Introduction
The pumping lemma for regular languages is a necessary condition that every regular language satisfies. Its main use is negative: if you can show that a language breaks the condition, the language is not regular. It is not a sufficient test; some non-regular languages still satisfy the numeric conclusion for tricky reasons, so failing to pump does not prove regularity.
The skills are the classic non-regular proofs (, , ) and the correct quantifier order in the lemma statement.
Prerequisites
- Closure and Decision Properties of Regular Languages: regular languages via DFAs; when to prefer Myhill-Nerode instead.
Core concepts
Statement
If is regular, then there exists a pumping length such that every with can be written with:
- ,
- ,
- for every integer .
Intuition. In a DFA with states, a path of length repeats a state inside the first states visited; the loop is .
Quantifiers (memorize the order)
- (depends on only),
- with ,
- split obeying (1)-(2),
- , .
To show non-regularity, negate: , with , splits with (1)-(2), with .
What the lemma does not do
- It does not prove regularity.
- A language may be non-regular yet hard to pump; use Myhill-Nerode or closure arguments instead.
- Mis-pumping outside the first symbols is a common wrong proof.

How it works
Template proof that is not regular
- Assume is regular; let be the pumping length.
- Choose a specific with (clever choice).
- Consider an arbitrary split with and .
- Show some pumped string (often or ) leaves .
- Contradiction; is not regular.
Choosing
For , take . Then lies inside the leading 's (because ), so pumping changes the number of 's only.
Algorithms and pseudocode
There is no "algorithm" inside the lemma; DFA cycle detection explains why it holds:
Input strings use 1-based positions; run-state visits use indices 0 through |w|.
WHY-PUMPING(M, w) // |w| >= |Q|, w accepted
1 run M on w, record states s0,s1,...,s_|w|
2 among s0..s_p find i < j with si = sj // p=|Q|
3 x <- w[1..i]; y <- w[i+1..j]; z <- w[j+1..|w|]
4 return (x,y,z) // pumping the loop yMathematical explanation
Proof of the lemma
Let be a DFA for with . Take , . The run visits states in the first symbols plus the start, so by pigeonhole two visits occur with . Set to the substring between them. The loop can be taken times, staying accepting because the original run ended accepting and the loop returns to the same state.
Myhill-Nerode alternative
For , the prefixes are pairwise distinguishable by the continuations . Infinitely many classes not regular.
Worked examples
Example 1:
Assume regular, pumping length . Let . For any with , for some . Then . Done.
Example 2:
Take . Because , the piece () lies in the first block of 0s. Then : its two halves cannot be equal, since the only way to split it into equal halves of a string with exactly two 1s puts one 1 at the end of each half, which forces equal 0-blocks. So . The choice of matters: is in but pumps happily (pumping by an even stays in , and for the adversary may pick ; an assumed pumping length can always be enlarged to at least 2), so it proves nothing.
Example 3:
Take . Pumping adds letters with , producing a length strictly between consecutive squares and , hence not a square.
Example 4: a regular language that pumps
is regular. For , any () splits as , , ; pumping stays in . Satisfying the lemma does not by itself prove regularity (but here we already know it is regular via a 1-state DFA).
Example 5: choosing
. Take . Every legal is with . Pumping up keeps , so it fails to leave ; pumping down () gives with , so and the string is outside . Stopping after would wrongly suggest that the language pumps.
Example 6: primes
. Take a prime and , with , . Pump with : the length is . Both factors are at least 2 ( because ), so the length is composite and .
Example 7: languages that look non-regular but are regular
| Language | Regular? | Reason |
|---|---|---|
| yes | it is | |
| yes | finite | |
| yes | ; the exponents are independent | |
| yes | the counts of the factors ab and ba differ by at most 1, and they are equal iff is empty or starts and ends with the same symbol | |
| yes | 3 residues of | |
| yes | again | |
| no | pumps to | |
| no | closure: complement within is |
IMPERATIVE RULE. Before pumping, ask whether the "counting" is really unbounded and coupled. Precisely bounded counts and fixed modular conditions often yield finite-state constructions. A unary alphabet alone is no guarantee: a unary language is regular exactly when its set of lengths is ultimately periodic.
Example 8: minimum pumping length
The minimum pumping length of a regular is the smallest for which the lemma's conclusion holds. For it is 4: the string 000 (length 3) cannot be pumped, because removing or repeating any nonempty piece of it leaves ; with , every () pumps with = the first 1. For it is 2: with the string 01 would need , and 1 ; with , take . For a finite language, any larger than its longest string works vacuously, so a finite language never needs to pump.
Example 9: a non-regular language that satisfies the lemma
. With , every nonempty pumps with = its first symbol: if , changing the number of s keeps or produces , both in ; if , the string is and changing its first block keeps . Yet is not regular: , and the left quotient by gives , which is not regular. So passing the lemma proves nothing.
Example 10: misuse
Wrong: "take and set ". That split may violate or place across the boundary; the adversary chooses the split, so your proof must handle every legal split.
Important properties and observations
- Pumping length can be taken as the number of DFA states.
- deletes (useful often); duplicates .
- Closure arguments often beat pumping: proves non-regularity in one line (see Closure and Decision Properties of Regular Languages).
- The lemma gives a necessary condition only. A language that satisfies it may still be non-regular (Example 9).
Common misconceptions.
- Using pumping to "prove" regularity.
- Picking one convenient split instead of arguing against all splits.
- Forgetting , which would make pumping trivial.
GATE examination perspective
- WRITE QUANTIFIERS. Questions can test the quantifier order : know which choices are yours and which are the adversary's.
- FORCE INTO ONE BLOCK. Choose so that the first symbols are a single letter run.
- PREFER MYHILL-NERODE. When prefixes are obviously distinguishable.
- DO NOT PUMP NON-REGULAR CANDIDATES BLINDLY. Without checking the split constraints.
- TRY BOTH DIRECTIONS. If pumping up stays in , try (Example 5).
- "WHICH OF THESE IS REGULAR". Check for bounded counts, moduli and hidden independence (Example 7) before declaring a language non-regular.
- THE LEMMA IS ONE-WAY. " satisfies the pumping lemma, hence regular" is always a wrong option.
- MINIMUM PUMPING LENGTH. The least positive integer such that every with has a split satisfying , , and for every integer . Prefix legality depends on the same candidate ; the length of the longest unpumpable word alone is not a general rule.
Summary
Sources
- J. E. Hopcroft, R. Motwani, J. D. Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Pearson Addison-Wesley: Section 4.1 (proving languages not to be regular: the pumping lemma and its applications).
- M. Sipser, Introduction to the Theory of Computation, 3rd ed., Cengage Learning: Section 1.4 (nonregular languages; the pumping lemma for regular languages).
- P. Linz, An Introduction to Formal Languages and Automata, 6th ed., Jones & Bartlett Learning: Section 4.3 (identifying nonregular languages: using the pigeonhole principle, a pumping lemma).