Create DFA that accept language where number of 0's is even and after every 1 goes 0

2.2k Views Asked by At

Alphabet ${} = \{0,1\}$.

Language $L = \{ w \in \{0,1\}^* \mid \text{ number of $0$'s in $w$ is even and after every $1$ goes $0$} \}$.

I'm trying to create DFA that accepts language $L$. But I have some problems. Transition arrow with $1$ can only lead to the same state is goes from. But when it happens this state can not be final state. If arrow with $1$ goes to another state, then word can contain $11$ so this DFA would not accept this language. Probably I think in incorrect way? Can you give some advice how to create DFA that will accept language $L$?

2

There are 2 best solutions below

0
On

For the first part of the conditions, i.e. $|w|_0\equiv 0 \pmod 2$, you need two states, one for when the number of $0$'s read is even and one for the odd. For the second one, you must create a help state for the two states you had that reads the $1$ and pushs the 0 for the other state.

So the problem is that you are thinking in just keep 2 states. And you said that
"If arrow with 1 goes to another state, then word can contain 11 so this DFA would not accept this language" that is not necessary true, you can create a junk state where that kind of things go.

Hope it helps.

0
On

The regular language of even zeros is the language $(1*01*01*)*$, the regular language for no consecutive ones is $(1?0*)*$. One can construct $\varepsilon$-NFAs for each case using the Thompson construction, and use the subset construction to convert them into two explicit DFAs. One can then use the (constructive) proof that the finite union of two regular languages is regular to get an explicit DFA that matches both.