use of suite.lp.Configuration.ProverConfig 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.Configuration.ProverConfig 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 ()");
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class ProverTest method test.
private boolean test(RuleSet rs, String lp) {
ProverConfig pc = new ProverConfig();
boolean b0 = Suite.proveLogic(new InterpretedProverBuilder(pc), rs, lp);
boolean b1 = Suite.proveLogic(new SewingProverBuilder2(pc), rs, lp);
if (b0 == b1)
return b0;
else
return Fail.t("different prove result");
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class SewingProverTest method testPerformance.
@Test
public void testPerformance() {
RuleSet rs = Suite.newRuleSet();
Atom pred = Atom.of("q");
Atom tail = Atom.NIL;
for (int i = 0; i < 65536; i++) rs.addRule(Rule.of(Tree.of(TermOp.IS____, Tree.of(TermOp.TUPLE_, pred, Int.of(i)), tail)));
ProverFactory sp = new SewingProverImpl(rs);
ProverConfig pc = new ProverConfig(rs);
Prove_ test = sp.prover(Suite.parse("q 32768"));
Source<Stopwatch<Boolean>> trial = () -> Stopwatch.of(() -> {
boolean isOk = true;
for (int i = 0; i < 65536; i++) isOk &= test.test(pc);
assertTrue(isOk);
return isOk;
});
for (int i = 0; i < 8; i++) trial.source();
Stopwatch<Boolean> sw = trial.source();
System.out.println(sw.duration);
assertTrue(sw.duration < 300);
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class SewingProverTest method testBacktrack.
@Test
public void testBacktrack() {
RuleSet rs = Suite.newRuleSet();
Suite.addRule(rs, "mem (.e, _) .e");
Suite.addRule(rs, "mem (_, .tail) .e :- mem .tail .e");
Suite.addRule(rs, "q .c .v :- once (mem (0,) .v), .a/.b/.c = 0/0/0; mem (1,) .v, .a/.b/.c = 1/1/1");
Suite.addRule(rs, "r .c :- q .c .v, .v = 1");
ProverFactory sp = new SewingProverImpl(rs);
ProverConfig pc = new ProverConfig(rs);
assertTrue(sp.prover(new Generalizer().generalize(Suite.parse("r .c"))).test(pc));
}
Aggregations