The Pumping Lemma For CFL'S: Statement Applications
1. The pumping lemma for context-free languages states that for any context-free language L and string z in L of length greater than n, z can be divided into five pieces uvwxy such that pumping the pieces yields strings also in L.
2. The proof of the pumping lemma works by taking a CNF grammar for L and showing that any parse tree for a string z of length greater than 2^m must have a path of length m+2 or more, where m is the number of variables in the grammar.
3. This allows identifying two identical variables v and x along a longest path such that pumping v and x yields strings also in the language according to the conditions of the
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
195 views14 pages
The Pumping Lemma For CFL'S: Statement Applications
1. The pumping lemma for context-free languages states that for any context-free language L and string z in L of length greater than n, z can be divided into five pieces uvwxy such that pumping the pieces yields strings also in L.
2. The proof of the pumping lemma works by taking a CNF grammar for L and showing that any parse tree for a string z of length greater than 2^m must have a path of length m+2 or more, where m is the number of variables in the grammar.
3. This allows identifying two identical variables v and x along a longest path such that pumping v and x yields strings also in the language according to the conditions of the
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14
1
The Pumping Lemma for CFLs
Statement Applications 2 Intuition Recall the pumping lemma for regular languages. It told us that if there was a string long enough to cause a cycle in the DFA for the language, then we could pump the cycle and discover an infinite sequence of strings that had to be in the language. 3 Intuition (2) For CFLs the situation is a little more complicated. We can always find two pieces of any sufficiently long string to pump in tandem. That is: if we repeat each of the two pieces the same number of times, we get another string in the language. 4 Statement of the CFL Pumping Lemma For every context-free language L There is an integer n, such that For every string z in L of length >n There exists z = uvwxy such that: 1. |vwx| <n. 2. |vx| > 0. 3. For all i >0, uv i wx i y is in L. 5 Proof of the Pumping Lemma Start with a CNF grammar for L {}. Let the grammar have m variables. Pick n = 2 m . Let z, of length >n, be in L. We claim (Lemma 1 ) that a parse tree with yield z must have a path of length m+2 or more. 6 Proof of Lemma 1 If all paths in the parse tree of a CNF grammar are of length <m+1, then the longest yield has length 2 m-1 , as in: m variables one terminal 2 m-1 terminals 7 Back to the Proof of the Pumping Lemma Now we know that the parse tree for z has a path with at least m+1 variables. Consider some longest path. There are only m different variables, so among the lowest m+1 we can find two nodes with the same label, say A. The parse tree thus looks like: 8 Parse Tree in the Pumping- Lemma Proof <2 m = n because a longest path chosen and only the bottom m+1 variables used. A A u v y x w Cant both be . 9 Pump Zero Times u y A v x A w u y A w 10 Pump Twice u y A v x A w u y A w A v x A v x 11 Pump Thrice u y A v x A w u y A w A v x A v x A v x Etc., Etc. 12 Using the Pumping Lemma {0 i 10 i | i >1} is a CFL. We can match one pair of counts. But L = {0 i 10 i 10 i | i >1} is not. We cant match two pairs, or three counts as a group. Proof using the pumping lemma. Suppose L were a CFL. Let n be Ls pumping-lemma constant. 13 Using the Pumping Lemma (2) Consider z = 0 n 10 n 10 n . We can write z = uvwxy, where |vwx| <n, and |vx| >1. Case 1: vx has no 0s. Then at least one of them is a 1, and uwy has at most one 1, which no string in L does. 14 Using the Pumping Lemma (3) Still considering z = 0 n 10 n 10 n . Case 2: vx has at least one 0. vwx is too short (length <n) to extend to all three blocks of 0s in 0 n 10 n 10 n . Thus, uwy has at least one block of n 0s, and at least one block with fewer than n 0s. Thus, uwy is not in L.