Skip to content

Commit f43d028

Browse files
committed
FIX: toposort will always be buggy ;-)
1 parent 07dced8 commit f43d028

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

HB/common/database.elpi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,18 @@ toposort-proj Proj ES In Out :- !, toposort-proj.acc Proj ES [] In Out.
147147
pred topo-find i:B, o:A.
148148
pred toposort-proj.acc i:(A -> B -> prop), i:list (pair B B), i:list B, i:list A, o:list A.
149149
toposort-proj.acc _ ES Acc [] Out :- !,
150-
std.map {std.toposort ES Acc} topo-find Out.
150+
std.map {std.toposort ES Acc} topo-find-all Out.
151151
toposort-proj.acc Proj ES Acc [A|In] Out :- std.do![
152152
Proj A B,
153153
topo-find B A => toposort-proj.acc Proj ES [B|Acc] In Out
154154
].
155155

156+
pred topo-find-all i:B, o:A.
157+
topo-find-all B A :- std.do! [
158+
std.findall (topo-find B C_) L,
159+
std.assert! (std.forall L (x\ x = topo-find B A)) "topofind bad",
160+
].
161+
156162
% Classes can be topologically sorted according to the subclass relation
157163
pred toposort-classes.mk-class-edge i:prop, o:pair classname classname.
158164
toposort-classes.mk-class-edge (sub-class C1 C2 _ _) (pr C2 C1).

0 commit comments

Comments
 (0)