use of com.sri.ai.grinder.api.Constraint in project aic-expresso by aic-sri-international.
the class ValuesOfSingleVariableDifferenceArithmeticConstraintStepSolverTest method runTest.
private void runTest(Expression variable, String constraintString, Expression expected, Context context) {
Constraint constraint = new SingleVariableDifferenceArithmeticConstraint(variable, true, context.getTheory());
constraint = constraint.conjoin(parse(constraintString), context);
ExpressionLiteralSplitterStepSolver stepSolver = new ValuesOfSingleVariableDifferenceArithmeticConstraintStepSolver((SingleVariableDifferenceArithmeticConstraint) constraint);
Expression actual = stepSolver.solve(context);
System.out.println("Variable " + variable + "\nhas possible values:\n" + actual + "\nsatisfying constraint:\n" + constraintString + "\n");
assertEquals(expected, actual);
}
use of com.sri.ai.grinder.api.Constraint in project aic-expresso by aic-sri-international.
the class AbstractEqualityConstraintTest method testSatisfiabilitySpecialCases.
@Test
public void testSatisfiabilitySpecialCases() {
String conjunction;
// looks unsatisfiable for type size 5, but it is not
conjunction = "X != a and X != b and X != c and X != Y and X != Z";
TheoryTestingSupport theoryTestingSupport = makeTheoryTestingSupport();
Constraint constraint = new SingleVariableEqualityConstraint(parse("X"), false, theoryTestingSupport.getTheory());
Context context = theoryTestingSupport.makeContextWithTestingInformation();
constraint = constraint.conjoinWithConjunctiveClause(parse(conjunction), context);
// satisfiable if either Y or Z is equal to a, b, c, or each other.
Assert.assertNotEquals(null, constraint);
}
Aggregations