Search in sources :

Example 1 with Checker

use of suite.lp.checker.Checker in project suite by stupidsing.

the class ImportUtil method importFrom.

public synchronized boolean importFrom(RuleSet ruleSet, Node node) {
    List<Rule> rules = new ArrayList<>();
    for (Node elem : Tree.iter(node, TermOp.NEXT__)) rules.add(Rule.of(elem));
    Prover prover = new Prover(ruleSet);
    boolean b = true;
    IList<Node> importing0 = importing.get();
    try {
        importing.set(IList.cons(node, importing0));
        for (Rule rule : rules) if (rule.head != Atom.NIL)
            ruleSet.addRule(rule);
        else {
            Node goal = SewingGeneralizerImpl.generalize(rule.tail);
            b &= prover.prove(goal);
        }
    } finally {
        importing.set(importing0);
    }
    if (// check after all files are imported
    importing0.isEmpty())
        new Checker().check(ruleSet.getRules());
    return b;
}
Also used : Checker(suite.lp.checker.Checker) Node(suite.node.Node) ArrayList(java.util.ArrayList) Prover(suite.lp.doer.Prover) Rule(suite.lp.kb.Rule)

Aggregations

ArrayList (java.util.ArrayList)1 Checker (suite.lp.checker.Checker)1 Prover (suite.lp.doer.Prover)1 Rule (suite.lp.kb.Rule)1 Node (suite.node.Node)1