#### Question

Construct a finite-state machine with output that produces an output of 1 if the bit string read so far as input contains four or more 1s. Then construct a deterministic finite-state automaton that recognizes this set.

#### Solution

Verified#### Step 1

1 of 3$\textbf{Finite-state machine}$

A $\textbf{finite state machine}$ is a six-tuple $(S,I,O,f,g,s_0)$ where $S$ is the set of States, $I$ is the input alphabet, $O$ is the output alphabet, $f$ is the transition function that assigns a next state to a pair of a state and input, $g$ is an output function that assigns an output to every pair of a state and input, and $s_0$ is the starting state.

The $\textbf{states}$ of the finite-state machine are the labels written in the circles (states).

$S=\{s_0,s_1,s_2,s_3,s_4\}$

where $s_i$ represents that there are $i$ or more 1's in the string read so far.

The $\textbf{input symbols}$ of the finite-state machine are the possible inputs.

$I=\{0,1\}$

The $\textbf{initial state}$ of the finite-state machine is $s_0$

$\text{Initial state}=s_0$

When a 1 is read, we need to move from state $s_i$ to $s_{i+1}$ when $i=0,1,2,3$.

Otherwise, we will remain at the current state at the input is a 0 or as we already know that there are four or more 1's.

The output needs to be 1 when there are four or more ones and 0 otherwise.