Pumping Lemma for CFL

2 min read Last updated Sat Jun 27 2026 08:46:52 GMT+0000 (Coordinated Universal Time)

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

  • u=vwxyzu = vwxyz
  • wy>0|wy| > 0
  • wxyn|wxy| \le n
  • m0\forall m \ge 0, vwmxymzLvw^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 uLu \in L with un|u| \ge n.
  3. Consider all possible decompositions u=vwxyzu = vwxyz satisfying wy>0|wy| > 0 and wxyn|wxy| \le n.
  4. Show that for every such decomposition, some vwmxymzLvw^mxy^mz \notin L for some m0m \ge 0.
  5. Contradiction. LL is not a CFL.

Example

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

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

Any decomposition u=vwxyzu = vwxyz with wxyp|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, vw2xy2zLvw^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.

Was this helpful?