CPSC 313 Winter, 2005 Ambiguity of Context-Free Grammars

Size: px
Start display at page:

Download "CPSC 313 Winter, 2005 Ambiguity of Context-Free Grammars"

Transcription

1 CPSC 313 Winter, 2005 Ambiguity of Context-Free Grammars This document includes several proofs concerning the ambiguity of various context-free grammars. This supplements the material on ambiguity in grammars and languages found in Section 5.4 of the textbook. 1 Proving That a Context-Free Grammar is Ambiguous Recall that a context-free grammar G = (V, P, T, S) is ambiguous if (and only if) there exists a string w in the language of G such that there are two (or more) different parse trees with root S and yield w in G. We can therefore show that a given context-free grammar G = (V, T, P, S) is ambiguous by a direct application of this definition by giving a string w L(G) along with two parse trees with root S and yield w in G. For example, consider the context-free grammar G = (V, T, P, W ), where V = {W, A, B}, T = {0, 1}, W is the start variable, and the grammar includes the following rules. W A B A 0W ɛ B 1W ɛ In order to see that this grammar is ambiguous, it is sufficient to give two different parse trees with root W and with same string, w = ɛ, as yield, such as the following. W W A B PSfrag replacements ɛ PSfrag replacements ɛ It is also true that a context-free grammar G = (V, T, P, S) is ambiguous if and only if there exists a string w in the language of G such that there are two or more leftmost derivations of w from the start variable. 1

2 Thus we can also show that the above grammar ambiguous by noting that the string w = ɛ has two leftmost derivations, namely, and W G A (using the rule W A) G ɛ (using the rule A ɛ) W G B (using the rule W B) G ɛ (using the rule B ɛ). Finally, it is true that a context-free grammar G = (V, T, P, S) is ambiguous if and only if there exists a string w in the language of G such that there are two or more rightmost derivations of w from the start variable. Thus we can prove that the above grammar G is ambiguous by giving two rightmost derivations of the empty string from the start variable W, as well. 2 Removing Ambiguity From a Grammar Sometimes we are asked to remove ambiguity from a given context-free grammar G = (V, T, P, S). In other words, we are asked to find a second context-free grammar, Ĝ = ( V, T, P, Ŝ) (with the same set of terminals) such that L(Ĝ) = L(G) and Ĝ is unambiguous. Section 5.4 of the textbook includes several heuristics that are useful when you are trying to remove ambiguity from a grammar. If you have not already done so then you should read this section of the text! However, it turns out that the current example is simple enough for ambiguity to be removed without using these rules. With a little effort it is possible to show that W G w for every string x T. This will be proved more formally later on. The variable A can be used to derive any nonnempty string in T that begins with a 0 as well as the empty string, and the variable B can be used to derive any nonempty string in T that begins with a 1 as well as the empty string. The only string that can be derived from both A and B is the empty string. It turns out that it is sufficient to remove all but one way to derive the empty string in the way that is shown below. We will be able to show that the language of the resulting grammar is T (as needed) that that the resulting grammar is unambiguous after that. With that noted, let us consider the grammar Ĝ = (V, T, P, S) that is the same as the grammar G except that Ĝ does not include the rule B ɛ: Ĝ has the rules W A B A 0W ɛ B 1W It is necessary to do two things to show that this is a correct answer that is, to show that Ĝ is a grammar that removes ambiguity from G: We must prove that L(Ĝ) = L(G), and we must also prove that Ĝ is unambiguous. However, we can see intuitively that the grammar is correct, as argued next. 2

