11

Given a language $ L= \{a^n b^n c^n\}$, how can I say directly, without looking at production rules, that this language is not regular?

I could use pumping lemma but some guys are saying just looking at the grammar that this is not regular one. How is it possible?

Vitaly Olegovitch
  • 1,248
  • 1
  • 14
  • 21
doniyor
  • 243
  • 1
  • 8

3 Answers3

12

The main property of DFA's/NFA's is the lack of unbounded memory. If you look at a language and the only algorithm (which should later be translated into a Finite Automaton) you can think of requires this property, that is, you feel that any algorithm that recognizes it will need to remember an arbitrary large number of things (like $n$ in your example) then that language is probably not regular.

Of course, you should always remember that mathematical intuition can be wrong, and the only way to be sure of your intuition is to prove it.

EDIT: I'll answer the last question in the comments here, because of lack of space.

you guys are talking about unbounded memory which you mean is the reason why it is not regular. but a^nb^m can also have unbounded memory if i want, doesnot it? this is still giving me no peace.

The issue is not how big the words can get (you will usually encounter infinite regular languages, because every finite language is regular, and that's pretty boring) but how much the DFA needs to remember.
In the $a^mb^n$ example, there is no need to remember $m,n$. The algorihm just needs to make sure they are positive and that the word is correctly ordered. This is a finite list, and each of the items on the list requires a constant amount of memory.
Compare this to $a^nb^n$, for which a simple alogrithm is required to remember that the number of $a$'s is equal to the number of $b$'s. This will require unbounded memory. When I look at a language and see that any algorithm I can think of needs unbounded memory, my intuition that the language is not regular grows stronger. If I can't find a "smart" algorithm (one that requires a constant amount of memory) in a reasonable amount of time (how much time is reasonable is up to you) I will try proving the language is not regular.
Hope this makes it a bit clearer.

Boris Trayvas
  • 431
  • 3
  • 7
6

I could use pumping lemma

Exactly. After you have used the Pumping lemma or any of the other techniques a couple (of dozens) of times, you will start seeing the patterns in languages that prohibit them from being regular. $a^n\dots b^n$ is a very basic one you probably have mastered already. So this is also a matter of experience, not only intuition.

A good way to test your intuition is looking at these languages:

  1. $\quad \displaystyle \{xyyz \mid x,y,z \in \{a,b\}^+\}$
  2. $\quad \displaystyle \{xyyz \mid x,y,z \in \{a,b\}^*\}$
  3. $\quad \displaystyle \{xyyz \mid x,y,z \in \{a,b,c\}^+\}$
  4. $\quad \displaystyle \{xyyz \mid x,y,z \in \{a,b,c\}^*\}$

Which are context-free?

Raphael
  • 73,212
  • 30
  • 182
  • 400
4

You can actually decide if a language is regular using fairly straightforward calculations, rather than doing a full proof. You simply need to apply one very powerful criterion: A language is regular if and only if it has finitely many quotients.

Intuitively, a quotient is what you need to complete a word after having already read in part of the input. More formally, the left quotient of a language $L$ by a string $x$, written $x\setminus L$ is the set of strings $w$ such that $xw \in L$. For example, if $L=\{a^nb^n\}$, then $a\setminus L= \{a^{n-1} b^n | n\ge 1 \}$, while $b \setminus L=\emptyset$. We can easily see that $a^k \setminus L = \{a^{n-k}b^n | n \ge k \}$. There are infinitely many quotients of the form, so it follows immediately that $L$ is not regular.

If we construct a DFA $D$ to decide L, and $D$ will be in state $S$ after reading in $a$, then $a\setminus L$ is the language decided by $D$ modified to have start state $S$. This same idea can be used to directly construct the minimal DFA that decides a regular language from its definition.

James Koppel
  • 569
  • 2
  • 6