You are on page 1of 11

State Minimization in

Lexical Analyzers

• Faisal A (61072111110)
• Gokul E (61072111112)
• Varun Kumar M (61072211917)
State Minimization
 The task of State minimization 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)
Hopcroft Minimization
Algorithm
 Remove all the states that are not reachable
from the initial state
 Determine 0 equivalent state,1 equivalent
state,2 equivalent state,… ,n equivalent state
 Repeat Step 2 until nth equivalent and (n-1)th
equivalent states result with same set of
strings
 Construct minimal DFA using the result
obtained in Step 3
Hopcroft Minimization
Algorithm
 The initial state of the minimized DFA is the
representative of the group containing the start state
of the original DFA

 The accepting states of the minimized DFA is the


representative of those groups that contain an
accept/final state of the original DFA
DFA
 Often representing as a diagram:
Simple Example
Simple Example

Merge s1 and s2
DFA Minimization
 This is a state-minimized (or just minimized)
DFA
 Every remaining state is necessary
DFA Minimization
 So these two DFAs are equivalent:
Conclusion
 DFA Minimization 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 that John Hopcraft described


is O(k (n log n) )
References
 Alfred V Aho, Monica Lam, Ravi Sethi and Jeffery D Ullman, ”Compilers –
Principles, Techniques and Tools”, Essex Pearson , Harlow, 2014.

 Keith D Copper and Linda Torczon, “Engineering a Compiler”, Second


Edition, Morgan Kaufmann Publishers Elsevier Science, 2011

You might also like