3 2.1 Informal Argument That the Answer is Correct The only change made to the grammar G to produce Ĝ is removal of the rule allowing us to generate ɛ from B. Clearly, any string (of terminals) that could be generated from W in Ĝ can also be generated in G because G contains all the rules that Ĝ contains. If there is derivation of a string of terminals, say w,that can be generated in G but that cannot be generated in Ĝ, then the rule B ɛ must have been used in the derivation otherwise the derivation would also be a derivation in Ĝ. Part of the derivation must look as follows. uw v ubv uv w for some u, v (V T ). However, this part of the derivation can be replaced with uw v uav uv and thus the string w can also be derived in Ĝ. It follows that the language of the two grammars is the same. To see that Ĝ is unambiguous consider any string derived in Ĝ and its (leftmost) derivation. If the next symbol that we wish to derive is a 0 we must replace W with an A and then replace A with 0W. If the next symbol we wish to derive is a 1 then we must replace W with a B and replace B with 1W instead. We must continue until we have derived all terminal symbols we need, from left to right. Finally we must replace W with A which then can be replaced with ɛ. Since there is no choice during the entire derivation, there is only one derivation for each string and thus the grammar is unambiguous. The following sections prove that these intuitive arguments are indeed accurate. 2.2 Proving That Two Grammars Have the Same Language One way to prove that L(Ĝ) = L(G) is to prove that L(Ĝ) and L(G) are both equal to some given language L (in two separate proofs). In this case, L(Ĝ) and L(G) are each equal to T. This is implied by the following claims. Claim 1. W G w for every string w T. Sketch of Proof. This can be established by induction on the length of the string w that is mentioned in the claim. Basis: If the length of w is zero then w = ɛ, the empty string, and w can be derived from W as follows. W G A (using the rule W A) G ɛ (using the rule A ɛ). Inductive Step: Let n be an integer such that n 1. We must use the following Inductive Hypothesis to prove the following Inductive Claim in order to complete this step. Inductive Hypothesis: W G v for every string v T whose length is n 1. Inductive Claim: W G w for every string w T whose length is n. Completion of Inductive Step: Suppose, therefore, that w is a string in T with length n + 1. Since n 0, n and w must be nonempty. Since T = {0, 1}, w must begin with either a 0 or a 1. Each case will be considered separately, below. 3

4 Case: w begins with 0. In this case, w = 0x for some string x T whose length is n. It follows by the inductive hypothesis that W G x. This implies that 0W G 0x as well (see the online notes on Correctness of Context-Free Grammars if this is not clear). Therefore W G A (using the rule W A) G 0W (using the rule A 0W ) G 0x = w Case: w begins with 1. In this case, w = 1x (using the derivation described above). for some string x T whose length is n. It follows by the inductive hypothesis that W G x. This implies that 1W G 1x as well. Therefore W G B (using the rule W B) G 1W (using the rule B 1W ) G 1x = w (using the derivation described above). It has now been established that W G w in every possible case. Since w was an arbitrarily chosen string with length n + 1, this implies that W G w for every string w T with length n + 1, as required to complete the inductive step. It follow that W G w for every string w T, as claimed. Claim 2. W b G w for every string w T. The two grammars, G and Ĝ are similar enough for it to be easy to modify the proof of the first claim in order to prove the second claim. This is left as an exercise. Claim 3. L(Ĝ) = L(G). Proof. It follows by the two claims, given above, that L(Ĝ) = T = L(G). Another way to prove that two grammars G 1 and G 2 have the same language that will be helpful when Normal Forms for Context-Free Grammars are discussed is to describe a construction that can be be used to transform a derivation of a string w from the start variable of G 1, in the grammar G 1, into a derivation of the same string w from the start variable of G 2, in the grammar G 2, and then to prove that this transformation is correct establishing that L(G 1 ) L(G 2 ). Repeating the process, with the roles of the grammars G 1 and G 2 reversed, establishes that L(G 2 ) L(G 1 ) as well. Exercise: Try to do something like this. Transforming a derivation in Ĝ into one in G does not require any work at all. On the other hand, you should be able to use the ideas in Section 2.1 to prove that a derivation in G can also be transformed into a derivation in Ĝ either using induction on the number of steps in the original derivation or (even better) using induction on the number of times that the rule B ɛ is used in the derivation you start with. 4

