This is a question from a text book that's giving me some trouble. The question is:

Determine whether or not this language is regular. Justify your answer. $$L = \{ww : w \in \{a,b\}^* \}$$

I think this language is not regular because $w$ can be of arbitrary length and adheres to no pattern. So, therefore, it cannot be determined whether $ww$ is part of the language using a finite number of states. Am I correct in this assumption, and does my explanation make sense? Thanks for any help you can give me!

My answer, after reading the comments below:

Let $w = ww = (a^p)(b^p)(a^p)(b^p)$. Then consider the Pumping Lemma. Since $|xy| \leq p $ and $|y| \geq 1$, then the $y$ part of the string must be a's. But if we pump up, we'll have more a's in the first part than the second, and $w \neq w \in ww$. Hence, the language can't be regular.

  • 1
    $\begingroup$ I think your general idea could work, but you must argue very accurately why it is impossible have a DFA of finite size for the given language. Apart from this, this sounds like you should consider the pumping lemma here. $\endgroup$ – Rmn Feb 16 '15 at 17:06
  • $\begingroup$ See cs.stackexchange.com/q/1031/755 and cs.stackexchange.com/q/11759/755. $\endgroup$ – D.W. Feb 16 '15 at 21:37
  • $\begingroup$ "no pattern" is not a valid reason. Even though $w$ does not have a "pattern", the language $\{w \mid w \in \{a,b\}^*\}$ is regular. So this does not give you anything, and you can not conclude that finitely many states are insufficient. $\endgroup$ – Raphael Feb 17 '15 at 7:38
  • $\begingroup$ Ah, I see. I'll edit the above post and add my new solution. Thanks. $\endgroup$ – Victor Brunell Feb 18 '15 at 14:31

Your explanation is correct. To make it more rigorous, assume that L can be recognized by a finite automaton $D$ with $N$ states.

Consider feeding a string $w$ longer than $N$ characters to $D$. Since $D$ has only $N$ states, that means it will go through some state twice. Suppose $w$ can be represented as $w = pqr$, where the state of the DFA is the same before and after $q$.

Then the strings $ww = pqrpqr$ and $pqqq...rpqr$ must be both accepted by $D$, but probably only the first one is in $L$ (some more rigor may be needed to prove that there exists such a string $w$ such that the second string really cannot be in $L$, for some number of repetitions of $q$).

P.S. looks like I unknowingly used the Pumping Lemma.

  • $\begingroup$ "Your explanation is correct" -- I disagree. There is no logically valid step in the OP's post. $\endgroup$ – Raphael Feb 17 '15 at 7:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.