Search in sources :

Example 21 with RuleSet

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

the class ProverTest method testLet.

@Test
public void testLet() {
    RuleSet rs = Suite.newRuleSet();
    assertTrue(test(rs, "let 7 (2 * 3 + 1)"));
    assertFalse(test(rs, "let 7 (2 * 3 - 1)"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 22 with RuleSet

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

the class ProverTest method testIsCyclic.

@Test
public void testIsCyclic() {
    RuleSet rs = Suite.newRuleSet();
    assertFalse(test(rs, ".a = (a, b, c,), is.cyclic .a"));
    assertTrue(test(rs, ".a = (a, b, .a, c,), is.cyclic .a"));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Test(org.junit.Test)

Example 23 with RuleSet

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

the class ProverTest method testSystemPredicates.

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

Example 24 with RuleSet

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

the class SewingProverTest method testIf.

@Test
public void testIf() {
    RuleSet rs = Suite.newRuleSet();
    ProverFactory sp = new SewingProverImpl(rs);
    ProverConfig pc = new ProverConfig(rs);
    assertTrue(sp.prover(Suite.parse("if () () fail")).test(pc));
    assertFalse(sp.prover(Suite.parse("if () fail ()")).test(pc));
    assertTrue(sp.prover(Suite.parse("if fail fail ()")).test(pc));
    assertFalse(sp.prover(Suite.parse("if fail () fail")).test(pc));
}
Also used : RuleSet(suite.lp.kb.RuleSet) ProverConfig(suite.lp.Configuration.ProverConfig) ProverFactory(suite.lp.doer.ProverFactory) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl) Test(org.junit.Test)

Example 25 with RuleSet

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

the class SewingProverTest method test.

@Test
public void test() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "yes");
    ProverFactory sp = new SewingProverImpl(rs);
    ProverConfig pc = new ProverConfig(rs);
    assertTrue(sp.prover(Suite.parse("yes")).test(pc));
    assertTrue(sp.prover(Suite.parse("fail; yes")).test(pc));
    assertTrue(sp.prover(Suite.parse("yes; yes")).test(pc));
    assertFalse(sp.prover(Suite.parse("yes, fail")).test(pc));
    assertFalse(sp.prover(Suite.parse("!, fail; yes")).test(pc));
    assertTrue(sp.prover(new Generalizer().generalize(Suite.parse("(.v = 1; .v = 2), .v = 2"))).test(pc));
    assertFalse(sp.prover(new Generalizer().generalize(Suite.parse("once (.v = 1; .v = 2), .v = 2"))).test(pc));
    assertFalse(sp.prover(Suite.parse("not yes")).test(pc));
    assertTrue(sp.prover(Suite.parse("not fail")).test(pc));
    assertTrue(sp.prover(new Generalizer().generalize(Suite.parse(".p = yes, .p"))).test(pc));
}
Also used : RuleSet(suite.lp.kb.RuleSet) Generalizer(suite.lp.doer.Generalizer) ProverConfig(suite.lp.Configuration.ProverConfig) ProverFactory(suite.lp.doer.ProverFactory) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl) 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