Construct a deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly three 0s.

We will follow a similar approach to previous exercises to solve this exercise.

Let’s define 5 states as follows:

  • S0, the initial state
  • S1 is the state when the automata read exactly one 0
  • S2 is the state when the automata read exactly two 0s
  • S3 is the state when the automata read exactly three 0s. This is our final state because the automaton should recognize only strings with exactly three 0s.
  • S4 is the state when the automaton read more than three 0s.

After the definition of the previous states, we can also define the following transitions:

  • From the initial state with a 1, there is no need to change to a different state.
  • Reading a 0 at the initial state, the new state will be S1 (the automaton read exactly one 0).
  • At S1, reading a 0, the automaton will go to the next state S2 (the automaton read exactly two 0s).
  • At S1, reading a 1, the automaton will stay in the same state.
  • At S2, reading a 0, the automaton will go to the state S3. The automaton read exactly three 0s. Therefore, this one is a final state.
  • At S2, reading a 1, the automaton will stay in the same state.
  • At S3, reading a 0, the automaton will go to the state S4. At this point, the string cannot be recognized by this automaton. Therefore, this state is not final and whatever bit comes next, the automaton will stay in the same state.
A deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly three 0s
A deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly three 0s

We can also specify the transition function using the table below. Don’t forget to specify that S3 is the final state if you use a state table.

 f 
States10
S0S0S1
S1S1S2
S2S2S3
S3S3S4
S4S4S4
Transition function, using a state table, for a deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly three 0s

Similar exercises: