Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

22-Pumping Lemma For CFL-11-03-2024

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Pumping Lemma in Theory of Computation

There are two Pumping Lemmas, which are defined for


1. Regular Languages (3 parts – xyz or uvw ) and
2. Context – Free Languages ( 5 parts – uvwxy )

Pumping Lemma for Regular Languages


For any regular language L, there exists an integer n,
such that for all x ∈ L with |x| ≥ n, there exists u, v, w
∈ Σ∗, such that x = uvw, and
(1) |uv| ≤ n
(2) |v| ≥ 1
(3) for all i ≥ 0: uviw ∈ L

In simple terms, this means that if a string v is


‘pumped’, i.e., if v is inserted any number of times, the
resultant string still remains in L.

Pumping Lemma is used as a proof for irregularity of a


language. Thus, if a language is regular, it always
satisfies pumping lemma. If there exists at least one
string made from pumping which is not in L, then L is
surely not regular.
The opposite of this may not always be true. That is, if
Pumping Lemma holds, it does not mean that the
language is regular.

For example, let us prove L01 = {0n1n | n ≥ 0} is


irregular.
Let us assume that L is regular, then by Pumping
Lemma the above given rules follow.
Now, let x ∈ L and |x| ≥ n. So, by Pumping Lemma,
there exists u, v, w such that (1) – (3) hold.

We show that for all u, v, w, (1) – (3) does not hold.


If (1) and (2) hold then x = 0n1n = uvw with |uv| ≤ n and
|v| ≥ 1.
So, u = 0a, v = 0b, w = 0c1n where : a + b ≤ n, b ≥ 1, c ≥
0, a + b + c = n
But, then (3) fails for i = 0
uv0w = uw = 0a0c1n = 0a + c1n ∉ L, since a + c ≠ n.

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.
Thus, if L is a CFL, there exists an integer n, such that
for all x ∈ L with |x| ≥ n, there exists u, v, w, x, y ∈
Σ∗, such that x = uvwxy, and
(1) |vwx| ≤ n
(2) |vx| ≥ 1
(3) for all i ≥ 0: uviwxiy ∈ L

For above example, 0n1n is CFL, as any string can be


the result of pumping at two places, one for 0 and other
for 1.
Let us prove, L012 = {0n1n2n | n ≥ 0} is not Context-free.
Let us assume that L is Context-free, then by Pumping
Lemma, the above given rules follow.
Now, let x ∈ L and |x| ≥ n. So, by Pumping Lemma,
there exists u, v, w, x, y such that (1) – (3) hold.
We show that for all u, v, w, x, y (1) – (3) do not hold.

If (1) and (2) hold then x = 0n1n2n = uvwxy with |vwx| ≤


n and |vx| ≥ 1.
(1) tells us that vwx does not contain both 0 and 2.
Thus, either vwx has no 0’s, or vwx has no 2’s. Thus,
we have two cases to consider.
Suppose vwx has no 0’s. By (2), vx contains a 1 or a 2.
Thus uwy has ‘n’ 0’s and uwy either has less than ‘n’
1’s or has less than ‘n’ 2’s.
But (3) tells us that uwy = uv0wx0y ∈ L.
So, uwy has an equal number of 0’s, 1’s and 2’s gives
us a contradiction. The case where vwx has no 2’s is
similar and also gives us a contradiction. Thus L is not
context-free.

A context-free grammar generates context-free


languages (CFLs). The set of all context-free
languages is the same as the set of languages
accepted by the pushdown automata. The set of
regular languages is a subset of context-free
languages.
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. We break
its strings into five parts for any language L and
pump the second and fourth substring. If any string
does not satisfy its conditions, then the language
is not CFL.
Theorem
If L is a context-free language, there is a constant
'n' that depends exclusively on L, such that if w? L
and |w| >= n, w can be divided into five pieces, w =
uvxyz, meeting the following requirements.
 |vxy| >=n

 |vy| # ε
k y
 For all k>=0, the string uv xy z∈L
Steps to apply pumping lemma
 Assume that L is context-free.

 The pumping length will be n.

 All strings longer than the length(n) can be

pumped-> |w|>=n.
 Now we have to find a string 'w' in L such

that |w|>=n.
 We will divide string 'w' into uvxyz.

 Now show that uv xy z ∉L for some


k k

constant k.
 Then, we have to consider the ways that w

can be divided into uvxyz.


 Show that none of these can satisfy all the

3 pumping conditions simultaneously.


 A string 'w' cannot be pumped

(contradiction).
Example
Find out whether L={xnynzn|n>=1} is context-free
or not
 Let L be context-free.

 'L' must be satisfying the pumping length,

say n.
n n n
 Now we can take a string such that s=x y z

 We divide s into 5 strings uvxyz.

Let n=4 so, s=x4y4z4


Case 1:
v and y each contain only one type of symbol.
{we are considering only v and y because v and y
has power uv2xy2z}
X xx x yyyyz z zz
=uvkxykz when k=2
=uv2xy2z
=xxxxxxyyyyzzzzz
=x6y4z5
(Number of x # number of y #number of z)
Therefore, The resultant string is not satisfying the
condition
x6y4z5 ∉ L
If one case fails, there is no need to check another
condition.
Case 2:
Either v or y has more than one kind of symbols
Xx xx yy y y zzzz
=uvkxykz (k=2)
=uv2xy2z
=xxxxyyxxyyyyyzzzz
=x4y2x2y5z2
This string is not following the pattern of our string
xnynzn

You might also like