Search in sources :

Example 11 with ProverConfig

use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.

the class MapifyTest method testMapify.

@Test
public void testMapify() {
    ProverConfig pc0 = new ProverConfig();
    pc0.setRuleSet(null);
    Object map = mapify.mapify(ProverConfig.class, pc0);
    assertNotNull(map);
    System.out.println(map);
    ProverConfig pc1 = mapify.unmapify(ProverConfig.class, map);
    System.out.println(pc1);
    assertEquals(pc0, pc1);
    assertTrue(pc0.hashCode() == pc1.hashCode());
}
Also used : ProverConfig(suite.lp.Configuration.ProverConfig) Test(org.junit.Test)

Example 12 with ProverConfig

use of suite.lp.Configuration.ProverConfig 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 13 with ProverConfig

use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.

the class ProverFactoryTest method test.

private void test(String query, boolean result) {
    for (ProverFactory pf : new ProverFactory[] { // 
    new CompileProverImpl(), new SewingProverImpl(Suite.newRuleSet(List.of("auto.sl"))) }) {
        Prove_ p = pf.prover(Suite.parse(query));
        assertEquals(result, p.test(new ProverConfig()));
    }
}
Also used : ProverConfig(suite.lp.Configuration.ProverConfig) CompileProverImpl(suite.lp.compile.impl.CompileProverImpl) Prove_(suite.lp.doer.ProverFactory.Prove_) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl)

Example 14 with ProverConfig

use of suite.lp.Configuration.ProverConfig 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 15 with ProverConfig

use of suite.lp.Configuration.ProverConfig 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

ProverConfig (suite.lp.Configuration.ProverConfig)21 RuleSet (suite.lp.kb.RuleSet)12 Test (org.junit.Test)10 SewingProverImpl (suite.lp.sewing.impl.SewingProverImpl)9 ProverFactory (suite.lp.doer.ProverFactory)8 Node (suite.node.Node)7 Builder (suite.lp.search.ProverBuilder.Builder)5 Finder (suite.lp.search.ProverBuilder.Finder)5 Fun (suite.util.FunUtil.Fun)4 Prove_ (suite.lp.doer.ProverFactory.Prove_)3 CompiledProverBuilder (suite.lp.search.CompiledProverBuilder)3 Generalizer (suite.lp.doer.Generalizer)2 Prover (suite.lp.doer.Prover)2 InterpretedProverBuilder (suite.lp.search.InterpretedProverBuilder)2 SewingGeneralizerImpl (suite.lp.sewing.impl.SewingGeneralizerImpl)2 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1