In a nationwide entrance exam conducted in India, the following problem was asked in the year 2007:
Which of the following languages are regular?
(A) $L_1 = \left\{ ww^R \mid w \in \{0, 1\}^+ \right\}$
(B) $L_2 = \left\{ ww^Rx \mid x,w \in \{0, 1\}^+ \right\}$
(C) $L_3 = \left\{ wxw^R \mid x,w \in \{0, 1\}^+ \right\}$
(D) $L_4 = \left\{ xww^R \mid x,w \in \{0, 1\}^+ \right\}$
source - https://gateoverflow.in/1229/gate-cse-2007-question-31
For option (A), it is a standard textbook example of a non-regular language, because it violates the pumping lemma. We can show that the string $s=0^p110^p$ cannot be pumped. The pumping lemma is stated below for convenience. It is taken verbatim from Michael Sipser's Introduction to Theory of Computation, 3e
Theorem 1.70 - Pumping lemma
If $A$ is a regular language, then there is a number $p$ (the pumping length) where if $s$ is any string in $A$ of length at least $p$, then $s$ may be divided into three pieces, $s = xyz$, satisfying the following conditions:
- $\text{for each } i \ge 0, xy^iz \in A$,
- $|y| \gt 0$
- $|xy| \le p$
For option (C), this language is actually regular. The interesting observation here is that $ \text{A string } s \in L_3 \iff s \text{ begins and ends with same character} $. This is easy to show, so I am omitting the proof.
Coming to the question, I am not able to prove that options (B) and (D) are non-regular languages. Since this is an MCQ question (i.e., only 1 choice is correct), I was lucky to get it correct. But how does one go about proving that these are non-regular languages?
For option (B), I tried with $s = (01)^p(10)^p1$, but further steps seem convoluted in my attempt to show that $s$ cannot be pumped. I haven't attempted option (D). Could it be that these languages satisfy Pumping Lemma but are still non-regular?
Thanks for reading.