Pumping Lemma for CFL

Let LL be a CFL. Then ∃n∈N\exists n \in \mathbb{N} such that ∀u∈L\forall u \in L satisfying ∣u∣≥n|u| \ge n, there exist strings v,w,x,y,zv, w, x, y, z satisfying:

  • u=vwxyzu = vwxyz
  • ∣wy∣>0|wy| > 0
  • ∣wxy∣≤n|wxy| \le n
  • ∀m≥0\forall m \ge 0, vwmxymz∈Lvw^mxy^mz \in L

Using the Lemma to Prove Non-CFL

To show LL is not a CFL, assume LL is a CFL and derive a contradiction.

Standard proof structure:

  1. Assume LL is a CFL with pumping length nn.
  2. Choose a string u∈Lu \in L with ∣u∣≥n|u| \ge n.
  3. Consider all possible decompositions u=vwxyzu = vwxyz satisfying ∣wy∣>0|wy| > 0 and ∣wxy∣≤n|wxy| \le n.
  4. Show that for every such decomposition, some vwmxymz∉Lvw^mxy^mz \notin L for some m≥0m \ge 0.
  5. Contradiction. LL is not a CFL.

Example

Prove L={anbncn∣n≥1}L = \{a^n b^n c^n \mid n \ge 1\} is not a CFL.

Solution Reveal Hide

Assume LL is a CFL with pumping length pp. Choose u=apbpcpu = a^p b^p c^p, so ∣u∣=3p≥p|u| = 3p \ge p.

Any decomposition u=vwxyzu = vwxyz with ∣wxy∣≤p|wxy| \le p means wxywxy spans at most 2 of the 3 symbol types (cannot reach from the aa-block to the cc-block in pp characters).

Case 1: wxywxy lies entirely in apbpa^p b^p. Pumping increases the count of aas or bbs (or both) but not ccs. The pumped string has unequal counts.

Case 2: wxywxy lies entirely in bpcpb^p c^p. Pumping increases bbs or ccs but not aas. Unequal counts.

In all cases, vw2xy2z∉Lvw^2xy^2z \notin L. Contradiction. LL is not a CFL.

Ogden’s Lemma

A generalization of the pumping lemma for CFL. Allows marking “distinguished” positions in uu. Guarantees ww or yy contains at least 1 distinguished position.

Useful when the standard lemma is insufficient to force a contradiction. Every CFL satisfies Ogden’s lemma; it strictly subsumes the pumping lemma.

Written by October 19, 2026 2 min read
Was this helpful?