5 2.3 Proving That a Context-Free Grammar is Unambiguous It is considerably more challenging to prove that a given context-free grammar is unambiguous than it is to prove that a grammar is ambiguous. In particular, in order to prove that a grammar G = (V, T, P, S) is unambiguous, it is necessary to prove that there is only one leftmost derivation (or rightmost derivation, or parse tree) of any given string w T from the start variable S. In the example, the grammar Ĝ is simple enough for it to be possible to prove this using mathematical induction on the length of w. A sketch of a proof that establishes this is given below. Claim 4. There is exactly one leftmost derivation of the string w from the variable W in the grammar Ĝ, for every string w T. Proof. This will be proved by induction on the length of w. Basis: Suppose that w has length zero: Then w is the empty string. Notice that W bg A (using the rule W A) bg ɛ (using the rule A ɛ) is a leftmost derivation of the empty string from W in Ĝ. We must show there is no other leftmost derivation of the empty string from W in this grammar. Suppose, to obtain a contradiction, that some other leftmost derivation of the empty string from W in Ĝ. Either this leftmost derivation begins with an application of the rule W A (just like the leftmost derivation that is listed above) or it does not. These cases will be considered separately. Case: The other leftmost derivation also begins with the rule W A. Consider what happens after this rule is applied: Since we are left with the variable A we must continue by using some rule with A on its left hand side. Now, if we used the rule A ɛ then we would be done but the resulting leftmost derivation would not be different from the above one, after all! So, this cannot be the case. It follows that we must use some other rule with A as its head. There is only one such rule, namely, the rule A 0W, so our leftmost derivation must begin as follows: W bg A (using the rule W A) bg 0W (using the rule A 0W ) However, now we are stuck! It is impossible to get rid of the leftmost 0 that is generated, so that the only strings in T that can possibly be generated have the form 0v for v T. Question: How could you prove the above claim in a more formal way? In particular, it is not possible to derive the empty string, because the empty string does not begin with a 0. Thus this case cannot arise. Case: The other leftmost derivation does not begin with the rule W B. In this case, we must begin by using the rule W B. Since there is only one rule with B as its head, 5

6 our leftmost derivation must begin as follows. W bg B (using the rule W B) bg 1W (using the rule B 1W ) However, now we are stuck once again: The only strings in T that can possibly be derived are strings that begin with 1. Thus this case cannot arise either. We have now obtained a contradiction, so the only assumption that we made must be false: There is only one leftmost derivation of the empty string from W in the grammar Ĝ. Inductive Step: Let n be an integer such that n 1. We must use the following Inductive Hypothesis to prove the following Inductive Claim: Inductive Hypothesis: If v T such that v = n 1 then there is exactly one leftmost derivation of v from W in the grammar Ĝ. Inductive Claim: If w T such that w = n then there is exactly one leftmost derivation of w from W in the grammar Ĝ. Completion of the Inductive Step: Let w be a string in T with length n. Since n 1 w is not the empty string, and T = {0, 1}, either w begins with a 0 or w begins with 1. These cases are considered separately, below. Case: w begins with 0. In this case, w = 0v for some string v T such that the length of v is n 1. Notice that it follows by the inductive hypothesis that there is exactly one leftmost derivation of v from W in Ĝ. To complete the proof in this case, you should give an argument like the one in the basis to show that every leftmost derivation of w from W in Ĝ must begin as follows. W bg A (using the rule W A) bg 0W (using the rule A 0W ) You can prove this in much the same way as a similar result in the basis: Notice that there is only a finite (and small!) number of other ways to begin a leftmost derivation. Consider every one of these other ways and obtain a contradiction in every case. Suppose, to obtain a contradiction, that there are at least two leftmost derivations of w from W in Ĝ that begin in the above way. Notice that if you deleted the first two lines of these, and then removed the leftmost 0 after that, you would produce two different leftmost derivations of v from W in Ĝ. Since it follows by the inductive hypothesis that there is only one leftmost derivation of v, this results in a contraction. It follows that there is only one leftmost derivation of w from W in Ĝ in this case. Case: w begins with 1. This case is very, very similar and its completion is left as an exercise. It follows (after the above exercise is completed) that there is exactly one leftmost derivation of w from W in each case. Since w was an arbitrarily chosen string with length n in T, this completes the inductive step. The desired result now follows by induction on the length of w. 6

