4.6.12 · D3Theory of Computation

Worked examples — Pumping lemma for CFLs

2,944 words13 min readBack to topic

The scenario matrix

Every CFL-pumping problem falls into one of these cells. The last column names the example that covers it.

Cell What makes it this case Winning move Example
A. Three-block equality three letter-blocks must all match () window misses one block; pump Ex 1
B. Inequality / ordering counts must satisfy chain split into pump-up vs pump-down cases Ex 2
C. Copy / squared structure string is or has a repeated half clever witness ; pump breaks symmetry Ex 3
D. Arithmetic on a single count length is a perfect square / prime etc. pump changes length by a controllable amount Ex 4
E. Degenerate / boundary inputs , empty string, $ w <p$
F. The trap — actually IS a CFL pumping "succeeds"; you must NOT conclude give a grammar instead Ex 6
G. Real-world word problem balanced tags / matched resources model as language, then pump Ex 7
H. Exam twist — closure shortcut pumping directly is messy intersect with a regular language first Ex 8

We now clear every cell.


Ex 1 — Cell A: three-block equality


Ex 2 — Cell B: inequality / ordering


Ex 3 — Cell C: copy / squared structure


Ex 4 — Cell D: arithmetic on a single count


Ex 5 — Cell E: degenerate / boundary inputs


Ex 6 — Cell F: the trap (this language IS a CFL)


Ex 7 — Cell G: real-world word problem


Ex 8 — Cell H: exam twist (closure shortcut)


Recap

Recall Which cell needs a

two-case split, and why? Cell B (inequalities) ::: because the window may miss the 's (then pump up) or miss the 's (then pump down) — you must beat both possibilities.

Recall When does the pumping lemma stay silent?

On strings with , including ::: the guarantee only covers long strings, so short/degenerate inputs give no contradiction (Ex 5).

Recall If pumping "succeeds", what have you proved?

Nothing about CFL-ness ::: the lemma is necessary, not sufficient; prove membership with a grammar or PDA instead (Ex 6).

Related: Pumping lemma for CFLs · Chomsky Normal Form · Parse Trees and Derivations · Pigeonhole Principle · Pumping lemma for regular languages