DFA Minimization
DFA Minimization
Myhill-Nerode Method
0 0 0 0 0
1 1 1
1 1
A minimal DFA
• In practice, we are interested in the DFA with the minimal number of states.
– Use less memory
– Use less hardware (flip-flops)
• We can find a minimal DFA for any given DFA and their languages are equal.
Basis:
• Any non-accepting state is distinguishable from any accepting state.
Induction:
• States p and q are distinguishable if there is some input symbol a such that (p,a)
is distinguishable from (q,a).
• All other pairs of states are indistinguishable, and can be merged appropriately.
0
q x • p is distinguishable from q
0 q
p
r x and r by basis, mark them
1 1 p q
1
0
r
p
0 q • Equivalence relation partitions (equivalence
classes): { {p}, {q,r} }
1 1
1 • q and r are indistinguishable.
0
r
p
0,1 {q,r} 1
Equivalence Classes:
Equivalence Classes:
{ {A,E}, {B,H}, {C}, {D,F}, {G} }
• Suppose there is an equivalent DFA M 1 with transition function 1but with fewer
states Q = {q0,…,qn} where n<m.
• Since all states of M are distinguishable (since M is minimal), there must be distinct
,w ) = p for all i.
strings w1,…,wm such that δ(p 0 i i
• Since p and p are distinguishable, there must be some string x such that