Context Free Pumping Lemma. CFL Pumping Lemma A CFL pump consists of two non-overlapping substrings that can be pumped simultaneously while staying in.

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.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
1 Module 33 Non-context free languages –Intuition and Examples CFL Pumping Lemma –Comparison to regular language pumping lemma –What it means –Proof overview.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
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.
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)
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
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.
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.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
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.
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
Costas Busch1 More Applications of The Pumping Lemma.
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.
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.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
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.
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.
THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.
Overview Mathematical Induction Derivations Recursive Inference Parse Trees Equivalence of Inference, Derivations, and Parse Trees.
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.
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.
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.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
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.
CFL Big Picture. Context Free Languages Conclusion We have studied the class of context free languages (CFL) We saw two different ways to express a CFL.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
 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:
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Context-Free and Noncontext-Free Languages Chapter 13.
Non-regular languages
Standard Representations of Regular Languages
Lecture 15 Pumping Lemma.
Context Free Pumping Lemma Some languages are not context free!
Definition: Let G = (V, T, P, S) be a CFL
COSC 3340: Introduction to Theory of Computation
The Pumping Lemma for CFL’s
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Properties of Context-Free Languages
COSC 3340: Introduction to Theory of Computation
CS21 Decidability and Tractability
Chapter 2 Context-Free Language - 02
CS21 Decidability and Tractability
The Pumping Lemma for CFL’s
Applications of Regular Closure
The Pumping Lemma for CFL’s
Intro to Theory of Computation
Presentation transcript:

Context Free Pumping Lemma

CFL Pumping Lemma A CFL pump consists of two non-overlapping substrings that can be pumped simultaneously while staying in the language. Precisely, two substrings u and v constitute a CFL pump for a string w of L when 1.uv   (which means that at least one of u or v is not empty) 2.And we can write w=xuyvz, so that for every i  0 3.xu i yv i z  L

Pumping Lemma Let L be a CFL. Then there exists a number n (depending on L) such that every string w in L of length greater than n contains a CFL pump. Moreover, there exists a CFL pump such that (with the notation as above), |uyv|  n. For example, take L= {0 i 1 i | i  0 }: there are no (RE) pumps in any of its strings, but there are plenty of CFL pumps.

The pumping Lemma Game We want to prove L is not context-free. For a proof, it suffices to give a winning strategy for this game. 1.The demon first plays n. 2.We respond with w  L such that |w|  n. 3.The demon factors w into five substrings, w=xuyvz, with the proviso that uv   and |uyv|  n 4.Finally, we play an integer i  0, and we win if xu i yv i z  L.

Example 1 We prove that L= {0 i 1 i 2 i | i  0} is not context-free. In response to the demon's n, we play w=0 n 1 n 2 n. The middle segment uyv of the demon's factorization of w = xuyvz, cannot have an occurrence of both 0 and 2 ( because we can assume |uyv|  n ). Suppose 2 does not occur in uyv (the other case is similar). 1.We play i = 0. 2.Then the total number of 0's and 1's in w 0 =xyz will be smaller than 2n, 3.while the number of 2's in w 0 will be n. 4.Thus, w 0  L.

Example 2 Let L be the set of all strings over {0,1} whose length is a perfect square. 1.The demon plays n 2.We respond with w = 0 n^2 3.The demon plays a factorization 0 n^2 = xuyvz with 1  |uyv|  n. 4.We play i=2. 5.The length of the resulting string w 2 = xu 2 yv 2 z is between n 2 +1 and n 2 +n. 6.In that interval, there are no perfect squares, so w 2  L.

Proof of the pumping lemma Strategy in several steps 1.Define fanout 2.Define height yield 3.Prove a lemma about height yield 4.Apply the lemma to prove pumping lemma

Fanout Let fanout(G) denote the maximal length of the rhs of any production in the grammar G. E.g. For the Grammar – S  S S – S  ( S ) – S   The fanout is 3

Height Yield The proof of Pumping Lemma depends on this simple fact about parse trees. The height of a tree is the maximal length of any path from the root to any leaf. The yield of a parse tree is the string it represents (the terminals from a left-to- right in-order walk) Lemma. If a parse tree of G has height h, than its yield has size at most fanout(G) h Proof. Induction on h qed

The actual Proof The constant n for the grammar G is fanout(G) |V| where V is the set of variables of G. Suppose w  L(G) and |w|  n. Take a parse tree of w with the smallest possible number of nodes. By the Height-Yield Lemma, any parse tree of w must have height  |V|. Therefore, there must be two occurrences of the same variable on a path from root to a leaf. Consider the last two occurrences of the same variable (say A) on that path. They determine a factorization of the yield w=xuyvz as in the picture on the next slide

Diagram We have S   xAz A   uAv A   y so clearly S   xu i yv i z for any i  0. Start A A x u y v z

We also need to check that uv  . Indeed, if uv= , we can get a smaller parse tree for the same w by ignoring the productions “between the two As”. But we have chosen the smallest possible parse tree for w! Which leads to a Contradiction. Finally, we need to check that |uyv|  n. This follows from the Height-Yield Lemma because the nodes on our chosen path from the first depicted occurrence of A, onward, are labeled with necessarily distinct variables. qed