Search in sources :

Example 6 with RuleSet

use of suite.lp.kb.RuleSet in project suite by stupidsing.

the class ImportTest method testImport.

@Test
public void testImport() throws IOException {
    RuleSet rs = Suite.newRuleSet(List.of("auto.sl"));
    assertTrue(Suite.proveLogic(rs, "list"));
    assertTrue(Suite.proveLogic(rs, "list repeat"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 7 with RuleSet

use of suite.lp.kb.RuleSet in project suite by stupidsing.

the class ProverTest method testCut.

@Test
public void testCut() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "a :- !, fail");
    Suite.addRule(rs, "a");
    Suite.addRule(rs, "yes");
    assertFalse(test(rs, "a"));
    assertFalse(Suite.proveLogic(rs, "cut.begin .c, (nl, cut.end .c, fail; yes)"));
    assertTrue(Suite.proveLogic(rs, "(cut.begin .c, nl, cut.end .c, fail); yes"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 8 with RuleSet

use of suite.lp.kb.RuleSet in project suite by stupidsing.

the class ProverTest method testFindAll.

@Test
public void testFindAll() {
    RuleSet rs = Suite.newRuleSet();
    assertTrue(test(rs, "find.all .v (.v = a; .v = b; .v = c) .results, .results = (a, b, c,)"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 9 with RuleSet

use of suite.lp.kb.RuleSet in project suite by stupidsing.

the class ProverTest method testMember.

@Test
public void testMember() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "mem ((.e, _), .e)");
    Suite.addRule(rs, "mem ((_, .remains), .e) :- mem (.remains, .e)");
    assertTrue(test(rs, "mem ((a, ), a)"));
    assertTrue(test(rs, "mem ((a, b, c, ), .v)"));
    assertTrue(test(rs, ".l = (1, 2, 3,), find.all .v (mem (.l, .v)) .l"));
    assertFalse(test(rs, "mem ((a, b, c, ), d)"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 10 with RuleSet

use of suite.lp.kb.RuleSet in project suite by stupidsing.

the class ProverTest method testProve.

@Test
public void testProve() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "a");
    Suite.addRule(rs, "b");
    Suite.addRule(rs, "c");
    Suite.addRule(rs, "a b .v :- fail");
    Suite.addRule(rs, "a b c");
    Suite.addRule(rs, ".var is a man");
    Suite.addRule(rs, "q :- once (not yes; yes)");
    Suite.addRule(rs, "yes");
    assertTrue(Suite.proveLogic(rs, ""));
    assertTrue(Suite.proveLogic(rs, "a"));
    assertTrue(Suite.proveLogic(rs, "a, b"));
    assertTrue(Suite.proveLogic(rs, "a, b, c"));
    assertTrue(Suite.proveLogic(rs, "a, fail; b"));
    assertTrue(Suite.proveLogic(rs, "a b c"));
    assertTrue(Suite.proveLogic(rs, "abc is a man"));
    assertTrue(Suite.proveLogic(rs, ".v = a, .v = b; .v = c"));
    assertTrue(Suite.proveLogic(rs, "[1, 2, 3] = [1, 2, 3]"));
    assertTrue(Suite.proveLogic(rs, "q"));
    assertFalse(Suite.proveLogic(rs, "fail"));
    assertFalse(Suite.proveLogic(rs, "d"));
    assertFalse(Suite.proveLogic(rs, "a, fail"));
    assertFalse(Suite.proveLogic(rs, "fail, a"));
    assertFalse(Suite.proveLogic(rs, "a b d"));
    assertFalse(Suite.proveLogic(rs, "a = b"));
    assertFalse(Suite.proveLogic(rs, ".v = a, .v = b"));
}
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