On this page
You can draw an automaton for strings with an even number of 1s in a minute. Try one for some 0s followed by as many 1s and you run out of states. The pumping lemma explains why.
What does the pumping lemma for regular languages say?
A language is regular if some finite automaton (a DFA) accepts exactly its strings. The pumping lemma, as stated in Wikipedia's article on it, says: if L is regular, there is a number p ≥ 1, the pumping length, such that every string w in L of length at least p can be written as w = xyz where:
y is not empty, so |y| ≥ 1;
the first two pieces are short, so |xy| ≤ p;
xyⁱz is in L for every i ≥ 0.
Pumping means repeating y: i = 0 deletes it, i = 2 doubles it. Michael Rabin and Dana Scott first proved the lemma in their 1959 paper Finite Automata and Their Decision Problems; Bar-Hillel, Perles and Shamir rediscovered it in 1961.
Why does every long string have a repeatable middle part?
It is the pigeonhole principle applied to states. Take a DFA for L with p states and feed it a string of length at least p. Reading the first p symbols, the machine passes through p + 1 states, counting the start state. Only p are different, so some state qₛ appears twice. Cut the string there: x is read before the first visit to qₛ, y between the two visits (a loop from qₛ back to qₛ), and z after.
Going round the loop zero times or a hundred times ends in the same state, so if xyz is accepted, so is every xyⁱz. Both visits fall within the first p symbols, giving |xy| ≤ p, and y moves at least one step, giving |y| ≥ 1. That is the whole proof.
How do you prove that {0ⁿ1ⁿ} is not regular?
Let L = {0ⁿ1ⁿ : n ≥ 0}, the strings made of some 0s followed by exactly as many 1s. We argue by contradiction, the same move as in our post on proof by contradiction with √2 and the primes.
Suppose L is regular. Then it has some pumping length p. You do not know p, so the proof must work for every p.
Choose w = 0ᵖ1ᵖ. It is in L, and its length 2p is at least p.
The lemma says w = xyz with |xy| ≤ p and |y| ≥ 1. The first p symbols of w are all 0s, so x and y contain only 0s. Write y = 0ᵏ with k ≥ 1.
Pump down with i = 0: xz = 0ᵖ⁻ᵏ1ᵖ has fewer 0s than 1s, so it is not in L.
That contradicts the lemma, so L is not regular.
A concrete check with p = 4: w = 00001111. Every legal y sits inside 0000, so deleting it leaves something like 001111, with unequal counts. The same idea shows balanced brackets are not regular, which is why a textbook regular expression cannot check that brackets are properly nested.
What is the most common mistake when using the pumping lemma?
Choosing the split yourself. The lemma promises that some split xyz exists; it does not let you pick it. Writing let y = 01 for 0ᵖ1ᵖ proves nothing, because the lemma might hand back y = 0. Treat the proof as a game:
the opponent picks p;
you pick a string w in L with |w| ≥ p;
the opponent picks any legal split xyz;
you pick an i that pushes xyⁱz out of L.
You win only if your move beats every opponent move. Choosing 0ᵖ1ᵖ helps because |xy| ≤ p traps y inside the 0s, leaving one case.
The second mistake is using the lemma to show a language is regular. The converse is false. The Wikipedia article gives {aⁱbʲcᵏ : i = 0 or j = k}, which passes the pumping test yet is not regular, as the Myhill–Nerode theorem shows. To prove a language is regular, build a DFA or write a regular expression for it.
How should you practise pumping lemma proofs?
Work through three languages in order: {0ⁿ1ⁿ}; {ww : w a string of 0s and 1s}, using 0ᵖ10ᵖ1; and strings of 0s whose length is a perfect square. Write the four moves of the game for each before any prose.
If the automaton side feels shaky, the Fermi Concept Library covers mathematics and computing concepts, each with its own lesson, so you can revisit DFAs and the pigeonhole principle first.
The pumping lemma is one of several results saying a machine cannot do something. For a far more powerful machine with its own limit, read why the halting problem is undecidable.



