On the existence of a non-regular language $L$ such that $L^2\in \text{Reg}$?

333 Views Asked by At

Is there a non-regular language $L$ such that the language $L^2$ is regular? Nothing comes to my mind. What's your proposition ?

1

There are 1 best solutions below

3
On BEST ANSWER

Take a one-letter alphabet $\{a\}$ and let $L = \{a^{n^2} \mid n \geqslant 0 \} \cup \{a^{2n+1} \mid n \geqslant 0 \}$. Then $L^2 = a^*$, a regular language, and I let you verify that $L$ is not regular.