use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.
the class SGDPLLTTester method makeProblem.
private static Expression makeProblem(Collection<Expression> indices, Constraint constraint, Expression body, AssociativeCommutativeGroup group, Context context) {
Expression currentBody = body;
boolean firstIndex = true;
for (Expression index : indices) {
Expression indexType = GrinderUtil.getTypeExpressionOfExpression(index, context);
Expression constraintOnThisIndex = firstIndex ? constraint : TRUE;
SingleQuantifierEliminationProblem problem = new DefaultSingleQuantifierEliminationProblem(group, index, indexType, constraintOnThisIndex, currentBody);
currentBody = problem.toExpression();
firstIndex = false;
}
return currentBody;
}
use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.
the class AbstractTranslationBasedTheory method getSingleVariableConstraintSatisfiabilityStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintSatisfiabilityStepSolver(SingleVariableConstraint constraint, Context context) {
Expression index = constraint.getVariable();
Expression indexType = context.getTypeExpressionOfRegisteredSymbol(index);
DefaultSingleQuantifierEliminationProblem problem = new DefaultSingleQuantifierEliminationProblem(new Disjunction(), index, indexType, constraint, TRUE);
return getSingleQuantifierEliminatorStepSolver(problem, context);
}
use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.
the class SummationOnDifferenceArithmeticAndPolynomialStepSolverTest method runTest.
private void runTest(Expression variable, String constraintString, Expression body, Expression expected, Context context) {
Theory theory = context.getTheory();
SingleVariableDifferenceArithmeticConstraint constraint = new SingleVariableDifferenceArithmeticConstraint(variable, true, theory);
constraint = (SingleVariableDifferenceArithmeticConstraint) constraint.conjoin(parse(constraintString), context);
Expression typeExpression = context.getTypeExpressionOfRegisteredSymbol(variable);
SingleQuantifierEliminationProblem problem = new DefaultSingleQuantifierEliminationProblem(new Sum(), variable, typeExpression, constraint, body);
ExpressionStepSolver stepSolver = new SummationOnDifferenceArithmeticAndPolynomialStepSolver(problem);
Expression actual = stepSolver.solve(context);
expected = simplify(expected, context);
System.out.println("sum({{ (on " + variable + " in " + GrinderUtil.getTypeExpressionOfExpression(variable, context) + ") " + body + " : " + constraintString + " }} = " + actual + "\n");
if (!expected.equals(actual)) {
Expression difference = apply(MINUS, expected, actual);
Expression differenceResult = simplify(difference, context);
if (!differenceResult.equals(ZERO)) {
System.err.println("Expressions are not equal and even difference is not zero");
System.err.println("Expected: " + expected);
System.err.println("Actual: " + actual);
System.err.println("Difference: " + differenceResult);
fail("Expressions are not equal and even difference is not zero. Expected: " + expected + ", actual: " + actual);
}
}
// TODO: correctness test against grounding
}
use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.
the class LinearRealArithmeticTheoryTest method runSummationTest.
private void runSummationTest(Expression variable, String constraintString, String bodyString, Expression expected, Simplifier simplifier, Context context) {
Expression typeExpression = context.getTypeExpressionOfRegisteredSymbol(variable);
runQuantifierTest(variable, constraintString, bodyString, expected, "summation for " + bodyString, (SingleVariableConstraint c, Expression b) -> new SummationOnLinearRealArithmeticAndPolynomialStepSolver(new DefaultSingleQuantifierEliminationProblem(new Sum(), variable, typeExpression, c, b)), context);
}
use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.
the class AbstractTranslationBasedTheory method getSingleVariableConstraintModelCountingStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintModelCountingStepSolver(SingleVariableConstraint constraint, Context context) {
Expression index = constraint.getVariable();
Expression indexType = context.getTypeExpressionOfRegisteredSymbol(index);
DefaultSingleQuantifierEliminationProblem problem = new DefaultSingleQuantifierEliminationProblem(new Sum(), index, indexType, constraint, ONE);
return getSingleQuantifierEliminatorStepSolver(problem, context);
}
Aggregations