...

/

Minimal Automata

Minimal Automata

Learn how to minimize the number of states of a DFA.

DFAs are useful in recognizing text patterns and are easily implemented in code. We haven’t considered, however, whether an automaton is “efficient.” Our measure of efficiency is the number of states, since that determines the number of possible transitions that exist.

Making DFA efficient

Let’s examine the following DFA, DeD_e, for any redundant states.

Press + to interact
Is the DFA De efficient?
Is the DFA De efficient?

Once we reach state q2q_2, the machine remains in an accepting state regardless of subsequent input. States q2q_2 and q3q_3 can therefore collapse into a single accepting state, as shown in the figure below.

Press + to interact
Combining states q2 and q3
Combining states q2 and q3

Now let’s think about what language the machine above accepts. If a string starts with a bb, it is accepted. If it starts with an aa, it is not accepted until a bb is read. In other words, this machine accepts the language of strings that have at least one bb. We can therefore combine states q0q_0 and q1q_1 to obtain the minimal DFA in the figure below.

Press + to interact
A minimal DFA equivalent to De
A minimal DFA equivalent to De

We’ve discovered that states q0q_0 and q1q_1 play the same role in the original DFA (DeD_e). States q2q_2 and q3q_3 are likewise indistinguishable in their function, and we have reduced the number of states from 4 to 2.

Identifying distinguishable states

Which states are indistinguishable in the DFA DaD_a ...

Access this course and 1400+ top-rated courses and projects.