Search in sources :

Example 16 with RuleSet

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);
}
Also used : RuleSet(suite.lp.kb.RuleSet) Specializer(suite.lp.doer.Specializer) Node(suite.node.Node) Test(org.junit.Test)

Example 17 with RuleSet

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);
}
Also used : RuleSet(suite.lp.kb.RuleSet) Node(suite.node.Node) Test(org.junit.Test)

Example 18 with RuleSet

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 ()");
}
Also used : RuleSet(suite.lp.kb.RuleSet) Builder(suite.lp.search.ProverBuilder.Builder) CompiledProverBuilder(suite.lp.search.CompiledProverBuilder) ProverConfig(suite.lp.Configuration.ProverConfig) Test(org.junit.Test)

Example 19 with RuleSet

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());
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 20 with RuleSet

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"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Aggregations

RuleSet (suite.lp.kb.RuleSet)34 Test (org.junit.Test)25 ProverConfig (suite.lp.Configuration.ProverConfig)12 Node (suite.node.Node)9 ProverFactory (suite.lp.doer.ProverFactory)7 Builder (suite.lp.search.ProverBuilder.Builder)7 SewingProverImpl (suite.lp.sewing.impl.SewingProverImpl)7 Finder (suite.lp.search.ProverBuilder.Finder)6 Fun (suite.util.FunUtil.Fun)4 CompiledProverBuilder (suite.lp.search.CompiledProverBuilder)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Suite (suite.Suite)2 Prove_ (suite.lp.doer.ProverFactory.Prove_)2 Source (suite.util.FunUtil.Source)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Collectors (java.util.stream.Collectors)1 Pattern (suite.BindArrayUtil.Pattern)1