Skip to content

Commit f1a790c

Browse files
committed
improve docs
1 parent c9bc39a commit f1a790c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/DFAMin.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ import qualified Data.IntMap as IM
1717
import qualified Data.List as List
1818

1919
-- 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+
--
2125
-- P := {{all accepting states}, {all nonaccepting states}};
2226
-- Q := {{all accepting states}};
2327
-- while (Q is not empty) do
2428
-- choose and remove a set A from Q
2529
-- for each c in ∑ do
2630
-- 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
2933
-- if Y is in Q
3034
-- replace Y in Q by the same two sets
3135
-- else
@@ -44,12 +48,12 @@ import qualified Data.List as List
4448
-- remove A from Q and add it to R
4549
-- for each c in ∑ do
4650
-- 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
4953
-- add the smaller of the two sets to Q
5054
-- 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
5357
-- end;
5458
-- end;
5559
-- end;

0 commit comments

Comments
 (0)