Later in this lecture we are going to prove that the following example language can not possibly be decided by a finite automaton:
L = { x | x contains an equal number of 0s and 1s }
If A is a regular language, then there is a number p where if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions:
The pumping lemma essentially says
If A is a regular language then all long strings in A can be pumped
Like almost all theorems, the pumping lemma takes the logical form
If this then that
In logic, a logical statement in that general form is logically equivalent to that statement's contrapositive:
If not that then not this
This is the form of the pumping lemma that is most useful to us:
If not all long strings in A can be pumped, then A is not a regular language
To use the contrapositive form of the pumping lemma successfully we have to carry out the following steps:
Consider the language
L = { x | x contains an equal number of 0s and 1s }
Our counterexample string s = 0p1p.
s is clearly in L and has length greater than p.
Consider what happens when we decompose s into substrings x, y, and z while obeying the constraints that |y| ≥ 0 and |xy| ≤ p. The second constraint forces y to consist only of 0s.
Now pick i = 2 and consider the string xy2z. This string contains more 0s than s did, while keeping the same number of 1s. This string has an unequal number of 0s and 1s, and is not in L.
Consider the language
L = { ww | w ∈ Σ* }
Our counterexample string s = 0p10p1.
s is clearly in L and has length greater than p.
Consider what happens when we decompose s into substrings x, y, and z while obeying the constraints that |y| ≥ 0 and |xy| ≤ p. The second constraint forces y to consist only of 0s.
Now pick i = 2 and consider the string xy2z. This string essentially takes the form 0p+k10p1, where k = |y|. There is no way to decompose this string into two equal substrings. Hence, the pumped string is not in L.