Title: The Pumping Lemma for ContextFree Languages
1The Pumping LemmaforContext-Free Languages
2Take an infinite context-free language
Generates an infinite number of different strings
Example
3In a derivation of a long string, variables are
repeated
A derivation
4Consider now an infinite context-free language
Let be the grammar of
Take so that I has no unit-productions
no
-productions
5(Number of productions) x (Largest right side
of a production)
Let
Let
Example
6Take a string with length
We will show in the derivation of
a variable of is repeated
7(No Transcript)
8maximum right hand side of any production
9Number of productions in grammar
10Number of productions in grammar
Some production must be repeated
Repeated variable
11Derivation of string
Some variable is repeated
12Derivation tree of string
Last repeated variable
repeated
Strings of terminals
13Possible derivations
14We know
This string is also generated
15We know
This string is also generated
The original
16We know
This string is also generated
17We know
This string is also generated
18We know
This string is also generated
19Therefore, any string of the form
is generated by the grammar
20Therefore,
knowing that
we also know that
21Observation
Since is the last repeated variable
22Observation
Since there are no unit or -productions
23The Pumping Lemma
For infinite context-free language
there exists an integer such that
for any string
we can write
with lengths
and it must be
24Applicationsof The Pumping Lemma
25Non-context free languages
Context-free languages
26Theorem
The language
is not context free
Proof
Use the Pumping Lemma for context-free languages
27Assume for contradiction that
is context-free
Since is context-free and infinite we can
apply the pumping lemma
28Pumping Lemma gives a magic number such that
Pick any string with length
We pick
29We can write
with lengths and
30Pumping Lemma says
for all
31We examine all the possible locations of string
in
32Case 1
is within
33Case 1
and consist from only
34Case 1
Repeating and
35Case 1
From Pumping Lemma
36Case 1
From Pumping Lemma
However
Contradiction!!!
37Case 2
is within
38Case 2
Similar analysis with case 1
39Case 3
is within
40Case 3
Similar analysis with case 1
41Case 4
overlaps and
42Case 4
Possibility 1
contains only
contains only
43Case 4
Possibility 1
contains only
contains only
44Case 4
From Pumping Lemma
45Case 4
From Pumping Lemma
However
Contradiction!!!
46Case 4
Possibility 2
contains and
contains only
47Case 4
Possibility 2
contains and
contains only
48Case 4
From Pumping Lemma
49Case 4
From Pumping Lemma
However
Contradiction!!!
50Case 4
Possibility 3
contains only
contains and
51Case 4
Possibility 3
contains only
contains and
Similar analysis with Possibility 2
52Case 5
overlaps and
53Case 5
Similar analysis with case 4
54There are no other cases to consider
(since , string cannot
overlap , and at the same
time)
55In all cases we obtained a contradiction
Therefore
The original assumption that
is context-free must be wrong
Conclusion
is not context-free