Math 2.0

Computer science Automata and formal languages Lemma

Pumping lemma for context-free languages

Builds on Context-free languageContext-free grammarChomsky normal formPumping lemma for regular languages

Statement

Let L⊆Σ∗L \subseteq \Sigma^* be a context-free language. Then there is an integer p≥1p \ge 1 such that every w∈Lw \in L with ∣w∣≥p\abs{w} \ge p can be written as w=uvxyzw = uvxyz with u,v,x,y,z∈Σ∗u, v, x, y, z \in \Sigma^* such that:

  1. ∣vxy∣≤p\abs{vxy} \le p;
  2. ∣vy∣≥1\abs{vy} \ge 1;
  3. uvixyiz∈Lu v^i x y^i z \in L for every integer i≥0i \ge 0.

Here ∣w∣\abs{w} is the length of ww and viv^i is vv repeated ii times.

Remarks

Take a context-free grammar for LL in Chomsky normal form with kk nonterminals and set p=2kp = 2^k. A parse tree of a word of length at least pp is binary, so it has a root-to-leaf path with more than kk nonterminals. So some nonterminal AA repeats on the lowest part of this path. The subtree under the upper AA yields vxyvxy, the one under the lower AA yields xx, and replacing one subtree by the other, or the reverse, repeatedly gives uvixyizu v^i x y^i z. Example: L={anbncn:n≥0}L = \set{a^n b^n c^n : n \ge 0} is not context-free. For w=apbpcpw = a^p b^p c^p, the part vxyvxy has length at most pp, so it meets at most two of the three blocks. Then uv2xy2zu v^2 x y^2 z either has letters out of order or has unequal block lengths, so it is not in LL. The lemma gives only a necessary condition: some languages that are not context-free satisfy its conclusion.

Going deeper

For a student

The lemma is the context-free analogue of the pumping lemma for regular languages, where one piece is pumped instead of two. A typical proof that LL is not context-free picks a word depending on pp, considers every split allowed by clauses 1 and 2, and finds an ii with uvixyiz∉Lu v^i x y^i z \notin L. Since the context-free languages are closed under intersection with regular languages and under homomorphisms, one often first simplifies LL in this way. When the lemma is too weak, Ogden's lemma, which lets one mark the important positions, often works.

Reading path

To understand this page from the ground up, read these 8 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Chomsky normal form concept
  2. Context-free grammar concept
  3. Context-free language concept
  4. Deterministic finite automaton concept
  5. Regular language concept
  6. String concept
  7. Pumping lemma for regular languages statement
  8. Pumping lemma for context-free languages statement

Where this leads

1 page builds on this one.

Further reading

  1. Web https://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_languages
About this page
TagKQ0TQABTPJ
URIm2://KQ0TQABTPJ
Kindstatement, lemma
WritingW0 stub
MSC68Q45, 68Q42
StatusThis copy of the site has no build data. Run m2 status KQ0TQABTPJ.
AboutContext-free language
UsesContext-free language, Context-free grammar, Chomsky normal form, Pumping lemma for regular languages
Same as
Changed3 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

Used by