use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class LinearRealArithmeticTheoryTest method runQuantifierTest.
private void runQuantifierTest(Expression variable, String constraintString, String bodyString, Expression expected, String computedFunction, BinaryFunction<Constraint, Expression, ExpressionStepSolver> stepSolverMaker, Context context) {
Expression body = parse(bodyString);
Function<Constraint, ExpressionStepSolver> stepSolverMakerFromConstraint = c -> stepSolverMaker.apply(c, body);
runTest(variable, constraintString, expected, computedFunction, stepSolverMakerFromConstraint, context);
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class LinearRealArithmeticTheoryTest method runTest.
/**
* @param variable
* @param constraintString
* @param expected
* @param computedFunction
* @param stepSolverMaker
* @param context
*/
private void runTest(Expression variable, String constraintString, Expression expected, String computedFunction, Function<Constraint, ExpressionStepSolver> stepSolverMaker, Context context) {
System.out.println("Solving " + computedFunction + " for " + variable + " in " + constraintString);
Constraint constraint = new SingleVariableLinearRealArithmeticConstraint(variable, true, context.getTheory());
constraint = constraint.conjoin(parse(constraintString), context);
ExpressionStepSolver stepSolver = stepSolverMaker.apply(constraint);
Expression actual = stepSolver.solve(context);
System.out.println("Variable " + variable + "\nhas " + computedFunction + ":\n" + actual + "\nfor constraint:\n" + constraintString + "\n");
assertEquals(expected, actual);
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class LinearRealArithmeticTheory method getSingleVariableConstraintQuantifierEliminatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintQuantifierEliminatorStepSolver(AssociativeCommutativeGroup group, SingleVariableConstraint constraint, Expression body, Context context) {
ExpressionStepSolver formulaSplitterStepSolver;
if (group instanceof Sum) {
formulaSplitterStepSolver = new SummationOnLinearRealArithmeticAndPolynomialStepSolver(constraint, body);
} else {
formulaSplitterStepSolver = new QuantifierEliminationOnBodyInWhichIndexOnlyOccursInsideLiteralsStepSolver(group, constraint, body);
}
ExpressionLiteralSplitterStepSolver result = new ExpressionStepSolverToLiteralSplitterStepSolverAdapter(formulaSplitterStepSolver);
return result;
}
Aggregations