DFA Minimization
DFA Minimization
DFA
(Q, , , q0, F)
Q (finite) set of states alphabet (finite) set of input symbols transition function q0 start state F set of final / accepting states
DFA
DFA Minimization
DFA Minimization
DFA Minimization
DFA Minimization
The task of DFA minimization, then, is to automatically transform a given DFA into a state-minimized DFA
Several algorithms and variants are known Note that this also in effect can minimize an NFA (since we know algorithm to convert NFA to DFA)
Recall that a DFA M=(Q, , , q0, F) Two states p and q are distinct if
p in F and q not in F or vice versa, or for some in , (p, ) and (q, ) are distinct
Using this inductive definition, we can calculate which states are distinct
Create lower-triangular table DISTINCT, initially blank For every pair of states (p,q):
For every pair of states (p,q) and each symbol If DISTINCT(p,q) is blank and DISTINCT( (p,), (q,) ) is not blank
DISTINCT(p,q) =
s0 s1 s2
Label pairs with where one is a final state and the other is not
s0 s1 s2
s0 s1 s2
Merge s1 and s2
Check for pairs with one state final and one not:
Conclusion
Regular expression matching implementation Very similar algorithm is used for compiler optimization to eliminate duplicate computations John Hopcraft describes another more complex algorithm that is O(k (n log n) )
Question: Inductively define when two states in a DFA are distinct. Answer:
Two states p and q are distinct if p F and q F or vice versa, or for some , (p, ) and (q, ) are distinct
References
Ullman, A. V., Hopcroft, J. E. and Ullman, J. D. (1974) The Design and Analysis of Computer Algorithms. Addison-Wesley.
Hopcroft, J. (1971) An N Log N Algorithm for Minimizing States in a Finite Automaton. Stanford University.
Parthasarathy, M. and Fleck, M. (2007) DFA Minimization. University of Illinois at Urbana-Champaign.
http://www.cs.uiuc.edu/class/fa07/cs273/Handouts/minimization/minimization.pdf