use of com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive in project aic-expresso by aic-sri-international.
the class ExhaustiveTest method runTest.
private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.registerAdditionalSymbolsAndTypes(symbolsAndTypes);
Rewriter exhaustive = new Exhaustive(rewriter);
Expression solution = exhaustive.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive in project aic-expresso by aic-sri-international.
the class AbstractTheory method makeEvaluatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver makeEvaluatorStepSolver(Expression expression) {
Rewriter literalExternalizer = new LiteralRewriter(new Recursive(new Exhaustive(getTopRewriter())));
Recursive completeEvaluator = new Recursive(new Exhaustive(new FirstOf(getTopRewriter(), literalExternalizer)));
// it is a good idea to leave the literal externalizer at the end,
// since it is expensive due to duplicating the entire problem at every split
ExpressionLiteralSplitterStepSolver result = completeEvaluator.makeStepSolver(expression);
return result;
}
use of com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive in project aic-expresso by aic-sri-international.
the class DifferenceArithmeticTheory method makeEvaluatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver makeEvaluatorStepSolver(Expression expression) {
Rewriter literalExternalizer = new LiteralRewriter(new Recursive(new Exhaustive(getTopRewriter())));
ExpressionLiteralSplitterStepSolver result = new Recursive(new Exhaustive(new FirstOf(getTopRewriter(), literalExternalizer))).makeStepSolver(expression);
return result;
}
use of com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive in project aic-expresso by aic-sri-international.
the class AbstractIterativeMultiIndexQuantifierElimination method solve.
public Expression solve(AssociativeCommutativeGroup group, List<Expression> indices, Expression indicesCondition, Expression body, Context context) {
Expression result = group.additiveIdentityElement();
Expression summand = makeSummand(group, indices, indicesCondition, body, context);
Rewriter rewriter = new Recursive(new Exhaustive(getTopRewriterUsingContextAssignments()));
Iterator<Map<Expression, Expression>> assignmentsIterator = makeAssignmentsIterator(indices, indicesCondition, context);
for (Map<Expression, Expression> indicesValues : in(assignmentsIterator)) {
Context extendedContext = extendAssignments(indicesValues, context);
Expression bodyEvaluation = rewriter.apply(summand, extendedContext);
if (group.isAdditiveAbsorbingElement(bodyEvaluation)) {
return bodyEvaluation;
}
result = group.add(result, bodyEvaluation, extendedContext);
}
return result;
}
use of com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive in project aic-expresso by aic-sri-international.
the class AbstractInterpreter method setBaseTopRewriter.
public void setBaseTopRewriter(TopRewriter baseTopRewriter) {
Rewriter result = new Recursive(new Exhaustive(new TopRewriterUsingQuantifierEliminatorAndContextAssignments(baseTopRewriter)));
setBaseRewriter(result);
}
Aggregations