Theory of Computation · Week 1 · Lesson 0006 of 7
Regularity and the limits of finite memory
An unbounded count can sometimes reduce to a small amount of information.
First look for bounded information or cancellation. When the input requires unbounded distinctions, give a pumping argument.
1Warm-up
2Count occurrences with overlapping windows
An occurrence of a substring is a starting position at which the substring appears. Occurrences can overlap. The string 0000 has two occurrences of 000, starting at positions 1 and 2. Write #v(w) for the number of occurrences of v in w.
For binary words, define I(x)=1 if the pair x is 11 and I(x)=0 for any other pair. In a triple abc, subtract the value of the right pair from the left pair. For 110 this difference is +1, for 011 it is −1, and for every other triple it is zero. In particular, 111 has two equal pair values.
A telescoping sum cancels its consecutive interior terms. Here each interior pair occurs once on the right and once on the left. Thus for |w| ≥ 2, #110(w) − #011(w) = I(first pair) − I(last pair). With fewer than two symbols there are no triples and the difference is zero.
In 00111, the first pair is 00 and the last is 11, so the difference is −1 and the word fails #110 ≥ #011. Directly, 001, 011, 111 give 0−1+0 = −1. In 1100, the first pair is 11 and the last is 00, so the difference is +1.
The language L₁ defined by #110 ≥ #011 is regular. A DFA can store the first two bits once they arrive and always store the latest two bits, with separate initial information for prefixes of length zero or one. It rejects exactly when the first pair differs from 11 and the last pair equals 11. This uses finitely many states.
Two substring counts can grow without bound even when their difference depends only on the ends. Check for cancellation before deciding how much the machine must remember.
Sipser, Introduction to the Theory of Computation, §1.1 and §1.4.
3Turn a repeated state into a contradiction
A pumping length p for a regular language is a bound that guarantees a repeatable part near the start of any accepted word of length at least p. With p states, the first p symbols visit p+1 states including the start, so two visits reach the same state.
The pumping lemma says that if L is regular, some p ≥ 1 works as follows. Each w ∈ L with |w| ≥ p has a split w=xyz with |xy| ≤ p and |y| ≥ 1, such that xyiz ∈ L for every integer i ≥ 0. The part y follows a loop, which can be skipped or repeated without changing the state at which z begins.
To prove that the language L₂ defined by #000 ≥ #111 is nonregular, suppose it has pumping length p. Choose w = 0p+21p+2. Each block has p overlapping triples of its own symbol, and no triple crossing the boundary is all zeros or all ones. Thus w belongs to the language.
For every allowed split, y consists of d zeros with 1 ≤ d ≤ p because the first p symbols are zeros. Pump down with i=0. The zero block now has p+2−d symbols, at least two, and therefore p−d occurrences of 000. The one block still has p occurrences of 111. The new word fails the inequality. This contradicts the lemma for every allowed split.
As a second example, take the language {0n1n | n ≥ 0}. With a proposed pumping length p, use 0p1p. Every allowed y consists of at least one zero. Pumping down leaves fewer zeros than ones, so the result is outside the language. This proves nonregularity.
The pumping lemma gives a necessary property of regular languages. To prove a language is regular, construct a DFA, NFA, or regular expression, or start with regular languages and use a closure property.
4Recap
- Count all starting positions, including overlaps.
- For 110 and 011, adjacent pair contributions cancel.
- A pumping contradiction must handle every eligible split of the chosen word.
5Check yourself
6Cheat card
- Overlaps
- Count every valid start. A run of length m contains max(m−2,0) copies of its triple.
- Boundary test
- For words of length at least two, #₁₁₀ − #₀₁₁ = I(first pair) − I(last pair), where I tests for 11.
- Disprove regularity
- Choose w using p, handle every valid split, and find a repeat count that leaves the language.
- Memory hook
- If the middle cancels, store the ends. If a forced loop breaks the rule, pump it.