sclass NLLogicChecker_v1 { S input; new L facts; sclass Matching { SS matches; // var -> match new L output; } bool checkRule(IfThen rule, Matching m) { if (rule == null) false; if (!checkExpression(rule.in, m)) false; m.output.add(rule.out); true; } bool checkExpression(Exp e, Matching m) { if (e cast And) ret checkExpression(e.a, m) && checkExpression(e.b, m); if (e cast Func) { if (eq(e.name, "input")) ret match(join(((Sentence) e.arg).tok), input); else if (eq(e.name, "fact")) { S pat = join(((Sentence) e.arg).tok); for (S fact : facts) if (match(pat, fact)) true; } } false; } }