Overview Mathematical Induction Derivations Recursive Inference Parse Trees Equivalence of Inference, Derivations, and Parse Trees.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
Induction and recursion
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Induction Sections 41. and 4.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Formalizing Alpha: Soundness and Completeness Bram van Heuveln Dept. of Cognitive Science RPI.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Induction Sections 4.1 and 4.2 of Rosen Fall 2010
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-regular languages.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.
Induction and recursion
Induction and recursion
Chapter 6 Mathematical Induction
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Classification of grammars Definition: A grammar G is said to be 1)Right-linear if each production in P is of the form A  xB or A  x where A and B are.
CS 3240: Languages and Computation Context-Free Languages.
Context Free Grammars. Context Free Languages (CFL) The pumping lemma showed there are languages that are not regular –There are many classes “larger”
Chapter Mathematical Induction 4.2 Strong Induction and Well-Ordering 4.3 Recursive Definitions and Structural Induction 4.4 Recursive Algorithms.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Context-Free Languages
Inductive Proofs and Inductive Definitions Jim Skon.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Slide Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Mathematical Induction
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach a particular.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
5. Context-Free Grammars and Languages
CSCE 355 Foundations of Computation
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Lecture 15 Pumping Lemma.
Induction and recursion
Chapter 5 Induction and Recursion
CSCE 355 Foundations of Computation
Lecture 14 Grammars – Parse Trees– Normal Forms
Context-Free Languages
Infiniteness Test The Pumping Lemma Nonregular Languages
5. Context-Free Grammars and Languages
Induction and recursion
Finite Automata and Formal Languages
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Relationship to Left- and Rightmost Derivations
More Applications of the Pumping Lemma
Induction Chapter
Mathematical Induction
Applications of Regular Closure
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

Overview Mathematical Induction Derivations Recursive Inference Parse Trees Equivalence of Inference, Derivations, and Parse Trees

Mathematical Induction Climbing a ladder Given an infinitely long ladder, can we reach an arbitrarily high rung given that we can reach the first one and on any rung, we can climb up to the next one?

There are two operations involved in climbing a ladder: –Opn1 climb onto the first rung –Opn2 climb from the current rung to the next rung Algorithm to reach nth rung is as follows: Opn1  the basis step for i = 2 to n do Opn2  the inductive step

Suppose we label the rungs of the ladder with the positive integers Opn1 climb onto Rung 1 Opn2 climb from Rung k to Rung k+1 For any n, let P( n ) be true if and only if you can get to Rung n. That is, positive integer n has property P

If we can prove P (1) and ( ∀ k ) [ P ( k ) → P ( k +1)] then we can deduce ( ∀ n ) P ( n ) Operationally: P (1) is proved directly; P (1) → P (2) by the inductive step; P (2) → P (3) by the inductive step; P (3) → P (4) by the inductive step; etc.

Weak Mathematical Induction Given a predicate P :: Integer → Boolean, the principle of weak mathematical induction says that if we prove the two hypotheses – P (1) – ( ∀ k ) [ P ( k ) → P ( k+1)] then we can deduce ( ∀ n ) P ( n )

Strategy for weak induction (1)prove base case (2) assume P ( k ), prove P ( k +1)

Strong Mathematical Induction Given predicate P :: Integer → Boolean, the principle of strong mathematical induction says that if we prove the two hypotheses P (1) ( ∀ k )[ P (1) ∧ … ∧ P ( k –1) ∧ P ( k ) →P (k+1) ] then we can deduce ( ∀ n ) P ( n )

Strong Mathematical Induction Stated formally: P (1) ∧ ( ∀ k )[( ∀ r ) ( r ≤ k → P ( r )) → P ( k +1)] → ( ∀ n ) P ( n ) We have more true assumptions to use, namely, P (1), …, P ( k )

when is strong induction needed? when the proof of the inductive step involves “looking back” more than 1 when the proof of the inductive step involves “looking back” an unknown amount

Significance of Mathematical Induction To prove statements that assert a given property holds for all positive integers.

Derivations Example: Grammar for expressions. E → E + E E → E * E E → (E) E → id Show that a string is in the language by means of a derivation: E  E + E  (E) + E  (E) + E * E  (id) + E * E  (id) + id * E  (id) + id * id

Leftmost (rightmost) derivation Leftmost (rightmost) derivation: Eliminate the leftmost (rightmost) variable at each step. Notation:  lm,  rm.

Leftmost (rightmost) derivation –Leftmost Deriv. E  E + E  (E) + E  (id) + E  (id) + E * E  (id) + id * E  (id) + id * id –Rightmost Deriv. E  E + E  E + E * E  E + E * id  E + id * id  (E) + id * id  (id) + id * id

