Deterministic finite machine recognizing language $((00)^*|1(11)^*)^*$

finite-state machineformal-languagessolution-verification

Is the following deterministic finite machine correct for recognizing the language $((00)^*|1(11)^*)^*$?

Let $M=(Q,\Sigma,\delta,q_0,F)$ where $Q = \{q_0,q_1,q_2,q_3,q_4,q_5,q_\Delta\}$ is the set of states, $\Sigma=\{0,1\}$ is the alphabet, $\delta:Q\times\Sigma\to Q$ is the transition function given by
$$
\begin{array}{c|cc}
q\overset{\LARGE\setminus}{\phantom{.}}\overset{\Large i}{\phantom{l}}&0&1\\\hline
q_0&q_1&q_2\\
q_1&q_3&q_\Delta\\
q_2&q_\Delta&q_4 \\
q_3&q_1&q_\Delta\\
q_4&q_\Delta&q_5\\
q_5&q_\Delta&q_4 \\
q_\Delta&q_\Delta&q_\Delta
\end{array},
$$

$q_0$ is the start state, and $F=\{q_0,q_2,q_3,q_5\}$ is the set of accept states. Then $M$ recognizes the language described by the regular expression $((00)^*|1(11)^*)^*$.

Visualization:

finite machine

Best Answer

Your language is equivalent to $(00|1)^*$. It's much clearer now that our machine should only reject sequences that contain an odd number of zeroes consecutively. From this, we can define a simpler machine

Let $ M = (Q, \Sigma, \delta, q_0, F) $ where $Q = \{q^0, q^1, q^\Delta\}$ is the set of states, $\Sigma = \{0, 1\}$ is the alphabet, $ \delta : Q \times \Sigma \to Q $ is the transition function defined by

$$ \begin{array}{c|cc} q\overset{\LARGE\setminus}{\phantom{.}}\overset{\Large i}{\phantom{l}}&0&1\\ \hline q^0&q^1&q^0\\ q^1&q^0&q^\Delta\\ q^\Delta&q^\Delta&q^\Delta \\ \end{array}, $$

$q_0 = q^0$ is the start state, and $F = \{q_0\}$ is the set of accept states.