0% found this document useful (0 votes)
99 views9 pages

Dfa Minimization

Uploaded by

lokotwiststudio2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views9 pages

Dfa Minimization

Uploaded by

lokotwiststudio2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Minimizing DFA

Text Book: Peter Linz


Prepared by : Dr. Ravi B

October 31, 2022

1 Why do we need to minimize DFA?


For a given language, there are many dfa’s that accept it. There may be a
considerable difference in the number of states of such equivalent automata.
However, there may be reasons for preferring one over another. Consider the
following two equivalent dfa’s

Figure 1: Two equivalent dfa’s

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.

Clearly, two states are either indistinguishable or distinguishable. Indistin-


guishability has the properties of an equivalence relation: If p and q are in-
distinguishable and if q and r are also indistinguishable, then so are p and r,
and all three states are indistinguishable.
One method for reducing the states of a dfa is based on finding and combin-
ing indistinguishable states. We first describe a method for finding pairs of
distinguishable states.

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.

2. Consider all pairs of states (p, q). If p ∈ F and q ∈


/ F or vice versa, mark
the pair (p, q) as distinguishable

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

Figure 2: dfa with unnecessary states

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.

Figure 3: Minimized dfa

2. Minimize the following dfa

Figure 4: dfa with unnecessary states

Note that q2 and q4 are inaccessible. So after removing them we the dfa
shown below

4
Figure 5: After removing inaccessible states

We can now apply the mark procedure to construct the table

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.

Figure 6: Minimized dfa

3. Minimize the following dfa

5
Figure 7: dfa with unnecessary states

After applying the mark procedure we get the following table

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.

Figure 8: Minimized dfa

4. Minimize the following dfa

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

We see that D is inaccessible. After removing D

Table 2: Transition table

State 0 1
→A B F
B G C
∗C A C
E H F
F C G
G G E
H G C

Now we use the mark procedure on the above dfa

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.

Figure 9: Minimized dfa

5. Minimize the following dfa (Exercise)

Table 3: Transition table

State a b
→A B C
B C E
∗C D C
D C E
∗E B E

After applying mark procedure on the above dfa, we get

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.

Figure 10: Minimized dfa

6. Minimize the following dfa (Exercise)

Figure 11: dfa with unnecessary states

You might also like