DFA Minimization: The Idea: "Minimal"?
DFA Minimization: The Idea: "Minimal"?
DFA Minimization: The Idea: "Minimal"?
“Minimal”?
Minimal number of states.
“Unique”?
Unique up to renaming of states.
I.e., has same shape. Isomorphic.
1
DFA Minimization: Algorithm Idea
z z
p p
or
z z
q q
2
DFA Minimization: Algorithm
3
DFA Minimization: Algorithm
4
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
1. Initialize table entries:
Unmarked, empty list f
a b c d e f g
5
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
2. Mark pairs of final &
nonfinal states f
a b c d e f g
6
DFA Minimization: Example
0 1
0 1 0
a b c d (b,0) ? (a,0)
0 1 b
1 (b,1) ? (a,1)
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
a b c d e f g
7
DFA Minimization: Example
0 1
0 1 0
a b c d g ? b Maybe.
0 1 b
1 c ? f No!
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
a b c d e f g
8
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
a b c d e f g
9
DFA Minimization: Example
0 1
0 1 0
a b c d (e,0) ? (a,0)
0 1 b
1 (e,1) ? (a,1)
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
a b c d e f g
10
DFA Minimization: Example
0 1
0 1 0
a b c d h ? b Maybe.
0 1 b
1 f ? f Yes.
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
h
(a,e)
a b c d e f g
11
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
(g,a)
g
(g,a)
h
(a,e)
a b c d e f g
12
DFA Minimization: Example
0 1
0 1 0
a b c d b Need to mark.
1 0 1
0 1 So, mark (g,a) also.
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
(g,a)
g
(g,a)
h
(a,e)
a b c d e f g
13
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
3. For each unmarked
pair & symbol, … f
(g,a)
h
(a,e)
a b c d e f g
14
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
4. Coalesce unmarked
pairs of states. f
0 1
0 1 g
ae ae bh c
1 0
bh 0
df 1 h
df g (a,e)
1
0 a b c d e f g
15
DFA Minimization: Example
0 1
0 1 0
a b c d b
1 0 1
0 1
1 1 0
e f g h c
1 0
0
d
e
5. Delete unreachable
states. f
0 1
0 1 g
ae bh c
1 0
None. 0
1 h
df g (a,e)
1
0 a b c d e f g
16
DFA Minimization: Notes
17
DFA Minimization: Correctness
18
What About NFA Minimization?
?
Is there a (not necessarily unique) minimal NFA?
? Of course.
19
NFA Minimization
0 0
20