use of com.sri.ai.grinder.sgdpllt.library.FunctorConstants.EQUIVALENCE in project aic-expresso by aic-sri-international.
the class AbstractEqualityConstraintTest method runCompleteSatisfiabilityTest.
/**
* @param conjunction
* @param expected
*/
private void runCompleteSatisfiabilityTest(String conjunction, Expression expected, TheoryTestingSupport theoryTestingSupport) {
Context context = theoryTestingSupport.makeContextWithTestingInformation();
Constraint constraint = new CompleteMultiVariableContext(theoryTestingSupport.getTheory(), context);
for (Expression literal : And.getConjuncts(parse(conjunction))) {
constraint = constraint.conjoin(literal, context);
if (constraint.isContradiction()) {
break;
}
}
if (expected == null && !constraint.isContradiction()) {
throw new AssertionError("Expected null but was <" + constraint + ">");
} else if (expected != null && constraint.isContradiction()) {
throw new AssertionError("Expected <" + expected + "> but was null");
} else if (expected != null && !constraint.isContradiction() && !expected.equals(constraint)) {
Simplifier interpreter = (e, c) -> theoryTestingSupport.getTheory().evaluate(e, c);
// Simplifier interpreter = new Evaluator(theoryTestingSupport.getTheory());
Expression equivalenceDefinition = apply(EQUIVALENCE, expected, constraint);
Expression universallyQuantified = universallyQuantifyFreeVariables(equivalenceDefinition, context);
Expression equivalent = interpreter.apply(universallyQuantified, context);
if (equivalent.equals(FALSE)) {
throw new Error("Expected <" + expected + "> but got <" + constraint + ">, which is not equivalent either");
}
}
}
Aggregations