✖

DFA minimisation

By minimising an automaton we mean finding an equivalent automaton with the smallest possible number of states. Even an automaton with no redundant state can still be simplified further.

Example

Let us take this automaton:

The automaton accepts only the strings 01 and 11. It is clear that there is a simpler automaton with three states that accepts the same language. The states q1 and q2 can be merged into one new state {q1, q2}; the transitions that led into q1 or q2 will lead into the new state, and the same goes for the transitions leaving q1 and q2. We get this automaton:

This automaton clearly accepts the same language as the previous one and has fewer states.

Equivalence of states

Let A = ⟨Q, Σ, δ, q0, F⟩ be an automaton. We define the language of a state q ∈ Q, written L(q), as

L(q)=L(⟨Q,Σ,δ,q,F⟩)

That is, we change the start state of the automaton A from q0 to q and work out the language accepted by this automaton. In other words, the language L(q) contains all strings w such that in the automaton A we get from the state q to an accepting state on reading w. Going back to the previous automaton, L(q1) = {1}.

We say that two different states q1 and q2 are equivalent if

L(q1)=L(q2)

What does this mean? If q1, q2 are equivalent states and we make each of them the start state of the automaton, they generate the same language. In other words: if the automaton reaches the configurations ⟨q1, w⟩ and ⟨q2, w⟩, then it must either accept in both cases or reject in both cases.

Going back to the previous automaton: the states q1 and q2 are equivalent, because if we are in q1, we can accept the input string only if the unread part of the string is equal to 1. The same holds if we are in q2.

Minimising an automaton is therefore about finding equivalent states and removing them by merging them into one new state, just as we did in the example above.

How to find equivalent states

Which states are certainly not equivalent? An accepting state and a non-accepting state are certainly not equivalent, because the language of an accepting state differs from the language of a non-accepting state: an accepting state certainly accepts the string ε, a non-accepting one does not. We will show the procedure straight away on an example. Let us take this automaton:

We start by creating two sets of states

S1=F={q3,q6},S2=Q∖F={q0,q1,q2,q4,q5}.

Now we create a table of transitions and keep the information about the groups S1 and S2:

groupstate01S1q3q5q4q6——S2q0q1q2q1—q3q2—q3q4q6—q5q6—

Now we change the table so that, instead of writing directly which states we go to for a given symbol, we note only the group we move into. For example, from the state q3 on reading 0 we get to the state q5, which is in the group S2. So instead of q5 we write S2 in the table:

groupstate01S1q3S2S2q6——S2q0S2S2q1—S1q2—S1q4S1—q5S1—

Next we split both groups. We always put into the same group the states that move into the same groups for all symbols. For example, the states q3 and q6 will not be in the same group, because for neither 0 nor 1 do they go into the same group. On the other hand, the states q1 and q2 will be in the same group, because neither has a transition for 0 and both go into the group S1 for 1. This creates the new groups:

groupstate01q3S2S2q6——q0S2S2q1—S1q2—S1q4S1—q5S1—

In every group the states have the same transitions. We label the newly created groups and again find out which of these new groups the states lead into:

groupstate01S1q3S5S5S2q6——S3q0S4S4S4q1—S1q2—S1S5q4S2—q5S2—

At this point we split the groups again. But we see that no further split is possible, as we would get the same groups: the states q1 and q2 do have the same transitions between groups, but they are already in the same group and there is no other state in the group S4. The algorithm for finding equivalent states is finished. From each group it is enough to pick one state; we delete the others, and all transitions that led into deleted states will lead into the one state we picked.

So we can choose that our new automaton has the states q3, q6, q0, q1, q4, and we remove the states q2 and q5. All transitions that led into q2 now lead into q1, and all transitions that led into q5 lead into q4:

Procedure for minimising an automaton

  1. Remove the unreachable states,
  2. remove the redundant states,
  3. remove the equivalent states.

Sources

Chapters: Unreachable states, Redundant states, DFA minimisation