Search in sources :

Example 1 with BoolExpr

use of com.microsoft.z3.BoolExpr 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 BoolExpr

use of com.microsoft.z3.BoolExpr 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 BoolExpr

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

the class Issue73Test method testSatPredicateWithoutModel.

@Test
public void testSatPredicateWithoutModel() throws IOException {
    String formula = "1 < 2";
    BoolExpr constraint = translatePredicate(formula, z3Context);
    SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
    Set<Model> solutions = finder.findSolutions(constraint, 20);
    assertEquals(0, solutions.size());
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) Model(com.microsoft.z3.Model) SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Test(org.junit.Test)

Example 4 with BoolExpr

use of com.microsoft.z3.BoolExpr 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 5 with BoolExpr

use of com.microsoft.z3.BoolExpr 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)

Aggregations

BoolExpr (com.microsoft.z3.BoolExpr)141 Status (com.microsoft.z3.Status)55 Test (org.junit.Test)51 ArithExpr (com.microsoft.z3.ArithExpr)27 GraphEdge (org.batfish.symbolic.GraphEdge)25 Context (com.microsoft.z3.Context)24 HashMap (java.util.HashMap)22 Expr (com.microsoft.z3.Expr)21 Set (java.util.Set)20 Collectors (java.util.stream.Collectors)18 BitVecExpr (com.microsoft.z3.BitVecExpr)17 Event (dartagnan.program.Event)17 MemEvent (dartagnan.program.MemEvent)17 Program (dartagnan.program.Program)16 Map (java.util.Map)16 Local (dartagnan.program.Local)15 ArrayList (java.util.ArrayList)15 BatfishException (org.batfish.common.BatfishException)14 Graph (org.batfish.symbolic.Graph)14 com.microsoft.z3 (com.microsoft.z3)12