7 About This and Other Proofs As the above proof should suggest, you should often consider a proof by contradiction: Assume that two leftmost derivations of some string (from some variable) exist and then establish a contradiction. In more complicated examples it can be necessary to prove that several other context-free grammars namely, the grammars that you get by choosing different start variables (and changing nothing else) are unambiguous too. Mutual inductions on the length of the string being derived, or the length the (shorter) derivation being considered, can be useful when you do this. In other cases, you might not need to use mathematical induction at all just as you do not necessarily need to use mathematical induction in some cases when you are trying to show that a given context-free grammar has a given language. Exercise: Modify the above proof to show that the following context-free grammars are unambiguous as well: 1. G A : This is the same context-free grammar as Ĝ, except that A is the start variable instead of W. 2. G B : This is the same context-free grammar as Ĝ, except that B is the start variable instead of W. 3 Proving That a Context-Free Language is Not Inherently Ambiguous Suppose that you are given a context-free language L probably, represented by a given context-free grammar G such that L(G) = L. Suppose, as well, that you wish to prove that L is not inherently ambiguous. One way to do this is to prove that the given context-free grammar, G, is unambiguous. Another way to do this (which will work if G is ambiguous, instead), is to give another context-free grammar Ĝ, and then to show that L(Ĝ) = L(G) (so that L(Ĝ) = L) and that Ĝ is unambiguous. In other words, another way to do this, that works when G is an ambiguous context-free grammar, is to remove ambiguity from the grammar G, as described in the previous section of this document. For example, if you were given the context-free language L = {0, 1}, represented by the context-free grammar G that was presented at the beginning of this document, then you could prove that L is not inherently ambiguous by giving the grammar Ĝ that has been presented, above, along with the claims and proofs. that are used to show that L(Ĝ) = L(G) and Ĝ is unambiguous, and that are found in the previous section. 4 Proving That a Context-Free Language is Inherently Ambiguous As noted in lectures and the textbook, the following language L is inherently ambiguous. L = {a i b j c k d l either i = j 0 and k = l 0, or i = l 0 and j = k 0} An informal argument that this is true can be found in Section of the text. A more formal proof of this can be found in the first edition of the textbook. However, this is for interest only: Proving that a given context-free language is inherently ambiguous is beyond the scope of this course, and students will not be asked to do this, or to describe how to do this, in CPSC

8 Instead, it will be sufficient for students to understand (and accept) that inherently ambiguous contextfree languages really do exist. 8

Full and Complete Binary Trees

Full and Complete Binary Trees Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac. Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free

More information

Handout #1: Mathematical Reasoning

Handout #1: Mathematical Reasoning Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

More information

Mathematical Induction

Mathematical Induction Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers. MATHEMATICAL INDUCTION MIGUEL A LERMA (Last updated: February 8, 003) Mathematical Induction This is a powerful method to prove properties of positive integers Principle of Mathematical Induction Let P

More information

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

WRITING PROOFS. Christopher Heil Georgia Institute of Technology WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this

More information

Basic Proof Techniques

Basic Proof Techniques Basic Proof Techniques David Ferry dsf43@truman.edu September 13, 010 1 Four Fundamental Proof Techniques When one wishes to prove the statement P Q there are four fundamental approaches. This document

More information

Cartesian Products and Relations

Cartesian Products and Relations Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

More information

Solutions for Practice problems on proofs

