# Prove that a language is not regular with process of elimination [duplicate]

When deterministic automaton, I need to prove that you can't implement the language in it, because the language is not regular.

Easiest way to prove that a language is regular, is just by making an automaton for it. But if the automaton is not regular, you can't just say that it's not regular because you couldn't build an automaton for it.

So I am wondering, how to prove that a language is not regular the simplest way?

Given language:

$$L = \{a^n b^n | n > 0\}$$

Definition: The language accepts series of a's and b's where the amount of as equals to the amount of bs. This is not a regular language.

How can you prove that it's not a regular language?

From what I remember (I didn't understand it much), you had to take a sub-langauge of that language, and mark it as W

So $$W = \{a^i\}$$

Then select 2 words from W and mark them as w1 and w2

$$w1 = a^i$$ $$w2 = a^j$$

where i != j

And then I don't really remember what to do.

A simple technique is using the pumping lemma:

For any regular language $L$ there exists an integer $n$ such that for all $x \in L$, with $|x| \geq n$ there exists $u,v,w \in \Sigma^*$, such that,

• $x = uvw$
• $|uv| \leq n$
• $|v| \geq 1$
• for all $i \geq 0: uv^iw \in L$

Assumption: Suppose your language is regular.

Consider $s = a^nb^n$. Clearly $s \in L$ and $|s| \geq n$. We get that $uvw = a^nb^n$ and we know that $|uv| \leq n$, i.e $v$ can only contain $a$'s and since $|v| \geq 1$ it must contain at least one $a$. According to the last condition of the pumping lemma, $uv^0w \in L$ but this is clearly not the case. We now have a contradiction as we assumed the language to be regular:

The assumption must be wrong implying non-regularity of the language

• Thanks for taking the time to answer! Note that some questions pop up over and over again, and sometimes the exact exercise problem has even been posted before. We have compiled a list of reference questions for FAQs which you may want to check out before spending time on redundant answers. Commented Feb 4, 2015 at 13:55
• Yeah I noticed that - but thanks.
– User
Commented Feb 4, 2015 at 17:44

What you are suggesting is the Myhill–Nerode criterion, which is more natural, and in many cases simpler, than the standard pumping lemma which for some reason has become the undergraduate hallmark of the subject.

Consider your two words $a^i$ and $a^j$. Suppose we are given some DFA for the language. Can the DFA be at the same state after reading $a^i$ and $a^j$? It cannot, since if it were, the DFA would behave the same after seeing the word $b^i$, say reaching some state $q$; but since $a^ib^i \in L$, $q$ must be accepting, while since $a^jb^i \notin L$, $q$ must be rejecting! We conclude that the DFA must be at different states after reading $a^i$ and $a^j$.

We can consider the infinitely many words $a^1,a^2,a^3,\ldots$. The argument above shows that any DFA for $L$ must reach a different state after reading them. So it must have infinitely many states. Contradiction.

In contrast to the pumping lemma, which doesn't always "work" (i.e., there are non-regular languages which satisfying the pumping lemma), the Myhill–Nerode criterion is a complete characterization: if a language is not regular, then you can always find an infinite list of mutually inequivalent words (two words $w_1,w_2$ are inequivalent if for some word $x$, either $w_1x \in L$ while $w_2x \notin L$, or $w_1x \notin L$ while $w_2x \in L$), which proves that the language is not regular.