use of com.microsoft.z3.Expr in project bmoth by hhu-stups.
the class StateTest method testEquals.
@Test
public void testEquals() {
HashMap<String, Expr> map = new HashMap<>();
map.put("a", z3Context.mkInt(1));
map.put("b", z3Context.mkInt(2));
State s = new State(map);
State s2 = new State(map);
assertEqualsImplementedCorrectly(s);
assertEqualsImplementedCorrectly(s, s2);
s2 = new State(map);
State s3 = new State(map);
assertEqualsImplementedCorrectly(s2);
assertEqualsImplementedCorrectly(s2, s3);
}
use of com.microsoft.z3.Expr in project bmoth by hhu-stups.
the class StateTest method testStateEquals2.
@Test
public void testStateEquals2() throws Exception {
HashMap<String, Expr> map1 = new HashMap<>();
HashMap<String, Expr> map2 = new HashMap<>();
map1.put("x", z3Context.mkInt(11));
map1.put("y", z3Context.mkInt(12));
map2.put("x", z3Context.mkInt(11));
State state1 = new State(map1);
State state2 = new State(map2);
assertNotEquals(state1, state2);
assertNotEquals(state1.hashCode(), state2.hashCode());
}
use of com.microsoft.z3.Expr in project bmoth by hhu-stups.
the class Z3ConnectionTest method testQuantifiedFormula.
@Test
public void testQuantifiedFormula() {
Expr a = z3Context.mkIntConst("a");
Expr b = z3Context.mkIntConst("b");
BoolExpr constraint = z3Context.mkAnd(z3Context.mkEq(a, b), z3Context.mkEq(a, z3Context.mkInt(5)), z3Context.mkEq(b, z3Context.mkInt(7)));
constraint = z3Context.mkExists(new Expr[] { a, b }, constraint, 1, null, null, null, null);
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.UNSATISFIABLE, check);
}
use of com.microsoft.z3.Expr in project bmoth by hhu-stups.
the class Z3ConnectionTest method testSimpleCallToZ3.
@Test
public void testSimpleCallToZ3() {
// a = b & a = 5
Expr a = z3Context.mkIntConst("a");
Expr b = z3Context.mkIntConst("b");
BoolExpr constraint = z3Context.mkAnd(z3Context.mkEq(a, b), z3Context.mkEq(a, z3Context.mkInt(5)));
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.SATISFIABLE, check);
assertEquals(z3Context.mkInt(5), z3Solver.getModel().eval(a, true));
assertEquals(z3Context.mkInt(5), z3Solver.getModel().eval(b, true));
}
use of com.microsoft.z3.Expr in project bmoth by hhu-stups.
the class BooleanFormulaEvaluationTest method testSimpleBooleanFormula.
@Test
public void testSimpleBooleanFormula() throws Exception {
String formula = "x = TRUE & y = FALSE";
// getting the translated z3 representation of the formula
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
z3Solver.add(constraint);
Status check = z3Solver.check();
Expr x = z3Context.mkBoolConst("x");
Expr y = z3Context.mkBoolConst("y");
assertEquals(Status.SATISFIABLE, check);
assertEquals(z3Context.mkBool(true), z3Solver.getModel().eval(x, true));
assertEquals(z3Context.mkBool(false), z3Solver.getModel().eval(y, false));
}
Aggregations