Professional Documents
Culture Documents
3
Formal definition of the Pumping
Lemma for CFL’s
Let L be a CFL. Then there exists a constant p
such that if z is any string in L where |z| p, then
write z = uvwxy subject to the following
conditions:
1. |vwx| p. p is the pumping length
2. vx ε. v and x both may not be empty.
3. For all i 0, uviwxiy is also in L.
pump both v and x.
Proof idea
Use CNF of CFG. The parse tree is a binary tree.
Let G have m variables. Choose m for the longest path in the tree.
– Let constant p = 2m.
– Suppose a string z = uvwxy where |z| p is in L(G)
– Choose a parse tree of length m+1
– Any parse tree that yields z must have a path of length at least
m+1, then yield will be 2m or less
A1
A2
…
Ak
• Variables A0,A1, … Ak
• If km then at least two of these variables must be
the same, since only m unique variables
Parse Tree (cont.)
Suppose the variables are the same at Ai=Aj
where k-m i < j k
A0
Ai=Aj although we
may follow different
Ai production rules for
each
Aj
u v w x y
Condition 2: vx ≠
A0
• Production Ai follows to Aj and
can’t be a terminal or there would
be no Aj.
• Therefore it has two variables; one Ai
of these must lead to Aj and the
other must lead to v or x or both. Aj
• This means v and x cannot both be
empty but one might be empty.
u v w x y
Condition 1: |vwx| p
• This says the yield of the
subtree rooted at Ai is p
• Since the tree has the A0
longest path m+1, it
follows that
|vwx| p 2m+1-1 Ai
u y
Condition 3: (cont.)
A0
• Substituting Ai for Aj
• Result: Ai
u v Aj x y
v w x
Example: Language L = {aibici: i > 0} is not
context-free
• Use the Pumping Lemma and Proof by contradiction
Suppose L is context-free. If string X L, and |X| > p,
then X=uvwxy, where |vwx| p.
Choose i that is greater than p. Then, wherever vwx
occurs in the string aibici, it cannot contain more than
two distinct letters-it can be all a's, all b's, all c's, or it
can be a's and b's, or it can be b's and c's.
Thus the string vx cannot contain more than two distinct
letters; but by the pumping lemma, it cannot be
empty, either, so it must contain at least one letter.
12
L = {aibici: i > 0} is not context-free (cont.)
13