Warning: session_start(): open(/var/lib/php/sessions/sess_sprmo82hq1s41t808jdjhjj65u, 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 NewEngine implements Steppable {
replace LogicRule with BasicLogicRule.
transient new Map facts; // facts to trail
transient AllOnAllWithOperation rulesAndFacts = new(lambda2 applyLogicRuleToFact);
new DeepZipTools tools;
bool verbose = true, printNonMatches;
public bool step() { ret rulesAndFacts.step(); }
void addLogicRule(LogicRule rule) {
if (verbose) print("New rule: " + rule);
rulesAndFacts.newA(rule);
}
void addFact(O fact) { addFact(fact, "external"); }
void addFact(O fact, O trail) {
if (trail == null) trail = "unknown";
if (facts.put(fact, trail) != null) ret;
if (verbose) print("New fact: " + fact);
rulesAndFacts.newB(fact);
}
void addFormattedFact(S starPattern, O... args) {
addFact(formatWithFragments(starPattern, args));
}
L factsInOrderOfDefinition() { ret rulesAndFacts.cloneBList(); }
void run {
stepAll(this);
print("done. " + nFacts(rulesAndFacts.bList) + ", " + nRules(rulesAndFacts.aList));
}
void think { run(); }
void applyLogicRuleToFact(LogicRule rule, O fact) {
new LogicRuleApplier ap;
ap.rule = rule;
ap.fact = fact;
ap.verbose = verbose;
ap.printNonMatches = printNonMatches;
ap.addRewrittenRHS = lambda2 addRewrittenRHS;
ap.tools = tools;
ap.run();
}
void addRewrittenRHS(O o, O trail) {
if (o cast LogicRule) {
o.trail = trail;
addLogicRule(o);
} else if o is And(O a, O b) {
addRewrittenRHS(a, o);
addRewrittenRHS(b, o);
} else if (o != null)
addFact(o, trail);
}
}