Search in sources :

Example 6 with SewingProverImpl

use of suite.lp.sewing.impl.SewingProverImpl 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 7 with SewingProverImpl

use of suite.lp.sewing.impl.SewingProverImpl 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)

Example 8 with SewingProverImpl

use of suite.lp.sewing.impl.SewingProverImpl in project suite by stupidsing.

the class SewingProverTest method testCut.

@Test
public void testCut() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "a :- b");
    Suite.addRule(rs, "a");
    Suite.addRule(rs, "b :- !, fail");
    ProverFactory sp = new SewingProverImpl(rs);
    ProverConfig pc = new ProverConfig(rs);
    assertTrue(sp.prover(Suite.parse("a")).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 9 with SewingProverImpl

use of suite.lp.sewing.impl.SewingProverImpl in project suite by stupidsing.

the class SewingProverTest method testEnv.

@Test
public void testEnv() {
    RuleSet rs = Suite.newRuleSet();
    Suite.addRule(rs, "a :- b .a, b .b");
    Suite.addRule(rs, "b 1");
    ProverFactory sp = new SewingProverImpl(rs);
    ProverConfig pc = new ProverConfig(rs);
    assertTrue(sp.prover(Suite.parse("a")).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)

Aggregations

ProverConfig (suite.lp.Configuration.ProverConfig)9 SewingProverImpl (suite.lp.sewing.impl.SewingProverImpl)9 ProverFactory (suite.lp.doer.ProverFactory)7 RuleSet (suite.lp.kb.RuleSet)7 Test (org.junit.Test)6 Prove_ (suite.lp.doer.ProverFactory.Prove_)3 Generalizer (suite.lp.doer.Generalizer)2 Node (suite.node.Node)2 PrintWriter (java.io.PrintWriter)1 InterpretFunEager (suite.fp.InterpretFunEager)1 InterpretFunLazy (suite.fp.InterpretFunLazy)1 InterpretFunLazy0 (suite.fp.InterpretFunLazy0)1 CompileProverImpl (suite.lp.compile.impl.CompileProverImpl)1 Prover (suite.lp.doer.Prover)1 InterpretedProverBuilder (suite.lp.search.InterpretedProverBuilder)1 Builder (suite.lp.search.ProverBuilder.Builder)1 Finder (suite.lp.search.ProverBuilder.Finder)1 SewingProverBuilder (suite.lp.search.SewingProverBuilder)1 SewingGeneralizerImpl (suite.lp.sewing.impl.SewingGeneralizerImpl)1 Atom (suite.node.Atom)1