Search in sources :

Example 1 with SewingGeneralizerImpl

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

the class Rule method newClause.

public synchronized Node newClause(Node query, Node cut) {
    if (sewingGeneralizer == null) {
        sewingGeneralizer = new SewingGeneralizerImpl();
        headFun = sewingGeneralizer.generalizer(head);
        tailFun = sewingGeneralizer.generalizer(tail);
        cutIndex = sewingGeneralizer.mapper().computeIndex(ProverConstant.cut);
    }
    Env env = sewingGeneralizer.mapper().env();
    env.refs[cutIndex].bound(cut);
    return // 
    Tree.of(// 
    TermOp.AND___, // 
    Tree.of(// 
    TermOp.EQUAL_, // 
    query, // 
    headFun.apply(env)), tailFun.apply(env));
}
Also used : Env(suite.lp.sewing.Env) SewingGeneralizerImpl(suite.lp.sewing.impl.SewingGeneralizerImpl)

Example 2 with SewingGeneralizerImpl

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

the class GeneralizerFactoryTest method test.

private void test(String pattern, String match) {
    for (GeneralizerFactory gf : new GeneralizerFactory[] { new CompileGeneralizerImpl(), new SewingGeneralizerImpl() }) {
        Generalize_ p = gf.generalizer(Suite.parse(pattern));
        assertTrue(Binder.bind(p.apply(gf.mapper().env()), Suite.parse(match), new Trail()));
    }
}
Also used : CompileGeneralizerImpl(suite.lp.compile.impl.CompileGeneralizerImpl) Trail(suite.lp.Trail) Generalize_(suite.lp.doer.GeneralizerFactory.Generalize_) SewingGeneralizerImpl(suite.lp.sewing.impl.SewingGeneralizerImpl)

Aggregations

SewingGeneralizerImpl (suite.lp.sewing.impl.SewingGeneralizerImpl)2 Trail (suite.lp.Trail)1 CompileGeneralizerImpl (suite.lp.compile.impl.CompileGeneralizerImpl)1 Generalize_ (suite.lp.doer.GeneralizerFactory.Generalize_)1 Env (suite.lp.sewing.Env)1