Critique this PDA for L= { u u R v v R : u ∈ {0,1}* and v ∈ {0,1}+ } u0εu0 u1εu1 uεεvε v00vε v11vε vεεfε sεεtε t0εt0 t1εt1 t00tε t11tε tεεuε After you.

Slides:



Advertisements
Similar presentations
CS 3240: Languages and Computation Properties of Context-Free Languages.
Advertisements

1 Introduction to Computability Theory Lecture7: The Pumping Lemma for Context Free Languages Prof. Amos Israeli.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
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.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
1 Background Information for the Pumping Lemma for Context-Free Languages Definition: Let G = (V, T, P, S) be a CFL. If every production in P is of the.
Prof. Busch - LSU1 Pumping Lemma for Context-free 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.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
Design contex-free grammars that generate: L 1 = { u v : u ∈ {a,b}*, v ∈ {a, c}*, and |u| ≤ |v| ≤ 3 |u| }. L 2 = { a p b q c p a r b 2r : p, q, r ≥ 0 }
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
1 Problem of the Day: Factor (ab) k as xyz in all ways such that y ≠ ε.
Context-Free and Noncontext-Free Languages Chapter 13 1.
1 L= { w c w R : w  {a, b}* } is accepted by the PDA below. Use a construction like the one for intersection for regular languages to design a PDA that.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Test # 2 Friday, November 2 nd Covers all of Chapter 2 Test # 2 will be 20% of final score (same as Test #1) Final Exam will be 40% of the final score.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Context-Free and Noncontext-Free Languages Chapter 13.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Bottom-up parsing Pumping Theorem for CFLs MA/CSSE 474 Theory of Computation.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Context-Free and Noncontext-Free Languages Chapter 13.
Standard Representations of Regular Languages
Lecture 15 Pumping Lemma.
PDAs Accept Context-Free Languages
DPDA Deterministic PDA
Definition: Let G = (V, T, P, S) be a CFL
COSC 3340: Introduction to Theory of Computation
Deterministic PDAs - DPDAs
The Pumping Lemma for CFL’s
Pumping Lemma for Context-free Languages
Properties of Context-Free Languages
Chapter 4 Properties of Regular Languages
COSC 3340: Introduction to Theory of Computation
Chapter 2 Context-Free Language - 02
DPDA Deterministic PDA
Announcements Midterm is Wednesday June 23 in class.
The Pumping Lemma for CFL’s
Applications of Regular Closure
Pumping Theorem for CFLs
The Pumping Lemma for CFL’s
Presentation transcript:

Critique this PDA for L= { u u R v v R : u ∈ {0,1}* and v ∈ {0,1}+ } u0εu0 u1εu1 uεεvε v00vε v11vε vεεfε sεεtε t0εt0 t1εt1 t00tε t11tε tεεuε After you identify the bugs and inefficiencies, design a nicer PDA for this language that is correct.

2 Assignment #4 will be posted soon and will be due on Friday Nov. 18. The FINAL final exam schedule has been posted. CSC 320: Tuesday Dec. 6 at 2pm Drop deadline: Oct. 31

3

4 Languages which are not context-free { a n b n c n : n ≥ 0}

5 Languages which are not context-free The pumping lemma, a statement about context- free languages, is used to create proofs (by contradiction) that languages are not context- free. Closure properties can be used: Recall that intersecting a context-free language and a regular language gives a context-free language. Once we have some languages proven to not be context-free, we can give counterexamples to show that context-free languages are not closed under intersection or complement.

6 The Pumping Theorem for Context-Free Languages: Let G be a context-free grammar. Then there exists some constant k which depends on G such that for any string w which is generated by G with |w| ≥ k, there exists u, v, x, y, z, such that 1. w= u v x y z, 2. |v| + |y| ≥ 1, and 3. u v n x y n z is in L for all n ≥ 0.

7 Path: S - A - T - A Non-terminal A is repeated. To pump: Look for a path from root with a repeated non-terminal.

8

9 To pump n times: New yield is: = u v n x y n z

10 Theorem: L = { a n b n c n : n ≥ 0} is not context-free. Choose w= a k b k c k. Consider all possibilities for u, v, x, y, z: Case 1: v is in the a’s Case 2: v is in the b’s Case 3: v is in the c’s Case 4: v has both a’s and b’s Case 5: v has both b’s and c’s Case 6: v has a’s, b’s and c’s

11 w= a k b k c k. Case 1: v is in the a’s Case 1.1: y is in the a’s Case 1.2: y is in the b’s Case 1.3: y is in the c’s Case 1.4: y has both a’s and b’s Case 1.5: y has both b’s and c’s Case 1.6: y has a’s, b’s and c’s

12 w= a k b k c k. Case 2: v is in the b’s Case 2.1: y is in the b’s Case 2.2: y is in the c’s Case 2.3: y has both b’s and c’s Case 3: v is in the c’s Case 3.1: y is in the c’s

13 w= a k b k c k. Case 4: v has both a’s and b’s Case 4.1: y is in the b’s Case 4.2: y is in the c’s Case 4.3: y has both b’s and c’s Case 5: v has both b’s and c’s Case 5.1: y is in the c’s Case 6: v has a’s, b’s and c’s Case 6.1: y is in the c’s

