2. Pumping Lemma for CFG
Lemma:
Assume L is a context-free language, there is a
pumping length n such that any string w ∈ L of length ≥
n can be written as
|W| ≥ n
We can break W into 5 strings, W = u v x y z, such
that:
|vxy| ≤ n
|vy| ≠ ε
For all k ≥ 0, the string uvkxykz ∈ L.
Note: Select k such that the resulting string is not in L.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
2
3. Applications of Pumping Lemma:
Pumping lemma is used to check whether a
grammar is context free or not.
11/21/20173
Sampath Kumar S, AP/CSE, SECE
4. Problems to Discuss:
120. Find out whether the language L= {0n1n2n |n ≥ 1} is
context free or not.
Solution
At first, we assume that L is CFL.
At first, choose a number n of the pumping lemma.
Then, take z as 0n1n2n.
Break z into uvwxy,
where |vwx| ≤ n and
|vx| ≠ ε.
11/21/20174
Sampath Kumar S, AP/CSE, SECE
5. Sol. to problem 120:
Hence vwx cannot involve both 0s and 2s, since the
last 0 and the first 2 are at least (n+1) positions
apart. There are two cases −
Case 1 − vwx has no 2s. Then vx has only 0’s and
1’s. Then vwy, which would have to be in L,
has n 2’s, but fewer than n 0’s or 1’s.
Case 2 − vwx has no 0s.
Now assume k as 2 and apply it in uvkxykz which in ∉
L.
Hence, L is not a context-free language.
11/21/20175
Sampath Kumar S, AP/CSE, SECE
6. Problems to Discuss:
121. Prove that L = {ww|w ∈ {a,b}} is not CFL.
122. Prove that L = {0n1n2n3n|n>1} is not CFL.
123. Prove that L = {anbnci|i<n} is not CFL
124. Prove that L = {a2i|i>1} is not CFL
11/21/2017
Sampath Kumar S, AP/CSE, SECE
6