Solutions for Practice problems on proofs Solutions for Practice problems on proofs Definition: (even) An integer n Z is even if and only if n = 2m for some number m Z. Definition: (odd) An integer n Z is odd if and only if n = 2m + 1 for some

More information

CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

More information

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

More information

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 Proofs Intuitively, the concept of proof should already be familiar We all like to assert things, and few of us

More information

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? introduction Many students seem to have trouble with the notion of a mathematical proof. People that come to a course like Math 216, who certainly

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

Fundamentele Informatica II

Fundamentele Informatica II Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear

More information

6.3 Conditional Probability and Independence

6.3 Conditional Probability and Independence 222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

More information

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1. MATH10212 Linear Algebra Textbook: D. Poole, Linear Algebra: A Modern Introduction. Thompson, 2006. ISBN 0-534-40596-7. Systems of Linear Equations Definition. An n-dimensional vector is a row or a column

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

More information

Introduction to Automata Theory. Reading: Chapter 1

Introduction to Automata Theory. Reading: Chapter 1 Introduction to Automata Theory Reading: Chapter 1 1 What is Automata Theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Note: A device need not even be a

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

Worksheet for Teaching Module Probability (Lesson 1)

Worksheet for Teaching Module Probability (Lesson 1) Worksheet for Teaching Module Probability (Lesson 1) Topic: Basic Concepts and Definitions Equipment needed for each student 1 computer with internet connection Introduction In the regular lectures in

More information

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements. 3. Axioms of Set theory Before presenting the axioms of set theory, we first make a few basic comments about the relevant first order logic. We will give a somewhat more detailed discussion later, but

More information

C H A P T E R Regular Expressions regular expression

C H A P T E R Regular Expressions regular expression 7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

More information

THE DIMENSION OF A VECTOR SPACE

THE DIMENSION OF A VECTOR SPACE THE DIMENSION OF A VECTOR SPACE KEITH CONRAD This handout is a supplementary discussion leading up to the definition of dimension and some of its basic properties. Let V be a vector space over a field

More information

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing

More information

Row Echelon Form and Reduced Row Echelon Form

Row Echelon Form and Reduced Row Echelon Form These notes closely follow the presentation of the material given in David C Lay s textbook Linear Algebra and its Applications (3rd edition) These notes are intended primarily for in-class presentation

More information

Mathematical Induction. Lecture 10-11

Mathematical Induction. Lecture 10-11 Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

More information

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012 Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

More information

Turing Machines: An Introduction

Turing Machines: An Introduction CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

More information

k, then n = p2α 1 1 pα k

k, then n = p2α 1 1 pα k Powers of Integers An integer n is a perfect square if n = m for some integer m. Taking into account the prime factorization, if m = p α 1 1 pα k k, then n = pα 1 1 p α k k. That is, n is a perfect square

More information

Quotient Rings and Field Extensions

Quotient Rings and Field Extensions Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

More information

6.2 Permutations continued

