Professional Documents
Culture Documents
Unique?
A minimal DFA for a given language is unique up to renaming of states.
p
q
z or z
p
q
z z
Build table to compare each unordered pair of distinct states p,q. Each table entry has
a mark as to whether p & q are known to be not equivalent, and a list of entries, recording dependences: If this entry is later marked, also mark these.
1.
Initialize all entries as unmarked & with no dependences. Mark all pairs of a final & nonfinal state. For each unmarked pair p,q & input symbol a:
1. 2. 3.
2.
3.
Let r=(p,a), s=(q,a). If (r,s) unmarked, add (p,q) to (r,s)s dependences, Otherwise mark (p,q), and recursively mark all dependences of newly-marked entries.
4.
5.
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b c d e
5
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b c d e
6
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b
g ? b c ? f
Maybe. No!
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b c d e
9
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a b
10
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a
(a,e)
h ? b f ? f
Maybe. Yes.
11
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a
(g,a) (a,e) (g,a)
12
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a
(g,a) (a,e)
(g,a)
13
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a
(a,e) (g,a)
14
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e
f g h a
(a,e)
ae bh df
ae
0 1 1
bh
0
c g
df
15
a
e
0 1 1
b
f
1
c
g
0 1 0 1
d
h
b
c d e f g h a
(a,e)
None.
ae
0 1 1
bh
0
c g
df
16
Order of selecting state pairs was arbitrary, but all orders give the same result. Can delete unreachable states initially, instead. This algorithm: O(n2) time; Huffman (1954), Moore (1956).
Constant work per entry: initial mark test & possibly later chasing of its dependences. More efficient algorithms exist, e.g., Hopcroft (1971).
Of course.
NFA Minimization
20