use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class ProverTest method testAppend.
@Test
public void testAppend() {
RuleSet rs = Suite.newRuleSet();
Suite.addRule(rs, "app () .l .l");
Suite.addRule(rs, "app (.h, .r) .l (.h, .r1) :- app .r .l .r1");
assertTrue(test(rs, "app (a, b, c,) (d, e,) (a, b, c, d, e,)"));
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class ProverTest method testTree.
@Test
public void testTree() {
RuleSet rs = Suite.newRuleSet();
assertFalse(test(rs, "tree .t0 a ':' b, tree .t1 a ':' b, same .t0 .t1"));
assertTrue(test(rs, "intern.tree .t0 a ':' b, intern.tree .t1 a ':' b, same .t0 .t1"));
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class RbTreeTest method test.
@Test
public void test() throws IOException {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl", "rbt.sl"));
String gs = //
"" + //
"rbt-insert-list (6, 7, 8, 9, 10, 1, 2, 3, 4, 5,) ()/.t \n" + //
", rbt-get .t 8" + ", rbt-member .t 4";
for (Builder builder : List.of(new InterpretedProverBuilder(), new SewingProverBuilder2())) assertTrue(Suite.proveLogic(builder, rs, gs));
}
use of suite.lp.kb.RuleSet 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.kb.RuleSet 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