use of suite.lp.Configuration.ProverCfg in project suite by stupidsing.
the class CompileProverImpl method prover.
@Override
public Prove_ prover(Node node) {
var rt = f.input();
Fun<FunExpr, ProveRt> cf = cps -> FunCreator.of(ProveRt.class, false).create(rt_ -> cps).apply(Map.ofEntries());
var compiled = new Object() {
private FunExpr compile_(Node node, FunExpr cps) {
return new //
SwitchNode<FunExpr>(//
node).matchArray(".0, .1", m -> {
return compile_(m[0], compile_(m[1], cps));
}).matchArray(".0; .1", m -> {
FunExpr cps1;
if (Boolean.TRUE) {
var proveRt_ = cf.apply(cps);
cps1 = f.object(proveRt_).invoke("test", rt);
} else
cps1 = cps;
FunExpr f0 = compile_(m[0], cps1);
FunExpr f1 = compile_(m[1], cps1);
return f.seq(f0, f1);
}).matchArray("fail", m -> {
return f._void();
}).matchArray("yes", m -> {
return cps;
}).nonNullResult();
}
}.compile_(node, rt.fieldSet("ok", ok));
var proveRt = cf.apply(compiled);
return proverCfg -> {
var rt_ = new Runtime_();
rt_.proverCfg = proverCfg;
proveRt.test(rt_);
return rt_.ok;
};
}
use of suite.lp.Configuration.ProverCfg in project suite by stupidsing.
the class ProverTest method test.
private boolean test(RuleSet rs, String lp) {
var pc = new ProverCfg();
var b0 = Suite.proveLogic(new InterpretedProverBuilder(pc), rs, lp);
var b1 = Suite.proveLogic(new SewingProverBuilder2(pc), rs, lp);
if (b0 == b1)
return b0;
else
return fail("different prove result");
}
use of suite.lp.Configuration.ProverCfg in project suite by stupidsing.
the class SldResolution method resolve.
public List<Node> resolve(Node node) {
var ruleSet = Suite.newRuleSet(List.of("auto.sl", "pt.sl"));
var builder = CompiledProverBuilder.level1(new ProverCfg());
var finder = builder.build(ruleSet).apply(Suite.parse(//
"" + //
"source .n0" + //
", pt-prove0 .n0 .n1" + //
", pt-prove1 .n1 .n2" + //
", pt-prove2 .n2 .n3" + //
", pt-prove3 .n3 .n4" + //
", pt-prove4 .n4 .n5" + //
", pt-prove5 .n5 ()/.n6" + ", sink .n6"));
var n0 = finder.collectSingle(node);
var orsMap = new HashMap<Node, Source<List<Node>>>();
for (var n1 : Tree.read(n0)) {
var ors = Tree.read(n1).toList();
for (var index = 0; index < ors.size(); index++) {
var i = index;
orsMap.put(ors.get(i), () -> Concat.lists(ors.subList(0, i), ors.subList(i + 1, ors.size())));
}
}
var results = new ArrayList<Node>();
for (var e : orsMap.entrySet()) {
var value0 = e.getValue();
var value1 = orsMap.get(negate(e.getKey()));
if (value1 != null)
results.add(TreeUtil.buildUp(BaseOp.AND___, Concat.lists(value0.g(), value1.g())));
}
return results;
}
use of suite.lp.Configuration.ProverCfg in project suite by stupidsing.
the class InterpretedProverBuilder method build.
@Override
public Fun<Node, Finder> build(RuleSet ruleSet) {
return goal -> {
var goal1 = SewingGeneralizerImpl.generalize(goal);
return (source, sink) -> {
var proverCfg1 = new ProverCfg(ruleSet, proverCfg);
proverCfg1.setSource(source);
proverCfg1.setSink(sink);
new Prover(proverCfg1).elaborate(goal1);
};
};
}
Aggregations