Search in sources :

Example 1 with Prove_

use of suite.lp.doer.ProverFactory.Prove_ in project suite by stupidsing.

the class SewingProverBuilder method build.

@Override
public Fun<Node, Finder> build(RuleSet ruleSet) {
    ProverFactory sewingProver = new SewingProverImpl(ruleSet);
    return goal -> {
        Node goal1 = SewingGeneralizerImpl.generalize(goal);
        Prove_ pred = sewingProver.prover(goal1);
        return (source, sink) -> {
            ProverConfig proverConfig1 = new ProverConfig(ruleSet, proverConfig);
            proverConfig1.setSource(source);
            proverConfig1.setSink(sink);
            pred.test(proverConfig1);
        };
    };
}
Also used : SewingGeneralizerImpl(suite.lp.sewing.impl.SewingGeneralizerImpl) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl) Finder(suite.lp.search.ProverBuilder.Finder) ProverFactory(suite.lp.doer.ProverFactory) Builder(suite.lp.search.ProverBuilder.Builder) Prove_(suite.lp.doer.ProverFactory.Prove_) RuleSet(suite.lp.kb.RuleSet) Fun(suite.util.FunUtil.Fun) ProverConfig(suite.lp.Configuration.ProverConfig) Node(suite.node.Node) Node(suite.node.Node) ProverConfig(suite.lp.Configuration.ProverConfig) Prove_(suite.lp.doer.ProverFactory.Prove_) ProverFactory(suite.lp.doer.ProverFactory) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl)

Example 2 with Prove_

use of suite.lp.doer.ProverFactory.Prove_ in project suite by stupidsing.

the class SewingProverTest method testPerformance.

@Test
public void testPerformance() {
    RuleSet rs = Suite.newRuleSet();
    Atom pred = Atom.of("q");
    Atom tail = Atom.NIL;
    for (int i = 0; i < 65536; i++) rs.addRule(Rule.of(Tree.of(TermOp.IS____, Tree.of(TermOp.TUPLE_, pred, Int.of(i)), tail)));
    ProverFactory sp = new SewingProverImpl(rs);
    ProverConfig pc = new ProverConfig(rs);
    Prove_ test = sp.prover(Suite.parse("q 32768"));
    Source<Stopwatch<Boolean>> trial = () -> Stopwatch.of(() -> {
        boolean isOk = true;
        for (int i = 0; i < 65536; i++) isOk &= test.test(pc);
        assertTrue(isOk);
        return isOk;
    });
    for (int i = 0; i < 8; i++) trial.source();
    Stopwatch<Boolean> sw = trial.source();
    System.out.println(sw.duration);
    assertTrue(sw.duration < 300);
}
Also used : RuleSet(suite.lp.kb.RuleSet) ProverConfig(suite.lp.Configuration.ProverConfig) Stopwatch(suite.os.Stopwatch) Prove_(suite.lp.doer.ProverFactory.Prove_) Atom(suite.node.Atom) ProverFactory(suite.lp.doer.ProverFactory) SewingProverImpl(suite.lp.sewing.impl.SewingProverImpl) Test(org.junit.Test)

Example 3 with Prove_

use of suite.lp.doer.ProverFactory.Prove_ 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)

Aggregations

ProverConfig (suite.lp.Configuration.ProverConfig)3 Prove_ (suite.lp.doer.ProverFactory.Prove_)3 SewingProverImpl (suite.lp.sewing.impl.SewingProverImpl)3 ProverFactory (suite.lp.doer.ProverFactory)2 RuleSet (suite.lp.kb.RuleSet)2 Test (org.junit.Test)1 CompileProverImpl (suite.lp.compile.impl.CompileProverImpl)1 Builder (suite.lp.search.ProverBuilder.Builder)1 Finder (suite.lp.search.ProverBuilder.Finder)1 SewingGeneralizerImpl (suite.lp.sewing.impl.SewingGeneralizerImpl)1 Atom (suite.node.Atom)1 Node (suite.node.Node)1 Stopwatch (suite.os.Stopwatch)1 Fun (suite.util.FunUtil.Fun)1