2. PUMPING LEMMA
There are two Pumping Lemmas, which are defined for
1. Regular Languages, and
2. Context – Free Languages
3. APPLICATIONS OF PUMPING LEMMA
Pumping Lemma is to be applied to show that certain
languages are not regular.
It should never be used to show a language is regular.
If L is regular, it satisfies Pumping Lemma.
If L does not satisfy Pumping Lemma, it is non-
regular.
4. FORMAL STATEMENT
Pumping Lemma for Regular Languages
For any regular language L, there exists an integer n, such that for all w ∈
L with
|w| ≥ n, there exists (x, y, z ∈ Σ∗), such that w = xyz, and
(1) |xy| ≤ n
(2) |y| ≥ 1
(3) for all i ≥ 0: xyiz ∈ L
In simple terms, this means that if a string y is ‘pumped’, i.e., if y is
inserted any number of times, the resultant string still remains in L.
5. FORMAL STATEMENT
Pumping Lemma for Context-free Languages (CFL)
Pumping Lemma for CFL states that for any Context Free Language L, it is
possible to find two substrings that can be ‘pumped’ any number of times
and still be in the same language. For any language L, we break its strings
into five parts and pump second and fourth substring.
Pumping Lemma, here also, is used as a tool to prove that a language is not
CFL. Because, if any one string does not satisfy its conditions, then the
language is not CFL.
6. | w| n
The Pumping Lemma:
For infinite context-free language L
there exists an integer n such that
for any string
we can write
with lengths and |vy |1
w L,
w =uvxyz
| vxy | n
for all i 0
and it must be:
uvi xyiz L,
7. TAKE AN INFINITE CONTEXT-FREE
LANGUAGE
Example: S → AB
A →aBb
B → Sb
B → b
Generates an infinite number
of different strings
8. S → AB
A →
ABB B
→ SB B
→B
A derivation:
S AB aBbB abbB
abbSb abbABb abbaBbBb
abbabbBb abbabbbb
In a derivation of a long string,
variables are repeated
23.
S uAz AvAy
Ax
We know:
This string is also generated:
*
S uAzuxz
uv0xy0z
24. This string is also generated:
* *
S uAzuvAyzuvxyz
The original w =uv1xy1z
S uAz AvAy
Ax
We know:
25. This string is also generated:
* * *
S uAzuvAyzuvvAyyzuvvxyyz
uv2xy2z
S uAz AvAy
Ax
We know:
26. This string is also generated:
* *
S uAz uvAyzuvvAyyz
* *
uvvvAyyyzuvvvxyyyz
uv3xy3z
S uAz AvAy
Ax
We know:
27. We know:
S uAz AvAy A x
This string is also generated:
S uAz uvAyz uvvAyyz
uvvvAyyyz …
u v v v v A y yyyz
u v v v v x y yyyz
uvi xyiz
32. | w| n
The Pumping Lemma:
For infinite context-free language L
there exists an integer n such that
for any string
we can write
with lengths and |vy |1
w L,
w =uvxyz
| vxy | n
for all i 0
and it must be:
uvi xyiz L,