Context-Free Languages Pumping Lemma
Pumping Lemma for CFL If L is a context-free language, then there is a number p (the pumping length) where, if s is any string in L of length at least p, then s may be divided into five pieces s=uvxyz satisfying the conditions: For each i ≥ 0, s=uvixyiz L, |vy| > 0, and |vxy| ≤ p.
Pumping Lemma as an “Adversary Game” We pick a language L that we want to show is not a CFL. Our “adversary” gets to pick p. We get to pick s, and may use p as a parameter when we do so. Our adversary gets to break s into uvxyz, subject only to the constraints that |vy| > 0, and |vxy| ≤ p. We “win” the game, if we can, by picking i and showing that uvixyiz is not in L.
Example 1: L = { 1n where n is prime} By intuition: Is L a context-free language? n=2: 11 n=3: 111 n=5: 11111 n=7: 1111111 n=13: 1111111111111
Example 1: L = { 1n where n is prime} Adversary picks a pumping length of p. Consider some prime n ≥ p+2. Such an n must exist since there are an infinite number of primes. Let s= 1n Adversary picks uvxyz. Let |vy| = m. Then, |uxz| = n-m.
Example 1: L = { 1n where n is prime} By the pumping lemma, uvn-mxyn-mz L |uvn-mxyn-mz| = |uxz| + (n-m)(|v| + |y|) = n-m + (n-m) m = (n-m) (m+1) Thus, |uvn-mxyn-mz| is not prime unless one of the above factors is 1. But, (m+1) > 1 since m=|vy|, and |vy| > 0. (n-m) > 1 since: n ≥ p+2 was chosen, and m ≤ p since m=|vy| ≤ |vxy| ≤ p