Let's say I have a formal language $L$. I wanted to know which of these three equalities can be derived from the the given fact that $L^2$ = $L$:
- $L^+ = L$
- $L^* = L$
- $\varepsilon \in L$
where $L^+$ and $L^*$ are the Kleene plus and Kleene star. What exactly is correct here? Does the fact that $\varepsilon \in L$ mean that for every $L$ it is equal to $L^2$?
As noted, the empty language $\varnothing$ satisfies $\varnothing^2 = \varnothing$ and $\varnothing = \varnothing^+$, but $\varnothing^* = \{ \varepsilon \} \ne \varnothing$.
Next, if the language $L$ is non-empty, it has to contain $\varepsilon$: Say one of the shortest strings in $L$ is $\alpha \ne \varepsilon$, then there are no strings shorter than $\alpha^2$ in $L^2$, a contradiction.
Furthermore, if a non-empty $L = L^2$, then also $L = L \cdot L = L \cdot L^2 = L^3$, and in general $L = L^n$ for $n \ge 1$. Thus:
$\begin{align*} L^* &= \{ \varepsilon \} \cup L \cup L^2 \cup \ldots \\ &= \{ \varepsilon \} \cup L \cup L \cup \ldots \\ &= \{ \varepsilon \} \cup L \\ &= L \qquad \text{(since \(\varepsilon \in L\))} \end{align*}$
The same way:
$\begin{align*} L^+ &= L \cup L^2 \cup L^3 \cup \ldots \\ &= L \cup L \cup L \ldots \\ &= L \end{align*}$
Note that for example if $L = \{ \varepsilon, a \}$ then $L^2 = \{ \varepsilon, a, a^2 \} \ne L^2$. Tracing the above discussion, you see that any language sastisfying $L^2 = L$ must be $\varnothing$, $\{ \varepsilon \}$, or be infinite.