Recursive Inference Productions 1: E → I 2: E → E + E 3: E → E * E 4: E → (E) 5: I → a 6: I → b 7: I → Ia 8: I → Ib 9: I → I0 10: I → I1 String: a * (a + b00) Deductions: i: a  L(I), by rule 5 ii: b  L(I), by rule 6 iii: b0  L(I), by ii & rule 9 iv: b00  L(I), by iii & rule 9 v: a  L(E), by i & rule 1 vi: b00  L(E), by iv & rule 1 vii: a + b00  L(E), by v, vi, & rule 2 viii: (a + b00)  L(E), by vii & rule 4 ix: a * (a + b00)  L(E), by v, viii & rule 3

Parse Trees S S ( S S  ) Root is S. Leaves are in V  T  {  }. Internal nodes are in V. If then A → X 1 … X n. A X 1 … X n

Inference, Derivations, Parse Trees Derivation Leftmost Derivation Rightmost Derivation Parse Tree Recursive Inference Thm Thm Thm. 5.18

Recursive Inference → Tree Theorem 5.12: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If w  L(A) can be inferred from the recursive inference procedure, then an A-tree exists with yield w. Theorem 5.12: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If w  L(A) can be inferred from the recursive inference procedure, then an A-tree exists with yield w. Proof: The proof is by induction on the number of steps in the recursive inference. Basis: One step. Then A → w is a production. Thus, there exists a tree A where w = x 1 x 2 …x n. x 1 x 2 … x n

Step Step: More than one step. Last step came from looking at the production A → X 1 X 2 …X n, where it had been previously verified that x i  L(X i ) for each i, where w = x 1 x 2 …x n. Therefore, we have the following tree. A X 1 X 2 … X n x 1 x 2 x n From A → X 1 X 2 …X n By induction hypothesis w

Tree → Derivation Theorem 5.14: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If an A-tree with yield w exists, then there is a leftmost derivation A *  lm w in grammar G. Theorem 5.14: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If an A-tree with yield w exists, then there is a leftmost derivation A *  lm w in grammar G. Proof: The proof is by induction on the tree height. Basis: Height is one. Tree looks like this: A So, A → X 1 X 2 …X n = w is a production. X 1 … X n

Step Step: Height exceeds one. Tree looks like this: X 1 X 2 … X n-1 X n A x1x1 = x 2 = x n x n-1 = w

Step (Continued) X 1 X 2 … X n-1 X n A x1x1 = x 2 = x n x n-1 = w By induction hypothesis, X 1 *  lm x 1, X n-1 *  lm x n-1, etc. Trivially, X 2 *  lm x 2, X n *  lm x n, etc. From this, A  X 1 …X n, and w = x 1 …x n, it is quite easy to show A *  lm w.

Example Can prove the same thing for rightmost. In fact, the leftmost (rightmost) derivation corresponding to a parse tree is unique. Example: S a A S S b A a a b a Leftmost: S  aAs  aSbAS  aabAS  aabbaS  aabbaa Rightmost: S  aAS  aAa  AsbAa  aSbbaa  aabbaa

Derivation → Recursive Inference Theorem 5.18: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If a derivation A *  w exists in grammar G, then w  L(A) can be inferred via the recursive inference procedure. Theorem 5.18: Let G = (V, T, P, S) be a CFG, w  T*, and A  V. If a derivation A *  w exists in grammar G, then w  L(A) can be inferred via the recursive inference procedure. Proof: The proof is by induction on the length of the derivation. Basis: One step. Then A → w is a production, and clearly w  L(A) can be inferred.

Step Step: More than one step. We can write the derivation as A  X1X2…Xn *  x1x2…xn = w. By the induction hypothesis, we can infer that xi  L(Xi) for each i. Also A → X1X2…Xn is clearly a production, and hence we can infer that w  L(A).

Pumping Lemma -- Example (a) A1 = {0n1n2n|n >= 0} – Assume that A1 is regular – Then the pumping lemma is valid, let p be the pumping length – Let w = 0p1p2p be in A1,with |w| > p – Let w = xyz and x = 0^(p-1), y= 0, z = 1p2p. (WRONG!) Since |xy| 0 – According to the pumping lemma w0 = xyyz should be in A1 but w0 = 0^(p-1)1p2p is not in A1 => contradiction to the assumption – This means A1 is not regular

Solution

References pdfhttp://undergraduate.csse.uwa.edu.au/units/ /lectures/CS227_15_2004_Cond. pdf Text Book: section 5.2