Search in sources :

Example 41 with Status

use of su.litvak.chromecast.api.v2.Status 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);
}
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)

Example 42 with Status

use of su.litvak.chromecast.api.v2.Status 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));
}
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)

Example 43 with Status

use of su.litvak.chromecast.api.v2.Status 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));
}
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)

Example 44 with Status

use of su.litvak.chromecast.api.v2.Status in project bmoth by hhu-stups.

the class QuantifiedFormulaEvaluationTest method testFailExistentialFormula.

@Test
public void testFailExistentialFormula() {
    String formula = "#(x).(x=2 & x=5)";
    // getting the translated z3 representation of the formula
    BoolExpr constraint = translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.UNSATISFIABLE, check);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 45 with Status

use of su.litvak.chromecast.api.v2.Status in project bmoth by hhu-stups.

the class QuantifiedFormulaEvaluationTest method testUniversalExistentialFormula.

@Test
public void testUniversalExistentialFormula() {
    String formula = "#(y).(y:NATURAL & !(x).(x*y=y))";
    // getting the translated z3 representation of the formula
    BoolExpr constraint = translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.SATISFIABLE, check);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Aggregations

Status (com.microsoft.z3.Status)61 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)48 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 Z3_ast_print_mode (com.microsoft.z3.enumerations.Z3_ast_print_mode)1 LitmusLexer (dartagnan.LitmusLexer)1 LitmusParser (dartagnan.LitmusParser)1