As I am currently teaching regular languages and pumping lemma, I was searching for nice examples of languages, regular or not, for exercises.
- $L_1 = \{vv\mid v\in \Sigma^*\}$ is a classic example, as it can be proven to be non regular for $|\Sigma|\geqslant 2$ using the pumping lemma;
- $L_2 = \{ uvv\mid u,v\in\Sigma^*\}$ looks like $L_1$, however it is a bit of a trap: since $L_2 = \Sigma^*$, it is regular;
- $L_3 = \{uvv\mid u\in\Sigma^*, v\in\Sigma^+\}$ looks like $L_2$, however it is not regular if $|\Sigma| \geqslant 2$. This can be proven using the pumping lemma: suppose it is regular, and let $n$ be the pumping length. Let $u=a^nba^nb\in L_3$ and $u = xyz$ a decomposition such that $|xy|\leqslant n$ and $|y| > 0$. Then $xz = a^kba^nb$ with $k< n$ and does not end with a (non empty) square, therefore is not in $L_3$ which is not regular;
Things became a bit complicated with $L_4 = \{uuv\mid u\in \Sigma^+, v\in \Sigma^*\}$: after struggling a bit to find a counter-example word to the pumping lemma, I proved $L_4$ to be non regular if $|\Sigma|\geqslant 2$, using the fact that $L_3 = L_4^R$ and that regular languages are closed under mirror image.
However, if $|\Sigma| = 2$, I found out that $L_4$ verifies the conclusion of the pumping lemma, with a pumping length of $5$! Indeed, since any word of length $\geqslant 4$ contains a square, any word $u\in L_4$ with $|u| \geqslant 5$ can be written $u = vwwu'$ with $|vww|\leqslant 5$ and $|v|,|w| > 0$. Therefore $u = xyz$, with $x = \varepsilon$, $y = v$ and $z = wwu'$ verifying:
- $|xy| = |v| < |vww| \leqslant 5$;
- $|y| = |v| > 0$;
- for all $k \geqslant 0$, $xy^kz\in L_4$. Indeed, $xz = z = wwu' \in L_4$ (because $|w| > 0$), $xyz = u \in L_4$ (hypothesis) and if $k>1$, $xy^kz = yyy^{k-2}z \in L_4$ (because $|y| > 0$).
I then tried to find a counter-example to the pumping lemma for $L_4$ when $|\Sigma|>2$, but without success. I found out that in order to not be able to apply the previous reasoning, in any counter-example, the first $n$ (pumping length) letters need to not contain a square, which is possible, but couldn't go further.
My questions are all related to this problem:
- I don't think I did, but maybe, did I make any mistake?
- Is there a counter-example word to the pumping lemma for $L_4$ when $|\Sigma| \geqslant 3$?
- Do you know of any simpler language that is a counter-example to the converse of the pumping lemma (not regular but verifying the conclusion of the pumping lemma)? vonbrand proposed this one which is a tad bit complicated. I also know of $\{ab^iab^jab^j\mid i,j\geqslant 0\}\cup \{uaav\mid u,v\in\Sigma^*\}$ which is not better.