Dfa Minimization: Cs466 (Prasad) L13Dfamin 1

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

DFA Minimization

cs466(Prasad) L13DFAMin 1
Strings over {a,b} with even number of a’s
*

Ea Oa
Eb Ob Eb Ob

b
[Ea,Eb] [Ea,Ob]
b
a a a a
b
[Oa,Eb] [Oa,Ob]
b

cs466(Prasad) L13DFAMin 2
Strings over {a,b} with even number of a’s
*

Ea Oa

a
[Ea] [Oa]
a

b b

cs466(Prasad) L13DFAMin 3
Observation

• The states among the state sets {[Ea,Eb],


[Ea,Ob]} and {[Oa,Eb], [Oa,Ob]} differ on
aspect immaterial for the problem at hand.
• Why not collapse these state sets into one
state each, to get a smaller DFA?

cs466(Prasad) L13DFAMin 4
Equivalent or Indistinguishable States

• Recall that a DFA state summarizes the substring


consumed so far (that is, the past history).
• Two states qi and qj are equivalent or
indistinguishable (for the future), if, when started
in these states, every string causes the machine to
either end up in an accepting state for both or end
up in a non-accepting state for both.
• In other words, there is no string that can tell the
equivalent states apart for the given language.
cs466(Prasad) L13DFAMin 5
Main Idea
qi qm
a

qj qn
a

If qm and qn are distinguishable, then so are qi and qj

cs466(Prasad) L13DFAMin 6
Example DFA
b

a a b
q0 q1 q2 q3
a,b a
b
a,b
q4 a q5 q7

a,b
b q6 a
(a u b)(a u b*)
b

cs466(Prasad) L13DFAMin 7
Refinement of State Partitions

• { {q0,q7} , {q1,q2,q3,q4,q5,q6} }
• { {q0},{q7}, {q1,q2,q3,q4,q5,q6} }
• On any transition
• { {q0},{q7}, {q1,q2,q3,q4,q5,q6} }
• { {q0},{q7}, {q1,q4}, {q2,q3,q5,q6} }
• On “a” transition
• { {q0},{q7}, {q1,q4}, {q2,q5},{q3,q6} }
• On “b” transition

cs466(Prasad) L13DFAMin 8
Example DFA showing equivalent states
b

a a b
q0 q1 q2 q3
a,b a
b
a,b
q4 a q5 q7

a,b
b q6 a
(a u b)(a u b*)
b

cs466(Prasad) L13DFAMin 9
Example Minimum DFA

q0

a,b
a,b
q1,q4
a q2,q5 q7

a,b
b q3,q6
a
(a u b)(a u b*)
b

cs466(Prasad) L13DFAMin 10
• For an efficient way of determining
minimal DFA, see the details in Algorithm
5.7.2

cs466(Prasad) L13DFAMin 11

You might also like