use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class SewingProverBuilder method build.
@Override
public Fun<Node, Finder> build(RuleSet ruleSet) {
ProverFactory sewingProver = new SewingProverImpl(ruleSet);
return goal -> {
Node goal1 = SewingGeneralizerImpl.generalize(goal);
Prove_ pred = sewingProver.prover(goal1);
return (source, sink) -> {
ProverConfig proverConfig1 = new ProverConfig(ruleSet, proverConfig);
proverConfig1.setSource(source);
proverConfig1.setSink(sink);
pred.test(proverConfig1);
};
};
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class SewingProverBuilder2 method build.
@Override
public Fun<Node, Finder> build(RuleSet ruleSet) {
boolean isRewrite = !proverConfig.isTrace();
QueryRewriter qr = isRewrite ? new QueryRewriter(Prototype.multimap(ruleSet)) : null;
RuleSet ruleSet1;
if (qr != null) {
ruleSet1 = Suite.newRuleSet();
qr.rules().entries().forEach(p -> ruleSet1.addRule(p.t1));
} else
ruleSet1 = ruleSet;
Fun<Node, Finder> fun = new SewingProverBuilder(proverConfig).build(ruleSet1);
if (qr != null)
return goal -> fun.apply(qr.rewriteClause(goal));
else
return fun;
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class FailedTests method testRepeat.
// (Expected) infinite loop.
// (Actual) short boolean evaluation in Prover skipped the loop:
// alt = andTree(bt, orTree(andTree(right, rem), alt));
@Test
public void testRepeat() throws IOException {
RuleSet rs = Suite.newRuleSet();
Suite.importPath(rs, "auto.sl");
assertTrue(Suite.proveLogic(rs, "repeat, fail"));
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class LogicCompilerLevel1Test method testMemberOfMember.
@Test
public void testMemberOfMember() {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl"));
Node goal = Suite.parse("source .lln, member .lln .ln, member .ln .n, sink .n");
Node input = Suite.parse("((1, 2,), (3, 4,),)");
List<Node> results = FindUtil.collectList(finder(rs, goal), input);
System.out.println(results);
assertTrue(results.size() == 4);
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class LogicCompilerLevel2Test method test0.
// require tail recursion to work
@Test
public void test0() {
RuleSet rs = Suite.getRuleSet(Suite.parse(//
"" + //
"member (.e, _) .e #" + //
"member (_, .tail) .e :- member .tail .e #" + //
"sum .a .b .c :- bound .a, bound .b, let .c (.a - .b) #" + //
"sum .a .b .c :- bound .a, bound .c, let .b (.a - .c) #" + //
"sum .a .b .c :- bound .b, bound .c, let .a (.b + .c) #"));
Builder builder = CompiledProverBuilder.level2(new ProverConfig());
Suite.evaluateLogic(builder, rs, "(), sink ()");
}
Aggregations