RTUComputer ScienceYr 2024 · Sem 42024

Q2Theory of Computation

Question

10 marks

(a) State and prove the Pumping Lemma for Context-Free Languages. (b) Use Pumping Lemma to show that L = {a^n b^n c^n | n ≥ 1} is not context-free.

Answer

The CFL Pumping Lemma, proved from the bounded height of Chomsky Normal Form parse trees, guarantees a pumpable pair of substrings in any sufficiently long string of a context-free language, and applying it to a^n b^n c^n yields a contradiction proving that language is not context-free.

The lemma states: for any context-free language , there exists a constant (the pumping length) such that every string with can be written as satisfying: (1) (at least one of is non-empty), (2) (the combined pumped region is bounded), and (3) for all (both and can be pumped together, the same number of times each, and the string remains in ).

The proof relies on converting a CFG for into Chomsky Normal Form, so every internal node of a parse tree has exactly two children, and every derivation of a string of length produces a parse tree of height in the number of leaves relative to the branching factor, or more precisely: if has non-terminals, set (or similar bound). Then for any string with , its parse tree must have a path from root to leaf of length at least (since a binary tree of height has at most leaves, and we need enough leaves to spell out ). Since this path has more than non-terminal nodes but only distinct non-terminals exist, by the pigeonhole principle some non-terminal must repeat along this path. Let the lower occurrence of generate substring , and the upper occurrence generate the larger substring ; the portion of before is and after is , giving . Because derives both (from the lower occurrence) and (from the upper occurrence via a subderivation that itself passes through ), the subtree rooted at the lower can be substituted in place of itself repeatedly (or removed entirely), so for any , giving for all . The bound follows from choosing the two occurrences of to be the bottom-most repeated pair within the last nodes of the path, keeping the subtree small; and follows because in CNF, the derivation from the upper to the lower must consume at least one step introducing a terminal-generating sibling, since CNF rules are strictly binary-branching with no unit or null productions to allow a 'do-nothing' step.

Assume, for contradiction, that is context-free. Let be the pumping length guaranteed by the lemma. Choose ; clearly . By the lemma, with , , and for all .

Since , the substring cannot span all three blocks of 's, 's, and 's simultaneously (spanning all three would require length at least , to include at least the last a, all p b's, and the first c — actually more simply: since the block of 's alone has length , and 's and 's are separated by the full -block, can touch at most two of the three distinct blocks, because touching all three would force , contradicting ).

Case analysis: If lies entirely within the -block (or entirely within 's, or entirely within 's), pumping up to increases the count of that one symbol while leaving the other two unchanged, breaking the required equality of counts. If straddles the boundary between two adjacent blocks (e.g., spans some 's and some 's, or some 's and some 's), pumping with increases the counts of at most two of the three symbols (and by different amounts unless happen to add equally, which cannot hold across three total blocks), so the resulting string cannot have equal counts of or cannot preserve the required order . If lies entirely within one block's boundary but and are both non-empty from that same single block, only that symbol's count changes. In every case, either has unequal numbers of 's, 's, 's, or violates the required ordering pattern, so .

This contradicts the pumping lemma's guarantee that for all . Therefore the assumption that is context-free is false, and is not context-free. This is a canonical result distinguishing context-free from context-sensitive languages: requires simultaneously tracking two independent counts, which exceeds what a single stack (context-free) can enforce, but is well within reach of an LBA (context-sensitive), and indeed a Turing Machine, as shown by the explicit TM construction for this language.

Back to Paper