use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class LogicCompilerLevel1Test method testCompileFunProgram.
/**
* Compiles the functional compiler and use it to compile a simple functional
* program.
*/
@Test
public void testCompileFunProgram() {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl", "fc/fc.sl"));
String gs = //
"" + //
"source .in" + //
", compile-function .0 .in .out" + ", sink .out";
Node goal = new Specializer().specialize(Suite.substitute(gs, Atom.of("LAZY")));
Node input = Suite.parse("1 + 2");
Node result = FindUtil.collectSingle(finder(rs, goal), input);
System.out.println(result);
assertNotNull(result);
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class LogicCompilerLevel1Test method testTailCalls.
/**
* This test might fail in some poor tail recursion optimization
* implementations, as some variables are not unbounded when backtracking.
*/
@Test
public void testTailCalls() {
RuleSet rs = Suite.newRuleSet();
Suite.addRule(rs, "ab a");
Suite.addRule(rs, "ab b");
Node goal = Suite.parse("ab .a, ab .b, sink (.a, .b,)");
List<Node> results = FindUtil.collectList(finder(rs, goal), Atom.NIL);
System.out.println(results);
assertTrue(results.size() == 4);
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class LogicCompilerLevel2Test method test1.
@Test
public void test1() throws IOException {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl"));
Builder builder = CompiledProverBuilder.level2(new ProverConfig());
Suite.evaluateLogic(builder, rs, "(), sink ()");
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class ImportTest method testImportFunCompiler.
@Test
public void testImportFunCompiler() throws IOException {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl", "fc/fc.sl"));
System.out.println(rs.getRules().size());
}
use of suite.lp.kb.RuleSet in project suite by stupidsing.
the class ProverTest method testWrite.
@Test
public void testWrite() {
RuleSet rs = Suite.newRuleSet();
assertTrue(test(rs, "write (1 + 2 * 3), nl"));
assertTrue(test(rs, "write \"Don\"\"t forget%0A4 Jun 1989\", nl"));
}
Aggregations