Why is $a^nb^n$ irregular but $a^*b^*$ regular?

1.9k Views Asked by At

I was reading to find how a subset of regular language can be irregular and came across this. This raised the question why is $L = \{a^nb^n:\, n > 0\}$ irregular but not $a^*b^*$ ? I understand a language should be finite to be regular. $L$ could be infinite but so could $a^*b^*$ so why one is irregular and the other not ?

1

There are 1 best solutions below

0
On BEST ANSWER

A language can be infinite and regular. Finite languages are always regular (you can basically enumerate them), infinite languages have to be decided case by case.

A regular language has a finite recognition automaton, so it cannot "remember" if it has seen as many $a$'s as it will have to see $b$'s, but it's easy to recognise you've only seen $a$'s followed by $b$'s (which is what $a^\ast b^\ast$ is).

The formal proof that $\{a^n b^n : n \ge 0\}$ is not regular usually involves the "pumping lemma", and is quite technical. But the idea is in the inherit finite number of the states we can use to recognise a language.