Hello. In the previous lesson, you constructed product DFAs to show that regular languages remain regular under Boolean combinations. This lesson takes the complementary direction: how to prove that a language cannot be recognized by any DFA.
The pumping lemma formalizes a limitation of finite automata. A DFA has only finitely many states, so while reading a sufficiently long input, it must revisit some state. The segment read between those visits is a loop: it can be repeated or removed without changing the machine’s eventual acceptance. We will turn that necessary property of regular languages into contradiction proofs.
The pumping lemma: a necessary condition
Let be a regular language. Then there is an integer , called a pumping length, such that every string with can be written as
where:
and
for every integer .
The notation means copies of . In particular:
The three conditions have distinct roles:
| Condition | What it guarantees |
|---|---|
| $ | xy |
| $ | y |
| for all | Removing, repeating, or multiplying the loop must preserve membership in . |
Why should this be true for a DFA? Suppose a DFA has states and reads the first characters of a long accepted string. Including its starting position, the machine occupies state positions. Since only states are available, two of those positions must have the same state. The input portion read between those two visits is a nonempty loop. Call the input before the loop , the loop , and the rest of the input . Traversing the loop zero, one, two, or any number of times leaves the machine in the same state before it continues through .
The lemma does not say that you may select a convenient decomposition yourself. It says that, if the language is regular, some suitable decomposition must exist for every sufficiently long string.
Pumping Lemma for Regular Languages Example: 0ⁿ1ⁿ
Watch “Pumping Lemma for Regular Languages Example: 0ⁿ1ⁿ” from Easy Theory for a complete visual walkthrough of the standard proof.
Watch the setup to see the regularity assumption and the choice of a string based on the unknown pumping length. Then watch the decomposition constraints, focusing on why the first two pieces must lie in the initial block of zeros. Finish with the contradiction, where one pumped copy changes the number of zeros while leaving the number of ones fixed.
The quantifier order: who gets to choose what?
Most pumping-lemma errors are logical rather than algebraic. The lemma has this structure:
To disprove regularity, your proof must defeat this claim in the correct order. The most useful way to remember the order is as a game:
- Assume is regular. The opponent supplies a pumping length .
- You choose a string whose length is at least .
- The opponent chooses a decomposition , subject to and .
- You choose a value for which .
Your argument succeeds only if it works for every legal decomposition chosen in step 3. The value of may depend on the decomposition, although in clean proofs a single choice such as or often handles all cases.
A compact statement of the proof target is:
This makes the strategic purpose of choosing clear: choose it so that the bound forces into a region where pumping breaks an essential feature of the language.
proving languages not regular using Pumping Lemma
Read Nick Cheng’s concise notes to reinforce the formal statement and see the standard proof organized as a contradiction argument.
On page 1, in the introductory discussion before “A (relatively) easy example,” read the statement and strategy. The notes use n for the pumping length and u,v,w for the decomposition; these play the same roles as p and x,y,z here. Then read the “A (relatively) easy example” through page 2, stopping immediately before “A harder example.” In the proof, follow the decisive pumping step, and notice how the proof handles every possible nonempty choice of the pumpable block.
A complete proof: equal numbers of zeros and ones
Consider the language
Its strings consist of some number of zeros followed by exactly the same number of ones:
We will prove that is not regular.
Proof
Assume, for contradiction, that is regular. Let be the pumping length supplied by the pumping lemma.
Choose
This is a valid choice because
and
Now let
be any decomposition satisfying
and
The first symbols of are all zeros. Since is a prefix of of length at most , both and consist only of zeros. Therefore there are integers and such that
The remaining suffix is
Now choose . The pumping lemma would require . But
Because , the number of zeros is , which differs from the number of ones. Hence
This contradicts the pumping lemma’s requirement that for every . Therefore the original assumption was false:
What made the proof work?
The proof has a deliberate design.
First, depends on the unknown pumping length . Choosing a fixed string such as would be invalid, because its length might be smaller than .
Second, the first block has length exactly . This combines with
to trap all of inside the zeros. We never need to know the exact length of ; we only need to know that it is a positive number of zeros.
Finally, pumping down with changes one count but not the other. The defining invariant of the language, equal counts in the prescribed order, is destroyed.
This pattern generalizes:
Choose a long string with a protected region of length at least . Use the prefix bound to force into that region. Then pump in a way that violates the language’s defining condition.
For instance, the same proof idea immediately shows that
is nonregular: choose , force to contain only 's, and pump down.
A reusable proof template
For many languages, a polished pumping-lemma proof can follow this structure.
-
State the assumption.
“Assume for contradiction that is regular.” -
Introduce the pumping length.
“Let be the pumping length guaranteed by the pumping lemma.” -
Choose a strategic string.
Define as a function of . Verify both:and
-
Keep the decomposition arbitrary.
“Let , where and .” -
Use the constraints.
Derive what must look like. This is usually the proof’s central observation. -
Choose a pumping exponent.
Choose , , or another nonnegative integer that makes the pumped string fail the language definition. -
Identify the contradiction precisely.
State whycontradicts the lemma’s claim that the string must be in for every .
-
Conclude nonregularity.
“Therefore is not regular.”
A proof becomes rigorous not by displaying many sample decompositions, but by taking an arbitrary legal decomposition and deriving a contradiction from the length constraints.
Common invalid arguments
Choosing the pumping length yourself
You cannot write, “Let ,” and find a string that does not pump. If were regular, it might have a different pumping length. Your proof must begin with an arbitrary pumping length supplied under the regularity assumption.
Choosing the pumpable substring yourself
Writing
does not prove nonregularity. It only shows that one particular decomposition fails. The pumping lemma promises that some legal decomposition works, so you must defeat all legal decompositions.
Forgetting the prefix bound
The condition is not merely that is nonempty. You must use
to constrain where occurs. In the proof, this is exactly what prevents from containing ones.
Pumping without checking the language definition
After choosing , explicitly explain why the resulting string is outside the language. “The result looks wrong” is not a proof. For , the exact failure is that the two block lengths differ.
Trying to prove regularity with the pumping lemma
The pumping lemma is one-way:
It is useful when you can show a language fails the pumping condition. But a language’s apparent ability to pump does not establish that it is regular; to prove regularity, construct a DFA, NFA, regular expression, or use an appropriate closure argument.
Key takeaways
The pumping lemma captures the fact that every sufficiently long string accepted by a finite automaton contains a loop that can be repeated any number of times. To prove a language nonregular with it, assume regularity, let be the resulting pumping length, and choose a string whose structure forces every possible pumpable segment into a vulnerable region.
The logical order is essential: you choose after seeing , but the decomposition is adversarial. A valid proof establishes that every legal decomposition can be pumped to yield a string outside the language.
Next, you will prove nonregularity by a different method: combining closure properties of regular languages with a known nonregular language.
Can't find a good explanation? Sign up and we'll make it for you
Sign up