The Timpson Lyceum · Computation Theory
Lecture 11 (Computation Theory) Pumping Lemma, Non-Context-Free Languages, and Review
Overview
This lecture develops the pumping lemma for context-free languages (CFLs) and shows how to use it to prove that a given language is not context-free. It is the CFL analogue of the pumping lemma for regular languages, but the string is divided into five pieces instead of three, and two of those pieces get pumped together. The technique is a proof by contradiction: assume the language is context-free, invoke the pumping property, and then exhibit a string and a pumped variant that escapes the language. We work three representative proofs — , the ordered language with , and the copy language — to build fluency with the method, especially the crucial step of choosing the right string.
Key Concepts
-
Pumping lemma for CFLs (the property). If is a context-free language, then there exists a number (the pumping length) such that every string with can be written as satisfying all three conditions:
- — the pumped pieces and are not both empty (otherwise pumping changes nothing);
- — the pumped region together with its middle is short;
- for every , — you can pump and up (or down to ) and stay in the language.
-
Five pieces, two pumped. Unlike the regular pumping lemma (which splits and pumps the single middle ), the CFL version splits into and pumps and simultaneously and equally. This reflects how a context-free derivation can repeat a variable that generates matter on two sides of a center.
-
One-directional implication. The lemma says context-free pumping property. It does not say the converse. We use the contrapositive: not the pumping property not context-free. So the lemma is a tool for proving non-membership in the CFL class, not for proving a language is a CFL.
-
Negation of the pumping property (what you must establish to win). For every , there exists a string with such that for every decomposition with and , there exists some with . The quantifier flip is the whole game: you do not get to pick (it is handed to you), but you do get to pick the string , and you must defeat every legal split.
-
Strategy for the proofs. Assume is context-free and let be its pumping length. Choose a clever (this is the hardest, most creative step). Use to limit how far can stretch — typically it can span at most two of the distinct symbol blocks. Then pump (usually to add letters, or to remove them) and argue every case lands outside , contradicting condition 3.
-
The constraint is the lever. Because the window has length at most , when a string is built from long blocks of distinct symbols (, etc.), the window cannot touch all three blocks at once. That forces the pumping to unbalance the counts.
Worked Example
Claim. is not context-free.
Setup (contradiction). Assume is context-free; let be its pumping length. Choose the string
which is in and has length . By the pumping lemma, with and .
Key restriction. Since , the substring cannot stretch across all three blocks — it lies within the 's, within the 's, within the 's, or straddles only one boundary ( or ). Hence contains at most two of the three letters, and (by ) at least one. Pump up with :
For instance, if contains only 's and/or 's, pumping increases the count of 's and/or 's while the count stays at , so or ; symmetrically if contains 's and/or 's.
Contradiction. Every case yields , contradicting condition 3, which demanded it stay in . Therefore is not context-free.
Second example (sketch): the copy language . Choose (a convenient ). With , the window lies entirely in the first half, entirely in the second half, or straddles the center boundary. In each case pumping to lengthens one half differently from the other (or breaks the pattern), so the two halves no longer match and — contradiction. The same recipe handles with : pump up to over-supply 's or 's, or pump down () to under-supply 's or 's, violating an inequality.
Summary
- The CFL pumping lemma splits a long string as with , , and for all — pumping two substrings ( and ) together.
- It states context-free pumping property; its real use is the contrapositive, to prove a language is not context-free.
- A non-context-free proof is by contradiction: assume context-free, accept the given , choose a clever string , then show every valid split has some pump that leaves .
- The constraint confines the pumped window to at most two distinct symbol blocks — that is what forces the symbol counts out of balance.
- Pump up () to add letters and over-count; pump down () to delete letters and under-count, whichever breaks the language's defining condition.
- Canonical non-context-free witnesses include , , and .