14 Case 1: v is in the a’s Case 1.1: y is in the a’s Case 1.2: y is in the b’s Case 1.3: y is in the c’s Case 1.4: y has both a’s and b’s Case 1.5: y has both b’s and c’s Case 1.6: y has a’s, b’s and c’s Case 2: v is in the b’s Case 2.1: y is in the b’s Case 2.2: y is in the c’s Case 2.3: y has both b’s and c’s Case 3: v is in the c’s Case 3.1: y is in the c’s Case 4: v has both a’s and b’s Case 4.1: y is in the b’s Case 4.2: y is in the c’s Case 4.3: y has b’s and c’s Case 5: v has both b’s and c’s Case 5.1: y is in the c’s Case 6: v has a’s, b’s and c’s Case 6.1: y is in the c’s w= a k b k c k. MUST CONSIDER ALL CASES:

15 Case 1: v is in the a’s Case 1.1: y is in the a’s Case 1.2: y is in the b’s Case 1.3: y is in the c’s Case 1.4: y has both a’s and b’s Case 1.5: y has both b’s and c’s Case 1.6: y has a’s, b’s and c’s Case 2: v is in the b’s Case 2.1: y is in the b’s Case 2.2: y is in the c’s Case 2.3: y has both b’s and c’s Case 3: v is in the c’s Case 3.1: y is in the c’s Case 4: v has both a’s and b’s Case 4.1: y is in the b’s Case 4.2: y is in the c’s Case 4.3: y has b’s and c’s Case 5: v has both b’s and c’s Case 5.1: y is in the c’s Case 6: v has a’s, b’s and c’s Case 6.1: y is in the c’s CASE A: v and y contain at most one type of symbol. CASE B: v or y has more than one type of symbol.

16 Theorem: L = { a n b n c n : n ≥ 0} is not context-free. Choose w= a k b k c k. CASE A: v and y contain at most one type of symbol. Pump zero times. The number of occurrences of one or two types of symbols decreases but the number of occurrences of at least one type of symbol remains the same. Hence the resulting string no longer has equal numbers of a’s, b’s and c’s. CASE B: v or y has more than one type of symbol. Pump twice. The resulting string is not in L since it is not of the form a*b*c*.

17 Final formal proof (by contradiction): Theorem: L = { a n b n c n : n ≥ 0} is not context-free. Assume that L is context-free. Then there exists some constant k such that for all strings w in L with length at least k, the pumping theorem holds. Choose w= a k b k c k. This string w is in L and the length of w is at least k and therefore, the pumping theorem holds.

18 The Pumping Theorem for Context-Free Languages: Let G be a context-free grammar. Then there exists some constant k which depends on G such that for any string w which is generated by G with |w| ≥ k, there exists u, v, x, y, z, such that 1. w= u v x y z, 2. |v| + |y| ≥ 1, and 3. u v n x y n z is in L for all n ≥ 0.

19 Consider all ways to factor w as uvxyz such that |v| + |y| ≥ 1: CASE A: v and y contain at most one type of symbol. Pump zero times. The number of occurrences of one or two types of symbols decreases but the number of occurrences of at least one type of symbol remains the same. Hence the resulting string no longer has equal numbers of a’s, b’s and c’s. CASE B: v or y has more than one type of symbol. Pump twice. The resulting string is not in L since it is not of the form a*b*c*.

20 Note that I am very careful with the wording of the proof. For example: Case 1.2: v is in the a’s, y is in the b’s Factorizations are of the form: a i a j a k-i-j b r b s b k-r-s c k where j + s ≥ 1. v y Pumping zero times gives: a i (a j ) 0 a k-i-j b r (b s ) 0 b k-r-s c k = a i a k-i-j b r b k-r-s c k = a k-j b k-s c k NOTE: j + s ≥ 1. If j=0: a k b k-s c k  less b’s. If s=0: a k-j b k c k  less a’s. If j ≠ 0 and s ≠ 0: a k-j b k-s c k  more c’s than a’s or b’s.

21 Theorem: L= {w in {a, b, c}* : w has the same number of a’s, b’s and c’s} is not context-free. Proof (by contradiction): Assume L is context-free. Since a context-free language intersected with a regular language must be context-free, this means that: L’ = L ⋂ a* b* c* is context-free. But L’ = { a n b n c n : n ≥ 0} and hence L’ is not context-free.

22 The Pumping Theorem for Context-Free Languages: Let G be a context-free grammar. Then there exists some constant k which depends on G such that for any string w which is generated by G with |w| ≥ k, there exists u, v, x, y, z, such that 1. w= u v x y z, 2. |v| + |y| ≥ 1, and 3. u v n x y n z is in L for all n ≥ 0.

23 Proof: If the string w is long enough, then there is a path from the root with a non-terminal repeated which does not have both v and y equal to the empty string.

24 Take parse tree apart to get building blocks.

25 To pump 0 times: New yield is u x z = u v 0 x y 0 z

26 To pump 2 times: New yield is u v v x y y z = u v 2 x y 2 z

27 To pump 3 times: New yield is u v v v x y y y z = u v 3 x y 3 z

28 New yield is u v n x y n z To pump n times: