Warning: session_start(): open(/var/lib/php/sessions/sess_pru4rasia0u0r51909jgl3gfp5, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass LogicRuleApplier {
BasicLogicRule rule;
O fact;
// define what a variable is
swappable bool isVar(O o) { ret o instanceof S && isDollarVar(o/S); }
// where does your output go
swappable void addRewrittenRHS(O rhs, O trail) {
print("Derived: " + rhs);
}
// use standard deep-zip & replace utils
swappable Map deepZip(O a, O b) { ret newGazelle_deepZip1(a, b); }
swapapble O replaceVars(O o, Map map) { ret replaceVars_understandsTransformableAndList(o, map); }
run {
// now we match the fact to our condition
Map map = deepZip(rule.lhs, fact);
// Discard unless all keys are variables
if (map != null && !all(keys(map), s -> isVar(s))) map = null;
if (map == null)
ret with if (printNonMatches) print("Non-match: " + quote(cond) + " / " + quote(fact));
// Now we have a proper mapping with the keys being variables!
if (verbose) print("Match: " + quote(cond) + " / " + quote(fact));
// Apply mapping to right hand side
O rhs_replaced = replaceVars(rule.rhs, map);
if (verbose) print(+rhs_replaced);
Map trail = litorderedmap(op := "applyLogicRuleToFact",
+rule, +fact, +rhs_replaced);
addRewrittenRHS(rhs_replaced, trail);
}
}