Skip to main content

Pumping Lemma of Regular Languages

The pumping lemma for regular languages is a lemma that describes an essential property of all regular languages. Informally, it says that all sufficiently long strings in a regular language may be pumped—that is, have a middle section of the string repeated an arbitrary number of times—to produce a new string that is also part of the language.

tip

Please remember that we only talk about infinite languages.

Pumping Lemma of Regular Languages and Its Proof​

Pumping Lemma states that, if L\mathcal{L} is an infinite regular language, there must exists a pumping length p≥1p \geq 1 (pp is only dependent on the language).

If an integer pp is a pumping length. For any w∈Lw \in \mathcal{L} and ∣w∣≥p|w| \geq p, there must exists a way of dividing ww into,

w=xyzw = xyz

Where, ∣y∣≥1|y| \geq 1 and ∣xy∣≤p|xy| \leq p.

And ∀n≥0\forall n \geq 0, xynz∈Lxy^nz \in \mathcal{L}.

This can be proven with regular expression- and is very simple.

Because L\mathcal{L} is infinite, there must exist at least one star, that is,

R=r1r2∗r3R = r_1r_2^*r_3

Where r2r_2 is not empty.

Thus, if xx matches r1r_1, zz matches r3r_3, yy matches r2r_2, we will have the pumping lemma.

Example​

We usually use pumping lemma to prove a language is not regular.

For example, we would like to prove,

0n1n0^n1^n

Is not a regular language.

We assume there exists a pumping length pp, and assume that this is a regular language.

Pumping lemma tells us that for every string longer than pumping length, there must exists a pumping decomposition. We can take,

w=0p1pw = 0^p1^p

We know that a pumping decomposition exists, but we don't know exactly how- it's okay, we can assume,

w=xyzw = xyz

No matter how ww decomposes, there are only there cases for yy.

  • yy contains only 11, then obviously, xy2z∉Lxy^2z \not \in \mathcal{L}, because there will be more 11 than 00.
  • yy contains only 00, then obviously, xy2z∉Lxy^2z \not \in \mathcal{L}, because there will be more 00 than 11.
  • yy contains 00 and 11, then y=0a1by = 0^{a}1^{b}, then xy2z=0n1b0a1n∉Lxy^2z=0^{n}1^b0^a1^{n} \not \in \mathcal{L}

Thus, there doesn't exists such a decomposition.

In conclusion, 0n1n0^n1^n is not a regular language.