Examples of nonregular languages

We’ll use the pumping theorem to prove that the following languages are not regular:

  • The language Lab=anbnL_{ab}=a^nb^n.
  • The language of palindromes.
  • The language of repeated halves, {ww    w(a+b)}\{ww \;|\; w \in (a+b)^*\}.
  • The language over Σ={(,)}\Sigma=\{(,)\} of balanced parentheses.
  • The language {ambn    m>n}\{a^mb^n \;|\; m > n\}.
  • The language PRIME = {an}\{a^n\}, where nn is a prime number.
  • The language {an2    n>0}\{a^{n^2} \;|\; n>0\}.

The language LabL_{ab}

We’ll now show that the language Lab=anbnL_{ab}=a^nb^n is not regular by showing that it does not satisfy the pumping theorem.

Intuitively, we can surmise that LabL_{ab} is not regular because a finite machine has no way to track an arbitrarily large number of aa's to match the subsequent bb's. We can only go so far before we run out of states. Consider the diagram below accepting the singleton language {ab}\{ab\}. (Once again, we omit the jail state for readability.)

Get hands-on with 1400+ tech skills courses.