Dfa Minimization
Dfa Minimization
We notice some obviously unnecessary features in the first dfa. The state q5
plays absolutely no role in the automaton since it can never be reached from the
initial state q0 . Such a state is inaccessible, and it can be removed without af-
fecting the language accepted by the automaton. But even after the removal of
q5 , the first automaton has some redundant parts. The states reachable subse-
quent to the first move δ(q0 , 0) mirror those reachable from a first move δ(q0 , 1).
1
The second automaton combines these two options.
Also, in terms of simplicity, the second alternative is clearly preferable. Repre-
sentation of an automaton for the purpose of computation requires space pro-
portional to the number of states. For storage efficiency, it is desirable to reduce
the number of states as far as possible. We now describe an algorithm that ac-
complishes this.
2 Definition
Two states p and q of a dfa are called indistinguishable if
δ ∗ (p, w) ∈ F implies δ ∗ (q, w) ∈ F
and,
δ ∗ (p, w) ∈
/ F implies δ ∗ (q, w) ∈
/F
for all w ∈ Σ∗
If, on the other hand, there exists some string w ∈ Σ∗ such that,
δ ∗ (p, w) ∈ F implies δ ∗ (q, w) ∈
/F
or vice versa, then the states p and p are said to be distinguishable by a string
w.
3 Algorithm
Procedure : Mark
1. Remove all inaccessible states. This can be done by enumerating all simple
paths of the graph of the dfa starting at the initial state. Any state not
2
part of some path is inaccessible.
3. Repeat the following step until no previously unmarked pairs are marked.
For all pairs (p, q) and all a ∈ Σ, compute δ(p, a) = pa and δ(q, a) = qa . If
the pair (pa , qa ) is marked as distinguishable, mark (p, q) as distinguish-
able.
We claim that this procedure constitutes an algorithm for marking all distin-
guishable pairs.
(The procedure mark can be implemented by partitioning the states into equiv-
alence classes. Whenever two states are found to be distinguishable, they are
immediately put into separate equivalence classes)
To apply the procedure mark to find distinguishable and indistinguishable states
we use Table-Filling method as shown in the problems below. We use mark
to indicate distinguishable states and × to indicate indistinguishable states
4 Problems
1. Minimize the following dfa
3
q1
q2
q3 ×
q4
q0 q1 q2 q3
After applying the mark procedure in above table we get (q1 , q3 ) as the indis-
tinguishable states. The set Q becomes
Q = {q0 , (q1 , q3 ), q2 , q4 }
We get the following DFA in which q1 and q3 are combined.
Note that q2 and q4 are inaccessible. So after removing them we the dfa
shown below
4
Figure 5: After removing inaccessible states
q1 ×
q3
q5 ×
q0 q1 q3
We see tgat (q0 , q1 ) and (q3 , q5 ) are indistinguishable states. The set Q becomes
Q = {(q0 , q1 ), (q3 , q5 )}
We get the following DFA in which (q0 , q1 ) and (q3 , q5 ) are combined.
5
Figure 7: dfa with unnecessary states
q1
q2 ×
q3 × ×
q4
q0 q1 q2 q3
We see that (q1 , q2 ), (q1 , q3 ) and (q2 , q3 ) are the indistinguishable states.
Since
(q1 , q2 ) ∩ (q1 , q3 ) ̸= ∅, and
(q1 , q2 ) ∩ (q2 , q3 ) ̸= ∅, and
(q1 , q3 ) ∩ (q2 , q3 ) ̸= ∅,
We can combine them into a single state (q1 , q2 , q3 ). The set Q becomes
Q = {q0 , (q1 , q2 , q3 ), q4 }
We get the following DFA in which q1 , q2 and q3 are combined.
6
Table 1: Transition table
State 0 1
→A B F
B G C
∗C A C
D C G
E H F
F C G
G G E
H G C
State 0 1
→A B F
B G C
∗C A C
E H F
F C G
G G E
H G C
B
C
E ×
F
G
H ×
A B C E F G
7
We see that (A,E) and (B,H) are the indistinguishable states. The set Q be-
comes
Q={(A,E),(B,H),C,F,G}
We get the following DFA in which (A,E) and (B,H) are combined as shown
below.
State a b
→A B C
B C E
∗C D C
D C E
∗E B E
8
B
C
D ×
E ×
A B C D
Therefore (B, D) and (C, E) are the indistinguishable states.The set Q becomes
Q={A,(B,D),(C,E)}
We get the following DFA in which (B, D) and (C, E) are combined as shown
below.