Proving a Language Non-Context-Free
Context: FIT2014_MOC Β· the exam-standard use of the CFL pumping lemma Β· the outer-ring twin of Proving a Language Non-Regular Problem it solves: given a language, prove it is not context-free β i.e. no CFG and no PDA can handle it.
Quick Revision
- π― Trigger: the language needs three or more unboundedly-coupled counts (or two interleaved copies) β two pumping blocks cannot keep them all in step.
- β οΈ Key Constraint: you choose ; you must then defeat every decomposition with and β so the case split must be exhaustive, not illustrative.
π The recipe
- Assume is context-free βΉ it has a CFG βΉ it has one in CNF generating .
- Let = number of nonterminals in that CNF grammar. (You never see the grammar; is just a number the lemma hands you.)
- Choose a suitable with β parameterise it so the length condition is satisfiable, e.g. take and .
- Consider any with , , .
- Exhibit an with β in every case.
- Contradiction with the lemma βΉ is not context-free.
- β‘ The case split writes itself β partition on where and sit: (1) each inside a single homogeneous stretch, (2) one of them straddles a boundary. Straddling cases die instantly, because pumping creates a second occurrence of a boundary pattern.
π₯ Worked example β
Theorem. is not context-free. Proof (by contradiction). Assume it is. Take its CNF grammar, let , take so that , and choose . Consider any with , , .
| Case | Where sit | Pumped word | Why it leaves |
|---|---|---|---|
| 1 | and are each all s, all s, or empty | each of lies inside one of the three stretches, so β₯1 stretch is unaltered; since , β₯1 other stretch grows βΉ the three lengths can no longer be equal | |
| 2 | or contains | the word now has two occurrences of ; every word of has at most one | |
| 3 | or contains | same argument β two occurrences of , impossible in |
In every case some (here ) gives , violating the lemma. Contradiction βΉ is not context-free.
- π The counting principle β two pumping blocks can keep two counts in step ( is context-free: pump ). Three coupled counts exhaust them β that is precisely the CFL frontier.
- Note the unused hypothesis β this proof never needs ; the three-stretch pigeonhole alone does the work. Practice 2 is where that bound earns its keep.
βοΈ Practice
Practice 1: prove is not context-free.
Reference solution
- Assume context-free; take a CNF grammar with nonterminals; take and , so .
- Take any with , , .
- Case A β each within one letter-block. They occupy at most two of the three blocks, so one block is untouched while grows another βΉ has unequal counts βΉ .
- Case B β or straddles a boundary (contains or ). Then has letters out of order (e.g. an after a ), and every word of is sorted s-then-s-then-s βΉ .
- Contradiction βΉ is not context-free.
- Key move: identical skeleton to β three blocks, two pumping sites. Only the βwhy it leaves β reason changes (order violation instead of a repeated ).
Practice 2 (harder β this one genuinely needs ): prove is not context-free.
Reference solution
- Assume context-free; CNF grammar with nonterminals; choose and , and (since ).
- Take any valid . Because and the -block has length , the window cannot contain both an and a .
- Case A β contains no . Pump up (): the -count stays while . But forces βΉ .
- Case B β contains no . Pump down (): the -count stays . If contains a then , breaking ; otherwise is all s so , breaking βΉ .
- Contradiction βΉ is not context-free.
- Key move: the locality bound is what forces the two-case split β it is the CFL analogue of the regular lemmaβs , and picking is what makes it bite.
β οΈ Common Mistakes
- π‘ You choose ; you do NOT choose β the lemma says such a decomposition exists; to contradict it you must defeat every one. Picking a convenient yourself is the most common invalid proof.
- π‘ Forgetting that or may be empty β only is guaranteed. Case analyses that assume both are non-empty miss decompositions.
- π‘ Forgetting the straddling cases β a proof that only handles β inside single blocksβ is incomplete and loses marks even though those cases are the easy ones.
- π‘ Reusing the regular lemmaβs shape β there is no prefix bound here; the constraint is and it pins a window, not a prefix.
- π‘ This never proves context-freeness β to show is a CFL, build a CFG or a PDA.
π§ Active Recall
Why is context-free while is not?
Answer
- Short answer: the CFL lemma gives two pumping blocks, and , incremented in lockstep. Two blocks can maintain two coupled counts (, keeps them equal), but with three stretches at least one is always left behind βΉ equality breaks.
- Why: Blocks vs counts β the same accounting explains the whole hierarchy: the regular lemma pumps one block, so it already fails at ; a PDAβs single stack can match one pair of counts, not two nested pairs.