@@ -17,15 +17,19 @@ import qualified Data.IntMap as IM
17
17
import qualified Data.List as List
18
18
19
19
-- Hopcroft's Algorithm for DFA minimization (cut/pasted from Wikipedia):
20
-
20
+ -- X refines Y into Y1 and Y2 means
21
+ -- Y1 := Y ∩ X
22
+ -- Y2 := Y \ X
23
+ -- where both Y1 and Y2 is nonempty
24
+ --
21
25
-- P := {{all accepting states}, {all nonaccepting states}};
22
26
-- Q := {{all accepting states}};
23
27
-- while (Q is not empty) do
24
28
-- choose and remove a set A from Q
25
29
-- for each c in ∑ do
26
30
-- let X be the set of states for which a transition on c leads to a state in A
27
- -- for each set Y in P for which X ∩ Y is nonempty and Y \ X is nonempty do
28
- -- replace Y in P by the two sets X ∩ Y and Y \ X
31
+ -- for each set Y in P for which X refines Y into Y1 and Y2 do
32
+ -- replace Y in P by the two sets Y1 and Y2
29
33
-- if Y is in Q
30
34
-- replace Y in Q by the same two sets
31
35
-- else
@@ -44,12 +48,12 @@ import qualified Data.List as List
44
48
-- remove A from Q and add it to R
45
49
-- for each c in ∑ do
46
50
-- let X be the set of states for which a transition on c leads to a state in A
47
- -- for each set Y in R for which X ∩ Y is nonempty and Y \ X is nonempty do
48
- -- replace Y in R by the greater of the two sets X ∩ Y and X \ Y
51
+ -- for each set Y in R for which X refines Y into Y1 and Y2 do
52
+ -- replace Y in R by the greater of the two sets Y1 and Y2
49
53
-- add the smaller of the two sets to Q
50
54
-- end;
51
- -- for each set Y in Q for which X ∩ Y is nonempty and Y \ X is nonempty do
52
- -- replace Y in Q by the two sets X ∩ Y and X \ Y
55
+ -- for each set Y in Q for which X refines Y into Y1 and Y2 do
56
+ -- replace Y in Q by the two sets Y1 and Y2
53
57
-- end;
54
58
-- end;
55
59
-- end;
0 commit comments