CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Slides:



Advertisements
Similar presentations
Context-Free and Noncontext-Free Languages
Advertisements

The Pumping Lemma for CFL’s
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Closure Properties of CFL's
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CS 3240: Languages and Computation Properties of Context-Free Languages.
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.
CS5371 Theory of Computation
1 Module 33 Non-context free languages –Intuition and Examples CFL Pumping Lemma –Comparison to regular language pumping lemma –What it means –Proof overview.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Normal forms for Context-Free Grammars
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.3: Non-Context-Free Languages) David Martin With.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
CS 3240 – Chapter 8.  Is a n b n c n context-free? CS Properties of Context-Free Languages2.
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.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
1 Properties of Context-Free Languages Is a certain language context-free? Is the family of CFLs closed under a certain operation?
Context-free Languages
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
Context-Free and Noncontext-Free Languages Chapter 13 1.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
Context-Free and Noncontext-Free Languages Chapter 13 1.
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.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
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.
Non-Context-Free Languages Section 2.3 CSC 4170 Theory of Computation.
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.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
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.
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Context-Free and Noncontext-Free Languages Chapter 13.
Lecture 15 Pumping Lemma.
Lecture 17 Oct 25, 2011 Section 2.1 (push-down automata)
Non-Context-Free Languages
Definition: Let G = (V, T, P, S) be a CFL
COSC 3340: Introduction to Theory of Computation
Properties of Context-Free Languages
Bottom-up parsing Pumping Theorem for CFLs
COSC 3340: Introduction to Theory of Computation
CS21 Decidability and Tractability
Chapter 2 Context-Free Language - 02
CS21 Decidability and Tractability
Pumping Theorem for CFLs
Intro to Theory of Computation
Presentation transcript:

CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Objectives Introduce Pumping Lemma for CFL Apply Pumping Lemma to show that some languages are non-CFL

Pumping Lemma for CFL Theorem: If L is a CFL, then there is a number p (pumping length) where, if w is any string in L of length at least p, we can find u,v,x,y,z with w = uvxyz and –for each i  0, uv i xy i z is in L –|vy|  0, and –|vxy|  p

Proof of Pumping Lemma Let b be the maximum branching factor in the parse tree of any string in L –that is, the right side of any rule has at most b terminals and variables) We shall use p = b |V|+1 to prove the lemma Observation: What is the minimum height of the parse tree for a string w with length at least p?

Proof of Pumping Lemma (2) Height of the parse tree  |V| + 1  some path in tree  |V|+2 nodes Only one such node can be a terminal  at least |V|+1 variable on the path What does that mean? Some variable appears at least twice

Proof of Pumping Lemma (3) Let R be a variable that appears at least twice Then, the parse tree of the string w looks something like: S R R uzxvy w =w = So, uv i xy i z is in L for any i  0 (why??)

uv i xy i z is in L for any i  0 Facts: R derives x, R derives vxy Since S derives uRz, and R derives x, S can derive uxz S R uz x S R u z R v y R v y x Since S derives uvRyz and R derives vxy, S can derive uvvxyyz

To complete the prove, we need to show |vy|  0 and |vxy|  p The current construction cannot, but we can do so if we further restrict: (1) parse tree is the smallest among all that can generate the string w (2) R is chosen from the lowest |V|+1 variables in the longest root-to-leaf path Proof of Pumping Lemma (5)

|vy|  0 Suppose on the contrary that |vy| = 0  Both v and y are empty strings Then in the parse tree, we replace “Subtree of R that generates vxy” by “Subtree of R that generates x” Resulting parse tree will also generate w (why?), but it has fewer nodes  contradiction occurs

|vxy|  p R is chosen from the lowest |V| + 1 variables in the longest root-to-leaf path Consider subtree of R that generates vxy Its height is at most |V|+1 (why?)  It has at most b |V|+1 leaves  Thus, vxy has at most p characters (as p = b |V|+1 ) Recall: b = maximum branching factor

Non-CFL (example 1) Theorem: The language A = {a n b n c n | n  0} is not a context-free language. How to prove? By contradiction, using pumping lemma First thing: Assume that A is CFL

Proof (example 1) Let p be the pumping length Let w = a p b p c p in A, and consider partition w into any u,v,x,y,z such that w = uvxyz Two possible cases: Case 1: Both v and y have only one type of char Case 2: v or y has more than one type of char In both cases, uvvxyyz is not in A (why?) Thus, we find a string at least p long in A that does not satisfy pumping lemma  contradiction occurs

Non-CFL (example 2) Theorem: The language B = {a i b j c k | 0  i  j  k} is not a context-free language. How to prove? By contradiction, using pumping lemma First thing: Assume that B is CFL

Proof (example 2) Let p be the pumping length Let w = a p b p c p in B, and consider partition w into any u,v,x,y,z such that w = uvxyz Two possible cases: Case 1: Both v and y have only one type of char Case 2: v or y has more than one type of char We can see that for Case 2, uvvxyyz cannot be in B How about Case 1?

Proof (example 2) Unfortunately, for Case 1, if v = b, y = c, then the string uvvxyyz is always in B… So, how to get a contradiction?? We divide Case 1 into two subcases: Subcase 1.1: char a not appear in both v and y Subcase 1.2: char a appears in v or y

Proof (example 2) For Subcase 1.1 (char a not appear in v and y), uxz cannot be in B [why?] For Subcase 1.2 (char a appears in v or y), uvvxyyz cannot be in B [why?] Thus, we find a string at least p long in B that does not satisfy pumping lemma  contradiction occurs

Non-CFL (example 3) Theorem: The language C = {ww | w in {0,1}*} is not a context-free language. How to prove? By contradiction, use pumping lemma on 0 p 1 p 0 p 1 p

Proof (example 3) When w = 0 p 1 p 0 p 1 p = uvxyz, what can be the corresponding vxy? –Case 1: vxy consists of one type of char –Case 2: vxy consists of two types of char For Case 1, uvvxyyz not in C (why?) For Case 2, vxy must cross a “01” or “10” boundary  Then, uxz cannot be in C (why?)

CFL is closed under all regular operations Union: We have seen that before Concatenation: Let G A and G B be CFGs for two CFLs A and B, using different sets of variables Let S A and S B be their start variables Combine the rules, add rule S  S A S B Star: Add rule S  S S A | 

CFL closed under complement? What is the complement of A = {a n b n c n | n  0}? The complement of A includes: –strings containing ba, ca, or cb; –strings a i b j c k with i  j or j  k  the complement of A is a CFL (why??) As A is not a CFL, what can we conclude? Assume  = {a, b, c}

CFL closed under intersection? Is A = {a n b n c m | n,m  0} a CFL? Is B = {a m b n c n | n,m  0} a CFL? What is the intersection of A and B? Is it a CFL? What can we conclude?

What we have learnt so far? PDA = CFG –Prove by Construction Properties of CFG - Ambiguous, Chomsky Normal Form Pumping Lemma –Prove by Contradiction (using Parse Tree) Existence of non-CFL

Language Hierarchy Set of Regular Language Set of Context- Free Language Set of Languages (= set of “set of strings”) {0 x 1 y } {0 n 1 n } {0 n 1 n 2 n } {w with even |w|} {w | w = w R } {ww}