Sub topic 12
The Pumping Lemma for Context-Free Languages
Prerequisites and statement
Assume you know alphabets, strings, languages, finite automata, and proof by contradiction. Familiarity with the regular-language pumping lemma is helpful.
The pumping lemma for context-free languages gives a necessary property of every context-free language (CFL). If a language is context-free, then there is a number \(p\), called the pumping length, such that every string \(z\) in the language with \(|z| \ge p\) can be written as
\[ z = uvwxy \]
with these conditions:
- \(|vwx| \le p\)
- \(|vx| \ge 1\)
- \(uv^i w x^i y \in L\) for every integer \(i \ge 0\)
The parts \(v\) and \(x\) are the pumpable parts. Pumping means repeating or removing both parts the same number of times.
Why the lemma works
A context-free grammar can generate a sufficiently long parse tree with a repeated variable along one root-to-leaf path. The repeated variable creates two portions of the derivation that can be repeated. These portions correspond to \(v\) and \(x\).
The bound \(|vwx| \le p\) is important. It limits the repeated region to a short part of the string. For strings divided into several large blocks, this region cannot reach every block.
Standard proof strategy
To prove that a language \(L\) is not context-free:
- Assume that \(L\) is context-free.
- Let \(p\) be its pumping length.
- Choose a string \(z \in L\) with \(|z| \ge p\), usually using blocks of length \(p\).
- Consider every decomposition \(z=uvwxy\) satisfying the lemma's conditions.
- Use \(|vwx| \le p\) to restrict where \(v\) and \(x\) can occur.
- Choose one value of \(i\), often \(0\) or \(2\), for which the pumped string is not in \(L\).
- Contradict the lemma.
For \(L=\{a^n b^n c^n\mid n\ge1\}\), choose \(z=a^p b^p c^p\). The substring \(vwx\) cannot contain both an \(a\) and a \(c\), because the entire \(b^p\) block lies between them. Thus pumping changes at most two symbol blocks, while at least one block remains unchanged. The three counts become unequal, or the block order is broken. Therefore the pumped string is not in \(L\), so \(L\) is not context-free.
Exercise
Why must a pumping-lemma proof consider every valid decomposition of the chosen string?
Show answer
The lemma promises that at least one valid decomposition can be pumped. To contradict that promise, the proof must show that every valid decomposition fails for some pumping value.