use of suite.lp.Configuration.ProverConfig 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));
}
use of suite.lp.Configuration.ProverConfig 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));
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class SldResolution method resolve.
public List<Node> resolve(Node node) {
RuleSet ruleSet = Suite.newRuleSet(List.of("auto.sl", "pt.sl"));
CompiledProverBuilder builder = CompiledProverBuilder.level1(new ProverConfig());
Finder 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"));
Node n0 = FindUtil.collectSingle(finder, node);
Map<Node, Source<List<Node>>> orsMap = new HashMap<>();
for (Node n1 : Tree.iter(n0, TermOp.AND___)) {
List<Node> ors = To.list(Tree.iter(n1, TermOp.AND___));
for (int i = 0; i < ors.size(); i++) {
int index = i;
orsMap.put(ors.get(index), () -> List_.concat(ors.subList(0, index), ors.subList(index + 1, ors.size())));
}
}
List<Node> results = new ArrayList<>();
for (Entry<Node, Source<List<Node>>> e : orsMap.entrySet()) {
Source<List<Node>> value0 = e.getValue();
Source<List<Node>> value1 = orsMap.get(negate(e.getKey()));
if (value1 != null)
results.add(Tree.of(TermOp.AND___, List_.concat(value0.source(), value1.source())));
}
return results;
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class NodifyTest method testMapify.
@Test
public void testMapify() {
ProverConfig pc0 = new ProverConfig();
pc0.setRuleSet(null);
Node node = nodify.nodify(ProverConfig.class, pc0);
assertNotNull(node);
System.out.println(node);
ProverConfig pc1 = nodify.unnodify(ProverConfig.class, node);
System.out.println(pc1);
assertEquals(pc0, pc1);
assertTrue(pc0.hashCode() == pc1.hashCode());
}
use of suite.lp.Configuration.ProverConfig in project suite by stupidsing.
the class CompiledProverBuilder method build.
@Override
public Fun<Node, Finder> build(RuleSet ruleSet) {
Node rules = Suite.getRules(ruleSet);
return goal -> {
Node code = compile(Suite.substitute(".0 >> .1", rules, goal));
return (source, sink) -> {
ProverConfig proverConfig1 = new ProverConfig(ruleSet, proverConfig);
proverConfig1.setSource(source);
proverConfig1.setSink(sink);
try (InstructionExecutor executor = new LogicInstructionExecutor(code, proverConfig1)) {
executor.execute();
}
};
};
}
Aggregations