Pumping Lemma for Context-Free Languages
Context: FIT2014_MOC · the property every CFL must have ➔ the tool that proves some languages are not context-free, closing the outer ring after Pumping Lemma for Regular Languages closed the inner one · applied in Proving a Language Non-Context-Free Parent Framework: Context-Free Grammars (CFG)
Quick Revision
- 🎯 Objective: in a CNF grammar with nonterminals, any generated word longer than forces a repeated nonterminal on a root-to-leaf path ➔ the subtree between the two copies can be re-inserted or deleted, pumping two substrings at once.
- 📦 Core Components: ➔ pump | = inner subtree’s yield | = untouched flanks.
- ⚡ Key Constraint: necessary, not sufficient — it proves non-context-freeness only. And unlike the regular case you must pump two blocks simultaneously, which is what the case analysis has to defeat.
🌳 Why a long word forces a repeated nonterminal
- Path length = non-leaf nodes ➔ in a parse tree, each non-leaf node carries a nonterminal symbol.
- Naive bound ➔ if some root-to-leaf path is longer than the number of nonterminals in the grammar, some nonterminal appears twice on it (pigeonhole).
- The gap ➔ nothing yet guarantees a long word produces a long path — a wide flat tree would defeat it. CNF closes the gap:
- Consequence ➔ if then , so ⟹ a nonterminal repeats on that path. (This is exactly what CNF’s binary shape is for.)
📜 The lemma
Theorem (Pumping Lemma for CFLs). Let be a context-free language with a CNF grammar having nonterminal symbols. Then for every with there exist strings with (i.e. not both empty) such that:
- for all : — i.e.
Symbolically:
🧮 Proof Blueprint
Theorem. As stated above.
Strategy. Pigeonhole a repeated nonterminal onto a root-to-leaf path of a CNF parse tree, then splice the subtree between the two copies.
Derivation.
Q.E.D. (The final step is formalised by induction on .)
⚖️ A Tale of Two Pumping Lemmas
| Regular | Context-free | |
|---|---|---|
| Object with the bound | FA with states | CNF grammar with nonterminals |
| ”Sufficiently long” | ||
| What repeats | a state on the accepting path | a nonterminal on a root-to-leaf path |
| Decomposition | ||
| Blocks pumped | one () | two, in lockstep ( and ) |
| Non-emptiness | (either may be empty, not both) | |
| Locality bound | ||
| Conclusion |
When It Flips: a language that survives the regular lemma's failure is often context-free by pumping two blocks — pumps together. Three coupled blocks () is where two pumping sites run out, and that is the CFL frontier.
⚠️ Common Mistakes
- 💡 , not ➔ one of them may be empty; only the pair must be non-empty. A proof that assumes both are non-empty is incomplete.
- 💡 The bound is on , not ➔ the regular lemma bounds a prefix; here the bound confines the pumped material plus the gap between the two blocks, and it can sit anywhere in .
- 💡 Necessary, not sufficient ➔ satisfying the lemma never proves a language is context-free; build a CFG or PDA for that.
- 💡 counts nonterminals in the CNF grammar ➔ not states, not terminals, not rules — and the grammar must be in Chomsky Normal Form for the bound to hold at all.
- 💡 is legal ➔ (delete both blocks) is as valid a pumped word as .
🧠 Active Recall
Where exactly does Chomsky Normal Form enter the proof, and what breaks without it?
Answer
- Short answer: twice. (1) Binary trees give , converting “long word” into “long path” and hence a repeated nonterminal — without it a flat wide tree gives a long word with a short path. (2) Binariness forces node to have two children with only one above , which is what guarantees .
- Why: Ban shrinking and renaming ➔ CNF has no -rules and no unit rules, so no derivation step wastes tree height; every level genuinely doubles the maximum yield, making both the threshold and the locality bound exact.
Why must be chosen as far down the path as possible?
Answer
- Short answer: it guarantees every nonterminal below on the path is distinct, so that subpath has at most nodes ⟹ length ⟹ has at most leaves ⟹ .
- Why: The locality bound is bought by the choice ➔ any repeated pair would give conditions 1 and 3, but only the lowest repetition bounds the subtree’s height, and it is that bound which later confines and to a short window of — the leverage used in Proving a Language Non-Context-Free.