Example- Pumping Lemma For CFL
Using the Pumping Lemma to Show a Language is Not Context-Free
We will use the pumping lemma for context-free languages to prove that:
is not a context-free language.
Proof
Step 1: Assume is context-free
Suppose, for contradiction, that is a context-free language.
Then, by the pumping lemma, there exists a positive integer such that
any string with can be written as:
satisfying:
-
-
-
for all
Step 2: Choose a specific string in
Let us take:
Clearly, and .
Step 3: Analyze the possible locations of and
Because
the substring must lie within a span of length in .
That means can only cover a limited portion of —
it cannot stretch over all three regions (the block of a’s, b’s, and c’s).
Hence, and can appear in one of the following ways:
(a) Entirely within the block of a’s
(b) Entirely within the block of b’s
(c) Entirely within the block of c’s
(d) Across the boundary between a’s and b’s
(e) Across the boundary between b’s and c’s
We will show in each case that for some .
Step 4: Consider all possible cases
Case (a): lies entirely within the a’s
Then and contain only a’s.
When we pump , the number of a’s increases,
but the number of b’s and c’s remains the same.
Resulting string:
This string is not in because the numbers of a’s, b’s, and c’s are no longer equal.
Case (b): lies entirely within the b’s
Then and contain only b’s.
Pumping increases or decreases the number of b’s without changing a’s or c’s:
This is not in since the counts differ.
Case (c): lies entirely within the c’s
Similar to case (a):
This is not in .
Case (d): spans the boundary between a’s and b’s
Then contains some a’s and contains some b’s.
When we pump , we add extra a’s and b’s simultaneously,but not the same number necessarily, and no extra c’s.
Resulting string:
contains unequal numbers of a’s, b’s, and c’s → not in .
Case (e): spans the boundary between b’s and c’s
Similarly, pumping changes the number of b’s and c’s differently, producing a string with unequal counts.
Thus again
Step 5: Conclusion
In all possible cases, pumping changes the balance among a’s, b’s, and c’s.Therefore, there exists some (such as ) for which:
This contradicts the third condition of the pumping lemma.
Hence, our assumption that is context-free must be false.
🧠 Intuitive Summary
-
Pumping lemma tells us every long enough CFL string can be “pumped” by repeating some substrings and .
-
For , the balance of a’s, b’s, and c’s is strict.
-
Pumping always destroys that balance.
-
Therefore, no context-free grammar (and hence no PDA) can generate this language.
Comments
Post a Comment