Sub topic 13
Using the Pumping Lemma to Show a Language Is Not Context-Free
Prerequisites and the proof pattern
Assume you know alphabets, strings, languages, finite automata, and proof by contradiction. You should also know that a context-free language (CFL) is a language generated by a context-free grammar or recognised by a pushdown automaton.
The pumping lemma for CFLs gives a necessary property of every CFL. If a language fails this property, it cannot be context-free.
If \(L\) is context-free, then there is a pumping length \(p\) such that every string \(z\) in \(L\) with \(|z| \ge p\) can be written as
\[ z = uvwxy \]
with:
- \(|vwx| \le p\),
- \(|vx| \ge 1\),
- \(uv^iwx^iy \in L\) for every \(i \ge 0\).
The substrings \(v\) and \(x\) are the parts that can be repeated. The middle substring \(w\) stays fixed.
The quantifiers matter
To prove that a language is not context-free, assume that it is context-free and let \(p\) be its pumping length. Choose one carefully designed string \(z\) in the language.
Then consider every valid decomposition \(z=uvwxy\). You must show that at least one pumping value, usually \(i=0\) or \(i=2\), produces a string outside the language.
A common error is to choose one convenient decomposition. The lemma does not promise that you control the decomposition. Your proof must handle all decompositions satisfying the length conditions.
Worked proof: equal numbers of three symbols
Consider
\[ L = \{a^n b^n c^n \mid n \ge 1\}. \]
We prove that \(L\) is not context-free.
Assume, for contradiction, that \(L\) is context-free. Let \(p\) be its pumping length. Choose
\[ z=a^p b^p c^p. \]
This string belongs to \(L\), and its length is at least \(p\). By the lemma, write \(z=uvwxy\), where \(|vwx|\le p\) and \(|vx|\ge1\).
The substring \(vwx\) cannot contain both an \(a\) and a \(c\). To reach an \(a\) and a \(c\), it would have to cross all \(p\) symbols \(b\), requiring more than \(p\) positions. Therefore, \(v\) and \(x\) together affect at most two symbol groups.
At least one of \(v\) and \(x\) is nonempty, so pumping changes the number of at least one symbol. At least one other symbol count remains \(p\). For example, pumping with \(i=2\) gives
\[ uv^2wx^2y. \]
The three symbol counts are no longer equal, or the symbols are no longer in the required block order. Thus the pumped string is not in \(L\), contradicting the pumping lemma.
Therefore, \(L\) is not context-free.
A practical checklist
- Choose a string with equal or otherwise tightly linked counts.
- Use the length bound to restrict where \(v\) and \(x\) can occur.
- Pump with \(i=0\) or \(i=2\).
- Show the required relationship fails.
- Conclude by contradiction.
Exercise
Why is z = a^p b^p c^p a suitable choice for proving that {a^n b^n c^n | n ≥ 1} is not context-free?
Show answer
It belongs to the language, has length at least p, and its three equal blocks make any local pumping change the required equality.