Search in sources :

Example 1 with Status

use of com.microsoft.z3.Status in project bmoth by hhu-stups.

the class Issue59Test method testIssue59JustInvariant.

@Test
public void testIssue59JustInvariant() {
    Context ctx = new Context();
    Solver s = ctx.mkSolver();
    String formula = "x**2 = x*x & #x.({x} \\/ {1,2} = {1,2})";
    BoolExpr combinedConstraint = translatePredicate(formula, ctx);
    s.add(combinedConstraint);
    Status check = s.check();
    assertEquals(Status.SATISFIABLE, check);
}
Also used : Context(com.microsoft.z3.Context) Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Solver(com.microsoft.z3.Solver) Test(org.junit.Test)

Example 2 with Status

use of com.microsoft.z3.Status in project bmoth by hhu-stups.

the class Issue59Test method testIssue59JustInvariant2.

@Test
public void testIssue59JustInvariant2() {
    Context ctx = new Context();
    Solver s = ctx.mkSolver();
    String formula = "x**2 = x*x";
    BoolExpr combinedConstraint = translatePredicate(formula, ctx);
    s.add(combinedConstraint);
    Status check = s.check();
    assertEquals(Status.SATISFIABLE, check);
}
Also used : Context(com.microsoft.z3.Context) Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Solver(com.microsoft.z3.Solver) Test(org.junit.Test)

Example 3 with Status

use of com.microsoft.z3.Status in project bmoth by hhu-stups.

the class Issue76Test method testOperatorPrecedence.

@Test
public void testOperatorPrecedence() {
    String satFormula1 = "TRUE or (FALSE & FALSE)";
    String satFormula2 = "TRUE or FALSE & FALSE";
    Status check;
    BoolExpr satExpr1 = translatePredicate(satFormula1, z3Context);
    BoolExpr satExpr2 = translatePredicate(satFormula2, z3Context);
    z3Solver.add(satExpr1);
    check = z3Solver.check();
    assertEquals(Status.SATISFIABLE, check);
    z3Solver.add(satExpr2);
    check = z3Solver.check();
    assertEquals(Status.UNSATISFIABLE, check);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 4 with Status

use of com.microsoft.z3.Status in project bmoth by hhu-stups.

the class Z3InterpolationTest method testSimpleInterpolation.

@Test
public void testSimpleInterpolation() {
    IntExpr x = ctx.mkIntConst("x");
    BoolExpr xGtZero = ctx.mkGt(x, ctx.mkInt(0));
    BoolExpr xLtZero = ctx.mkLt(x, ctx.mkInt(0));
    BoolExpr xGtZeroInterpolant = ctx.MkInterpolant(xGtZero);
    s.add(xGtZero);
    s.add(xLtZero);
    Status check = s.check();
    assertEquals(Status.UNSATISFIABLE, check);
    ComputeInterpolantResult ir = ctx.ComputeInterpolant(ctx.mkAnd(xGtZeroInterpolant, xLtZero), ctx.mkParams());
    assertEquals(1, ir.interp.length);
    assertEquals("(not (<= x 0))", ir.interp[0].toString());
}
Also used : ComputeInterpolantResult(com.microsoft.z3.InterpolationContext.ComputeInterpolantResult) Test(org.junit.Test)

Example 5 with Status

use of com.microsoft.z3.Status in project bmoth by hhu-stups.

the class BooleanFormulaEvaluationTest method testFalseFormula.

@Test
public void testFalseFormula() throws Exception {
    String formula = "x = 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");
    assertEquals(SATISFIABLE, check);
    assertEquals(z3Context.mkFalse(), z3Solver.getModel().eval(x, true));
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) BoolExpr(com.microsoft.z3.BoolExpr) Expr(com.microsoft.z3.Expr) Test(org.junit.Test)

Aggregations

Status (com.microsoft.z3.Status)61 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Context (com.microsoft.z3.Context)11 Expr (com.microsoft.z3.Expr)10 Solver (com.microsoft.z3.Solver)6 Model (com.microsoft.z3.Model)4 BatfishException (org.batfish.common.BatfishException)4 HeaderSpace (org.batfish.datamodel.HeaderSpace)4 IpWildcard (org.batfish.datamodel.IpWildcard)4 Fixedpoint (com.microsoft.z3.Fixedpoint)3 Z3Exception (com.microsoft.z3.Z3Exception)3 MachineToZ3Translator (de.bmoth.backend.z3.MachineToZ3Translator)2 ModelCheckingResult (de.bmoth.modelchecker.ModelCheckingResult)2 State (de.bmoth.modelchecker.State)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 ComputeInterpolantResult (com.microsoft.z3.InterpolationContext.ComputeInterpolantResult)1 Z3_ast_print_mode (com.microsoft.z3.enumerations.Z3_ast_print_mode)1 LitmusLexer (dartagnan.LitmusLexer)1