6.2 Permutations continued 6.2 Permutations continued Theorem A permutation on a finite set A is either a cycle or can be expressed as a product (composition of disjoint cycles. Proof is by (strong induction on the number, r, of

More information

Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011. Lecture 1 Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

1. Prove that the empty set is a subset of every set.

1. Prove that the empty set is a subset of every set. 1. Prove that the empty set is a subset of every set. Basic Topology Written by Men-Gen Tsai email: b89902089@ntu.edu.tw Proof: For any element x of the empty set, x is also an element of every set since

More information

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010 CS 598CSC: Combinatorial Optimization Lecture date: /4/010 Instructor: Chandra Chekuri Scribe: David Morrison Gomory-Hu Trees (The work in this section closely follows [3]) Let G = (V, E) be an undirected

More information

Ambiguity, closure properties, Overview of ambiguity, and Chomsky s standard form

Ambiguity, closure properties, Overview of ambiguity, and Chomsky s standard form Ambiguity, closure properties, and Chomsky s normal form Overview of ambiguity, and Chomsky s standard form The notion of ambiguity Convention: we assume that in every substitution, the leftmost remaining

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

Basic numerical skills: EQUATIONS AND HOW TO SOLVE THEM. x + 5 = 7 2 + 5-2 = 7-2 5 + (2-2) = 7-2 5 = 5. x + 5-5 = 7-5. x + 0 = 20.

Basic numerical skills: EQUATIONS AND HOW TO SOLVE THEM. x + 5 = 7 2 + 5-2 = 7-2 5 + (2-2) = 7-2 5 = 5. x + 5-5 = 7-5. x + 0 = 20. Basic numerical skills: EQUATIONS AND HOW TO SOLVE THEM 1. Introduction (really easy) An equation represents the equivalence between two quantities. The two sides of the equation are in balance, and solving

More information

Set Theory Basic Concepts and Definitions

Set Theory Basic Concepts and Definitions Set Theory Basic Concepts and Definitions The Importance of Set Theory One striking feature of humans is their inherent need and ability to group objects according to specific criteria. Our prehistoric

More information

The Halting Problem is Undecidable

The Halting Problem is Undecidable 185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014 Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014 3.4: 1. If m is any integer, then m(m + 1) = m 2 + m is the product of m and its successor. That it to say, m 2 + m is the

More information

Sample Induction Proofs

Sample Induction Proofs Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given

More information

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010. Chapter 7: Digraphs

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010. Chapter 7: Digraphs MCS-236: Graph Theory Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010 Chapter 7: Digraphs Strong Digraphs Definitions. A digraph is an ordered pair (V, E), where V is the set

More information

Mathematical Induction. Mary Barnes Sue Gordon

Mathematical Induction. Mary Barnes Sue Gordon Mathematics Learning Centre Mathematical Induction Mary Barnes Sue Gordon c 1987 University of Sydney Contents 1 Mathematical Induction 1 1.1 Why do we need proof by induction?.... 1 1. What is proof by

More information

sin(x) < x sin(x) x < tan(x) sin(x) x cos(x) 1 < sin(x) sin(x) 1 < 1 cos(x) 1 cos(x) = 1 cos2 (x) 1 + cos(x) = sin2 (x) 1 < x 2

sin(x) < x sin(x) x < tan(x) sin(x) x cos(x) 1 < sin(x) sin(x) 1 < 1 cos(x) 1 cos(x) = 1 cos2 (x) 1 + cos(x) = sin2 (x) 1 < x 2 . Problem Show that using an ɛ δ proof. sin() lim = 0 Solution: One can see that the following inequalities are true for values close to zero, both positive and negative. This in turn implies that On the

More information

Connectivity and cuts

Connectivity and cuts Math 104, Graph Theory February 19, 2013 Measure of connectivity How connected are each of these graphs? > increasing connectivity > I G 1 is a tree, so it is a connected graph w/minimum # of edges. Every

More information

So let us begin our quest to find the holy grail of real analysis.

So let us begin our quest to find the holy grail of real analysis. 1 Section 5.2 The Complete Ordered Field: Purpose of Section We present an axiomatic description of the real numbers as a complete ordered field. The axioms which describe the arithmetic of the real numbers

More information

3 0 + 4 + 3 1 + 1 + 3 9 + 6 + 3 0 + 1 + 3 0 + 1 + 3 2 mod 10 = 4 + 3 + 1 + 27 + 6 + 1 + 1 + 6 mod 10 = 49 mod 10 = 9.

3 0 + 4 + 3 1 + 1 + 3 9 + 6 + 3 0 + 1 + 3 0 + 1 + 3 2 mod 10 = 4 + 3 + 1 + 27 + 6 + 1 + 1 + 6 mod 10 = 49 mod 10 = 9. SOLUTIONS TO HOMEWORK 2 - MATH 170, SUMMER SESSION I (2012) (1) (Exercise 11, Page 107) Which of the following is the correct UPC for Progresso minestrone soup? Show why the other numbers are not valid

More information

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p. Page 331, 38.2 Assignment #11 Solutions Factor the following positive integers into primes. a. 25 = 5 2. b. 4200 = 2 3 3 5 2 7. c. 10 10 = 2 10 5 10. d. 19 = 19. e. 1 = 1. Page 331, 38.4 Suppose a is a

More information

Math 4310 Handout - Quotient Vector Spaces

Math 4310 Handout - Quotient Vector Spaces Math 4310 Handout - Quotient Vector Spaces Dan Collins The textbook defines a subspace of a vector space in Chapter 4, but it avoids ever discussing the notion of a quotient space. This is understandable

More information

Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

More information

Automata and Formal Languages

Automata and Formal Languages Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

More information

1 if 1 x 0 1 if 0 x 1

1 if 1 x 0 1 if 0 x 1 Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

More information

Math 319 Problem Set #3 Solution 21 February 2002

Math 319 Problem Set #3 Solution 21 February 2002 Math 319 Problem Set #3 Solution 21 February 2002 1. ( 2.1, problem 15) Find integers a 1, a 2, a 3, a 4, a 5 such that every integer x satisfies at least one of the congruences x a 1 (mod 2), x a 2 (mod

More information

Practice with Proofs

Practice with Proofs Practice with Proofs October 6, 2014 Recall the following Definition 0.1. A function f is increasing if for every x, y in the domain of f, x < y = f(x) < f(y) 1. Prove that h(x) = x 3 is increasing, using

More information

Invalidity in Predicate Logic

Invalidity in Predicate Logic Invalidity in Predicate Logic So far we ve got a method for establishing that a predicate logic argument is valid: do a derivation. But we ve got no method for establishing invalidity. In propositional

More information

2 When is a 2-Digit Number the Sum of the Squares of its Digits?

2 When is a 2-Digit Number the Sum of the Squares of its Digits? When Does a Number Equal the Sum of the Squares or Cubes of its Digits? An Exposition and a Call for a More elegant Proof 1 Introduction We will look at theorems of the following form: by William Gasarch

More information

INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

More information

A Few Basics of Probability

A Few Basics of Probability A Few Basics of Probability Philosophy 57 Spring, 2004 1 Introduction This handout distinguishes between inductive and deductive logic, and then introduces probability, a concept essential to the study

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

Introduction. Appendix D Mathematical Induction D1

Introduction. Appendix D Mathematical Induction D1 Appendix D Mathematical Induction D D Mathematical Induction Use mathematical induction to prove a formula. Find a sum of powers of integers. Find a formula for a finite sum. Use finite differences to

More information

Lecture 2: Universality

Lecture 2: Universality CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

More information

x a x 2 (1 + x 2 ) n.

x a x 2 (1 + x 2 ) n. Limits and continuity Suppose that we have a function f : R R. Let a R. We say that f(x) tends to the limit l as x tends to a; lim f(x) = l ; x a if, given any real number ɛ > 0, there exists a real number

More information

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)! Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

More information

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions Theory of Formal Languages In the English language, we distinguish between three different identities: letter, word, sentence.

More information

THE BANACH CONTRACTION PRINCIPLE. Contents

THE BANACH CONTRACTION PRINCIPLE. Contents THE BANACH CONTRACTION PRINCIPLE ALEX PONIECKI Abstract. This paper will study contractions of metric spaces. To do this, we will mainly use tools from topology. We will give some examples of contractions,

More information

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

More information

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

More information

The Chinese Remainder Theorem

The Chinese Remainder Theorem The Chinese Remainder Theorem Evan Chen evanchen@mit.edu February 3, 2015 The Chinese Remainder Theorem is a theorem only in that it is useful and requires proof. When you ask a capable 15-year-old why

More information

Lecture 17 : Equivalence and Order Relations DRAFT

Lecture 17 : Equivalence and Order Relations DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/31/2011 Lecture 17 : Equivalence and Order Relations Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last lecture we introduced the notion

More information

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

More information

The last three chapters introduced three major proof techniques: direct,

The last three chapters introduced three major proof techniques: direct, CHAPTER 7 Proving Non-Conditional Statements The last three chapters introduced three major proof techniques: direct, contrapositive and contradiction. These three techniques are used to prove statements

More information

NUMBER SYSTEMS. William Stallings

NUMBER SYSTEMS. William Stallings NUMBER SYSTEMS William Stallings The Decimal System... The Binary System...3 Converting between Binary and Decimal...3 Integers...4 Fractions...5 Hexadecimal Notation...6 This document available at WilliamStallings.com/StudentSupport.html

More information

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set. Section 2.5 Cardinality (another) Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted A = B, if and only if there is a bijection from A to B. If there is an injection

More information

Deterministic Finite Automata

Deterministic Finite Automata 1 Deterministic Finite Automata Definition: A deterministic finite automaton (DFA) consists of 1. a finite set of states (often denoted Q) 2. a finite set Σ of symbols (alphabet) 3. a transition function

More information

3515ICT Theory of Computation Turing Machines

3515ICT Theory of Computation Turing Machines Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

More information

MATH 289 PROBLEM SET 4: NUMBER THEORY

MATH 289 PROBLEM SET 4: NUMBER THEORY MATH 289 PROBLEM SET 4: NUMBER THEORY 1. The greatest common divisor If d and n are integers, then we say that d divides n if and only if there exists an integer q such that n = qd. Notice that if d divides

More information

Lecture 2: Regular Languages [Fa 14]

Lecture 2: Regular Languages [Fa 14] Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.

More information

Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

More information

Computability Theory

Computability Theory CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

More information

SECTION 10-2 Mathematical Induction

SECTION 10-2 Mathematical Induction 73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

More information

Pigeonhole Principle Solutions

Pigeonhole Principle Solutions Pigeonhole Principle Solutions 1. Show that if we take n + 1 numbers from the set {1, 2,..., 2n}, then some pair of numbers will have no factors in common. Solution: Note that consecutive numbers (such

More information

Follow links for Class Use and other Permissions. For more information send email to: permissions@pupress.princeton.edu

Follow links for Class Use and other Permissions. For more information send email to: permissions@pupress.princeton.edu COPYRIGHT NOTICE: Ariel Rubinstein: Lecture Notes in Microeconomic Theory is published by Princeton University Press and copyrighted, c 2006, by Princeton University Press. All rights reserved. No part

More information

Math 223 Abstract Algebra Lecture Notes

Math 223 Abstract Algebra Lecture Notes Math 223 Abstract Algebra Lecture Notes Steven Tschantz Spring 2001 (Apr. 23 version) Preamble These notes are intended to supplement the lectures and make up for the lack of a textbook for the course

More information

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. 3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

More information

LEARNING OBJECTIVES FOR THIS CHAPTER

LEARNING OBJECTIVES FOR THIS CHAPTER CHAPTER 2 American mathematician Paul Halmos (1916 2006), who in 1942 published the first modern linear algebra book. The title of Halmos s book was the same as the title of this chapter. Finite-Dimensional

More information

ECON 312: Oligopolisitic Competition 1. Industrial Organization Oligopolistic Competition

ECON 312: Oligopolisitic Competition 1. Industrial Organization Oligopolistic Competition ECON 312: Oligopolisitic Competition 1 Industrial Organization Oligopolistic Competition Both the monopoly and the perfectly competitive market structure has in common is that neither has to concern itself

More information

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

More information

How To Understand The Theory Of Computer Science

How To Understand The Theory Of Computer Science Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked

More information

Computational Models Lecture 8, Spring 2009

Computational Models Lecture 8, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown Univ. p. 1 Computational Models Lecture 8, Spring 2009 Encoding of TMs Universal Turing Machines The Halting/Acceptance

More information