This document discusses minimizing the number of states in a deterministic finite automaton (DFA). It begins with an introduction to DFAs, defining their components. It then explains that states can be redundant and provides an example of two equivalent DFAs where one state is unnecessary. The task of DFA minimization is to automatically transform a given DFA into an equivalent state-minimized DFA. An algorithm for DFA minimization is described that works by partitioning states into groups based on whether their transitions lead to the same groups for each input symbol, and merging states that are not distinct. Examples are provided to illustrate the algorithm. In conclusion, it notes that DFA minimization is useful for applications like regular expression matching and compiler optimizations, and that the
4. DFA MINIMIZATION
Deterministic Finite Automata (DFSA)
(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
5. Minimizing Number of States of a DFA
• Partition the set of states into two groups:
– G1 : set of accepting states
– G2 : set of non-accepting states
• For each new group G
Partition G into subgroups such that states s1 and s2 are in the same group if
for all input symbols a, states s1 and s2 have transitions to states in the same group.
Start state of the minimized DFA is the group containing
the start state of the original DFA.
Accepting states of the minimized DFA are the groups containing
the accepting states of the original DFA.
9. DFA Minimization
This is a state-minimized
(or just minimized) DFA
Every remaining state
is necessary
10. 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)
11. DFA Minimization
Algorithm
• 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
12. DFA Minimization Algorithm
• Create lower-triangular table DISTINCT, initially blank
• For every pair of states (p,q):
• If p is final and q is not, or vice versa
• DISTINCT(p,q) = ε
• Loop until no change for an iteration:
• 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) = α
• Combine all states that are not distinct
17. conclusion
It is a fairly understandable process, and is
useful in several areas
• Regular expression matching
implementation
• Very similar algorithm is used for compiler
optimization to eliminate duplicate
computations.
The algorithm described is O(kn2)
• John Hop craft describes another more
complex algorithm that is O(k (n log n) )
DFA Minimization