How to minimize a DFA
Introduction
Minimizing a DFA means converting a given DFA to an equivalent DFA with a minimum number of states.
We can the following two methods to minimize a DFA:
The equivalence method
The Myhill Nerode method
We will cover the Myhill Nerode method in this answer.
Myhill Nerode method
There are five steps included in this process:
A
table is formed where is the number of states in the DFA. The table will specify all possible combinations of the states.
Let's consider the following DFA:
The equivalent table for the above DFA is:
The upper half of the table is crossed out as the order of the combination does not matter:
Mark the states pairs
where or must be a final state. These state pairs are called distinguishable relations.
Now for the
, we take each unmarked state pair and computeundistinguishable relations The state pairs that are of the same type i.e. both are final or both are non-final states. , where s is the set of the inputs. This function calculates the transition from an initial state to a given input. If the resultant pair from any input is already marked in the table, the state pair is also marked.
e.g.
As
Repeat step 3 until no more relations are left that can be marked. In this case, we mark the boxes depending on the iteration number.
We see that
Check the table column-wise and see which unmarked pairs can be merged.
For example, In column 0, only
The transitions of the merged states will have no conflict and are shown on the DFA.
Free Resources