!7
/*
Event 1 happens before event 2 :=
vars {event 1, event 2, X, Y}
Event 1 happens at day X.
Event 2 happens at day Y.
X < Y.
*/
sclass Obj {
class Fact implements IStatement {}
replace Var with ValuelessVar.
record $HappensBefore$(A event1, B event2) extends Fact {}
record $HappensAtDay$(A event, B y) extends Fact {}
record $LessThan$(A x, A y) extends Fact {}
record StatementsWithVars(Set vars, L statements) {
*(Fact... statements) {
this.statements = asList(statements);
collectVars();
}
void collectVars {
vars = new Set;
fOr (Fact f : statements)
vars.addAll(print("Vars", findVars(f)));
}
}
L findVars(O o) { ret ai_findVarObjects Var(o); }
bool matchIndividual(O a, O b, Map map) {
if (a cast Var)
ret strictPut(map, a, b);
else
ret eq(a, b);
}
Map matchFacts(Fact f1, Fact f2) {
if (f1 == null || f2 == null) null;
if (f1.getClass() != f2.getClass()) null;
L fields = nonStaticNonTransientFieldObjects(f1);
new Map map;
for (Field f : fields)
if (!matchIndividual(fieldGet(f, f1), fieldGet(f, f2), map))
null;
ret map;
}
void recSolve(L facts, L statements, Map map, IVF1