[PDF] CFL Pumping Lemma
[PDF] CFL Pumping Lemma
[PDF] CFL Pumping Lemma
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
PUMPING LEMMA FOR <strong>CFL</strong>’S<br />
CS 516<br />
1. <strong>Pumping</strong> <strong>Lemma</strong> for <strong>CFL</strong>’s<br />
Theorem 1. Let L be a <strong>CFL</strong>. There exists a natural number N (depending<br />
on L) such that if z ∈ L and |z| ≥ N, then there exists strings u, v, w, x, y<br />
satisfying the following conditions:<br />
(1) z = uvwxy<br />
(2) v ≠ ɛ or x ≠ ɛ<br />
(3) |vwx| ≤ N<br />
(4) ∀i ≥ 0, uv i wx i y ∈ L.<br />
Proof.<br />
(1) Let G = (V, Σ, P, S) be the CNF grammar for L. The parse tree for<br />
any z ∈ L using G will be a binary tree. Let N = 2 |V |+1 .<br />
(2) If |z| ≥ N, the height of the parse tree for z is ≥ |V | + 1. Therefore<br />
there is a path from the root to a leaf that contains |V | + 1 edges<br />
and uses |V | + 1 internal nodes. By the Pigeon Hole Principle, two<br />
of these nodes must be labeled with the same nonterminal, say A.<br />
S<br />
A<br />
A<br />
u v w x<br />
y<br />
(3) The following three derivations can occur yielding z = uvwxy ∈ Σ ∗ :<br />
(a) S ∗ ⇒ uAy (assume this is the penultimate A in the path)<br />
(b) A ∗ ⇒ vAx (assume this is the last A from the root in the path)<br />
(c) A ∗ ⇒ w<br />
(4) G contains no null productions and all internal nodes have exactly<br />
two children. Therefore v and x can not both be empty.<br />
(5) The height of the upper A is at most |V | + 1 so |vwz| ≤ 2 |V |+1 = N.<br />
(6) By applying the first derivation above once, the second derivation i<br />
times, and the third once we get:<br />
S ∗ ⇒ uAy ∗ ⇒ uv i Ax i y ∗ ⇒ uv i wx i y. □<br />
Date: September 15, 2009.<br />
1
2 CS 516<br />
2. Proving some languages are not context-free<br />
The sole purpose of the <strong>Pumping</strong> <strong>Lemma</strong> is to prove that certain languages<br />
are not context-free. The proofs generally follow this pattern:<br />
(1) Assume L is context-free (with the hopes of yielding a contradiction)<br />
and thus has a “pumping number” N.<br />
(2) Pick a cleverly crafted string z such that z ∈ L and |z| ≥ N. We<br />
don’t know N in general so z is always defined in terms of N.<br />
(3) Since z ∈ L and |z| ≥ N, all four conditions of the lemma must<br />
apply.<br />
(4) We deduce “something useful” about v and x from the first three<br />
conditions. Often we must consider several possible cases.<br />
(5) Using our knowledge of what v and x must look like, we pick a value<br />
i such that uv i wx i y ∉ L contradicting the last condition.<br />
For example, we can show L = {a n b n c n | n ≥ 0} is not context-free as<br />
follows.<br />
(1) Assume L is context-free and thus has a “pumping number” N.<br />
(2) Let z = a N b N c N .<br />
(3) Since z ∈ L and |z| = 3N ≥ N, the four conditions of the <strong>Pumping</strong><br />
<strong>Lemma</strong> must apply.<br />
(4) Therefore, there exists strings u, v, w, x, y such that<br />
z = uvwxy = a } .{{ . . a}<br />
b } .{{ . . b}<br />
c } .{{ . . c}<br />
.<br />
N N N<br />
(5) Since |vwx| ≤ N we have<br />
v, x ∈ a ∗ ∪ b ∗ ∪ c ∗ ∪ a ∗ b ∗ ∪ b ∗ c ∗<br />
(6) If either v or x is in the set a + b + ∪b + c + then uv 2 wx 2 y ∉ a ∗ b ∗ c ∗ ⊃ L.<br />
(7) So v, x ∈ a ∗ ∪ b ∗ ∪ c ∗ but v and x are not both empty. Therefore<br />
uv 2 wx 2 y does not contain an equal number of a’s, b’s, and c’s and<br />
thus can not be in L. □<br />
Note that L is context-sensitive:<br />
S → aSBC | aBC<br />
CB → BC<br />
aB → ab<br />
bB → bb<br />
bC → bc<br />
cC → cc<br />
Notes:<br />
• Regular languages are “1-pumpable.”<br />
• Context-free languages are “2-pumpable.”<br />
• As before, you only get to pick z and i. The nature of the strings<br />
u, v, w, x, y are deduced from the first three conditions.