Professional Documents
Culture Documents
CS 160
CS 160
1
DFA simulation,
recognizing longest matching prefix
NFA Simulation
2
RE → NFA using Thompson’s Construction
Key idea
• We have a pattern for constructing an NFA for each symbol & each operator
• We apply these patterns respecting the precedence order
• Patterns for operators combine the NFAs from previous steps with ε moves
a a ε b
S0 S1 S0 S1 S3 S4
a ε
S1 S2
ε ε
S0 S5 ε a ε
S0 S1 S3 S4
ε b ε ε
S3 S4
NFA for a*
NFA for a | b
3
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
DFA Minimization
Splitting a set
• Split a set s into smaller groups if states in s have transitions to
different sets for the same input