This is an old revision of the document!


8. Proving languages are not regular

Pumping Lemma

Let L be an infinite regular language. Then, for $\forall w \in L$, $\exists n \in \mathbf{N}$, $ |w| \ge n $, $ w = xyz $, $ |xy| \le n $ and $ y \neq \varepsilon $, such that $ \forall k \ge 0, w_{k} = xy^{k}z \in L$.

Complement of Pumping Lemma

Let L be an infinite language. If $\forall n \in \mathbf{N}$, $\exists w_{n} \in L $ with $ |w| \ge n $ such that regardless of how $ w_{n} $ is split into $ w_{n} = xyz $ with $ |xy| \le n $ and $ y \neq \varepsilon $, $\exists k \ge 0 $ such that $ w_{n} = xy^{k}z \notin L $, then L in not a regular language.

8.1.1. Show that the pumping lemma holds for finite languages.

Solution

Solution

Let L be a finite language.

Pick $ n \gt max_{w \in L} |w| $ ⇒ $ \nexists w \in L $ with $ |w| \ge n $ ⇒ Pumping Lemma holds

8.1.2.* Find a language which is not regular for which the pumping lemma holds.

Show that each of the languages from the list below is not regular.

8.2.1. $ L = \{ \: A^n B^m \: | \: 0 \leq n \leq m \: \} $

Solution

Solution

For a fixed n, pick a word $ w_n \in L $ and $ w_n = xyz $:

$ w_n = A^nB^{n+1}

$ x = A^a $

$ y = A^b, b \ge 1 $

$ z = A^{n-b-a}B^{n-1} $

Find k such that $ xy^kz \notin L $:

$ w_k = A^{a+b*k+n-b-a}B^{n+1} = A^{n+(k-1)b}B^{n+1} $

Pick k = 3 ⇒ $ w_3 = A^{n+2b}B^{n+1} \notin L $ because $ b \ge 1 $

8.2.2. $ L = \{ \: w \in \{A,B\}^* \: | \: \#A(w) = \#B(w) \: \} $

8.2.3. $ L = \{(01)^n(10)^n \mid n > 0 \} $

8.2.4. $ L = \{ \: w \in \{A,B\}^* \: | \: \text{w is a palindrome} \: \} $

8.2.5. $ L = \{ \: w \in \{0\}^* \: | \: \text{the length of w is a prime number} \: \} $

8.2.6. $ L = \{ \: w \in \{0\}^* \: | \: \text{the length of w is a power of two} \: \} $

8.2.7. $ L = \{ \: ww^R \: | \: w\in \{0,1\}^* \} $

8.3.1. Using the pumping lemma, prove that $ L = \{ \: A^nB^m \: | \: n \neq m \}$ is not a regular language.

Solution

Solution

Assume that L is a regular language.

⇒ $ L(A^*B^*) \backslash L = \{ \: A^nB^n \: | \: n \in \mathbf{N} \} $ is a regular language because set difference is a closure property.

But we have previously proved that $ \{ \: A^nB^n \: | \: n \in \mathbf{N} \} $ is not regular.

⇒ Our assumtion was wrong ⇒ L is not a regular language.