use of org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor in project java-smt by sosy-lab.
the class SolverVisitorTest method testIntegerFormulaQuantifierHandlingUNSAT.
// Same as testBooleanFormulaQuantifierHandling but with Ints
@Test
public void testIntegerFormulaQuantifierHandlingUNSAT() throws Exception {
requireQuantifiers();
requireIntegers();
IntegerFormula x = imgr.makeVariable("x");
BooleanFormula xEq1 = bmgr.not(imgr.equal(imgr.makeNumber(1), x));
BooleanFormula constraint = qmgr.forall(ImmutableList.of(x), xEq1);
assertThatFormula(constraint).isUnsatisfiable();
BooleanFormula newConstraint = bmgr.visit(constraint, new BooleanFormulaTransformationVisitor(mgr) {
});
assertThatFormula(newConstraint).isUnsatisfiable();
}
use of org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor in project java-smt by sosy-lab.
the class SolverVisitorTest method testIntegerFormulaQuantifierHandlingTrivialUNSAT.
@Test
public void testIntegerFormulaQuantifierHandlingTrivialUNSAT() throws Exception {
requireQuantifiers();
requireIntegers();
IntegerFormula x = imgr.makeVariable("x");
BooleanFormula notxEqx = bmgr.not(imgr.equal(x, x));
BooleanFormula constraint = qmgr.forall(ImmutableList.of(x), notxEqx);
assertThatFormula(constraint).isUnsatisfiable();
BooleanFormula newConstraint = bmgr.visit(constraint, new BooleanFormulaTransformationVisitor(mgr) {
});
assertThatFormula(newConstraint).isUnsatisfiable();
}
use of org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor in project java-smt by sosy-lab.
the class SolverVisitorTest method testBooleanFormulaQuantifierHandling.
@Test
public void testBooleanFormulaQuantifierHandling() throws Exception {
requireQuantifiers();
assume().withMessage("Princess does not support quantifier over boolean variables").that(solverToUse()).isNotEqualTo(Solvers.PRINCESS);
BooleanFormula x = bmgr.makeVariable("x");
BooleanFormula constraint = qmgr.forall(ImmutableList.of(x), x);
assertThatFormula(constraint).isUnsatisfiable();
BooleanFormula newConstraint = bmgr.visit(constraint, new BooleanFormulaTransformationVisitor(mgr) {
});
assertThatFormula(newConstraint).isUnsatisfiable();
}
use of org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor in project java-smt by sosy-lab.
the class SolverVisitorTest method testTransformationInsideQuantifiers.
@Test
public void testTransformationInsideQuantifiers() {
requireQuantifiers();
// TODO Maybe rewrite using quantified integer variable to allow testing with Princess
assume().withMessage("Princess does not support quantifier over boolean variables").that(solverToUse()).isNotEqualTo(Solvers.PRINCESS);
BooleanFormula[] usedVars = Stream.of("a", "b", "c", "d", "e", "f").map(var -> bmgr.makeVariable(var)).toArray(BooleanFormula[]::new);
Fuzzer fuzzer = new Fuzzer(mgr, new Random(0));
List<BooleanFormula> quantifiedVars = ImmutableList.of(bmgr.makeVariable("a"));
BooleanFormula body = fuzzer.fuzz(30, usedVars);
BooleanFormula f = qmgr.forall(quantifiedVars, body);
BooleanFormula transformed = bmgr.transformRecursively(f, new BooleanFormulaTransformationVisitor(mgr) {
@Override
public BooleanFormula visitAtom(BooleanFormula pAtom, FunctionDeclaration<BooleanFormula> decl) {
if (decl.getKind() == FunctionDeclarationKind.VAR) {
// Uppercase all variables.
return bmgr.makeVariable(decl.getName().toUpperCase());
} else {
return pAtom;
}
}
});
assertThat(mgr.extractVariables(transformed).keySet().stream().allMatch(pS -> pS.equals(pS.toUpperCase()))).isTrue();
}
use of org.sosy_lab.java_smt.api.visitors.BooleanFormulaTransformationVisitor in project java-smt by sosy-lab.
the class SolverVisitorTest method testNestedIntegerFormulaQuantifierRecursiveHandling.
// Same as testNestedIntegerFormulaQuantifierHandling but with a recursive visitor
@Test
public void testNestedIntegerFormulaQuantifierRecursiveHandling() throws Exception {
requireQuantifiers();
requireIntegers();
// Z3 returns UNKNOWN as its quantifiers can not handle this.
assume().that(solverToUse()).isNotEqualTo(Solvers.Z3);
IntegerFormula x = imgr.makeVariable("x");
BooleanFormula xEq1 = imgr.equal(x, imgr.makeNumber(1));
BooleanFormula constraint = qmgr.exists(ImmutableList.of(x), qmgr.forall(ImmutableList.of(x), xEq1));
assertThatFormula(constraint).isUnsatisfiable();
BooleanFormula newConstraint = bmgr.transformRecursively(constraint, new BooleanFormulaTransformationVisitor(mgr) {
});
assertThatFormula(newConstraint).isUnsatisfiable();
}
Aggregations