!7 replace Var with ValuelessVar. replace VarMap with Map. abstract sclass Prop implements IStatement, IFieldsToList {} static withToList record Did$HappenBefore$(A event1, B event2) {} static withToList record WhenDid$Happen(O event) extends Prop {} static withToList record $HappensAtSecond$(A event, B y) extends Prop {} static withToList record $LessThan$(A x, B y) extends Prop {} static withToList record $BiggerThanOrEqualTo$(A x, B y) extends Prop {} static withToList record $AnyIntBiggerThan(O x) {} static withToList record $is$(O a, O b) {} sclass SimpleStatements { new L statements; *() {} *(Prop... statements) { addAll(this.statements, statements); } O fulfill(IF1 makeRecord) { new Var var; O result = null; Prop record = makeRecord.get(var); O[] a = record._fieldsToList(); bigLoop: for (Prop prop : statements) { if (prop.getClass() != record.getClass()) continue; O[] b = prop._fieldsToList(); if (b.length != a.length) fail("Bad argument length: " + record); for i over a: if (a[i] == var) { if (result != null && !eq(result, b[i])) continue bigLoop; result = b[i]; } else if (!eq(a[i], b[i])) continue bigLoop; ret result; } null; } } static O answer(O p, SimpleStatements statements) { if p is WhenDid$Happen(O event) { ret statements.fulfill(var -> $HappensAtSecond$(event, var)); } if p is Did$HappenBefore$(O event1, O event2) { Int time1 = optCast int(statements.fulfill(var -> $HappensAtSecond$(event1, var))); if (time1 == null) null; } null; } // full define $LessThan(int x, int y) = x < y; static Bool checkProposition(Prop p) { if p is $LessThan$(int x, int y) { ret x < y; } if p is $BiggerThanOrEqualTo$(int x, int y) { ret not(checkProposition($LessThan$(x, y))); } null; } p-exp { SimpleStatements statements = new($HappensAtSecond$("stuff", 10)); print(answer(print(WhenDid$Happen("stuff")), statements)); }