Lex 3
Lex 3
Lex 3
• Hopcroft’s algorithm
DFA RE
• All pairs, all paths problem
• Union together paths from s0 to a final state
from Cooper & Torczon 1
DFA Minimization
A partition P of S
• Each s S is in exactly one set pi P
• The algorithm iteratively partitions the DFA’s states
Splitting a set
• Assume qa, qb, & qc s, and
(qa,a) = qx, (qb,a) = qy, & (qa,a) = qz
• If qx, qy, & qz are not in the same set, then s must be split
• One state in the final DFA cannot have two transitions on a
final state
a a b a
a
s0 a s1 b s3 b s4 a b b
s 0 , s2 s1 s3 s4
b a a b a b
s2
What about a ( b | c )* ?
b q5
q4
q0 a q1 q2 q3 q8 q9
q6 c q7
Final states
from Cooper & Torczon 6
DFA Minimization
S p lit on s2
b
Cu rren t Pa rt ition a b c
a
s0 s1 b c
P0 { s 1 , s 2 , s 3 } {s 0 } n o ne n o ne n o ne
c
s3
final states c
To produce the minimal DFA
• Finite closures
Limited identifier length
Adds states to count length