You are on page 1of 2

Pumping lemma for regular languages Pumping lemma for regular languages

In what follows, we demonstrate that {0n 1n : n > 0} and similar Proof. Given any regular L, choose a DFA D = (Q, Σ, δ, s, F ) such
languages cannot be recognized by FAs. that L = L(D) and let k = |Q|.
The intuitive reason for this is that an FA may store information For a word w = w1 · · · wn ∈ L where the wi are in Σ, let q1 , . . . , qn
about the already read prefix of its input only by its state, hence be the sequence of states that occur during the processing of the
will not be able to distinguish such prefixes appropriately. input w , i.e., q0 = s and δ(s, w1 · · · wi ) = qi for i = 1, . . . , n.
This idea is made formal in the following pumping lemma.
w1 w2 w3 wn
Theorem (Pumping lemma for regular languages) q0 q1 q2 ··· qn

For every regular language L there is a constant k such that every


In case n ≥ k = |Q|, by the pigeonhole principle there are indices j
word w ∈ L of length at least k can be written in the form
and j 0 where 0 ≤ j < j 0 ≤ k and qj = qj 0 . Let
w = xyz
x = w1 · · · wj , y = wj+1 · · · wj 0 , and z = wj 0 +1 · · · wn .
such that the words x, y , and z have the following properties
(i) y 6= λ, Assertions (i) and (ii) in the theorem hold by j < j 0 ≤ k.
(ii) |xy | ≤ k, Assertion (iii) holds because for all i ≥ 0, the processing of the
(iii) xy i z ∈ L for all i ≥ 0. suffix z of the word xy i z will start in state qj , hence will always
end with the same accepting state as for w . t
u

Pumping lemma for regular languages Pumping lemma for regular languages

Example 1 (Blocks of zeroes and ones of equal size) Example 2 (Equal number of zeroes and ones)
The language L1 = {0n 1n : n > 0} is not regular. The language L2 = {w ∈ {0, 1}∗ : #0 (w ) = #1 (w )} of all words
For a proof by contradiction, assume that L1 is regular and that contain as many zeroes as ones is not regular.
accordingly choose a constant k as in the pumping lemma. For a proof by contradiction, it suffices to observe that in case the
Then the word w = 0k 1k has a partition w = xyz as in the language L2 were regular, then the language
pumping lemma.
L1 = L2 ∩ {0m 1n : m, n}
Because of y 6= λ and |xy | ≤ k, it holds that y = 0` for
some ` > 0. were the intersection of two regular languages and hence itself
By the pumping lemma, then also regular, contradicting Example 1.
Alternatively, the nonregularity of L2 can be demonstrated by using
xy 0 z = xz = 0k−` 1k ∈ L1 the pumping lemma in an argument that is almost literally the
same as the one in Example 1.
contradicting the definition of L1 .
Pumping lemma for regular languages Pumping lemma for regular languages
Example 3 (Words of prime length)
Proposition (The pumping lemma and nonregular languages)
The language L3 = {w ∈ {1}∗ : |w | is prime} of all words of prime
length over the unary alphabet is not regular. There is a nonregular language for which the conclusion of the
pumping lemma is true.
For a proof by contradiction, assume that L3 is regular and
accordingly choose a constant k as in the pumping lemma and a Proof. Let L0 be any language over the alphabet {0, 1} and
prime number p ≥ k + 2. consider the language
Let w = xyz be a partition of w = 1p as in the pumping lemma. L = {0, 1}∗ ∪ {#k u : k ≥ 0 and u ∈ L0 } ⊆ {0, 1, #}∗ .
For m = |y |, it holds that 1 ≤ m ≤ |xy | ≤ k ≤ p − 2 (∗).
Then the conclusion of the pumping lemma holds with k = 1 for
By the pumping lemma, the word xy p−m z is in L3 , however its the language L because for every word w in L, if we write w = az
length cannot be prime because of for some symbol a ∈ {0, 1, #}, we have
|xy p−m z| = |xz| + |y | (p − m) = (m + 1) (p − m), ai z ∈ L for all i ≥ 0.
|{z} |{z} | {z } | {z }
|w |−|y |=p−m =m ≥2 by (∗) ≥2 by (∗)

which contradicts the definition of L3 . t


u

Pumping lemma for regular languages

Proof, cont.: We conclude the proof by showing that if L0 is


chosen to be nonregular, then L is nonregular, too.
For a proof by contraposition, assume that L is regular and choose
some DFA

D = (Q, {0, 1, #}, δ, s, F ) where L = L(D).

Then L0 is regular because D can be transformed into a DFA that


recognizes L0 by
changing the initial state s into δ(s, #), and
cancelling all transitions that correspond to the symbol #. t
u

You might also like