Search in sources :

Example 61 with Expr

use of com.google.api.expr.v1alpha1.Expr in project batfish by batfish.

the class TransferResult method mergeChangedVariables.

// TODO: this really needs to use persistent set data types
public PList<Pair<String, Pair<Expr, Expr>>> mergeChangedVariables(TransferResult<U, T> other) {
    Set<String> seen = new HashSet<>();
    PList<Pair<String, Pair<Expr, Expr>>> vars = PList.empty();
    for (Pair<String, Expr> cv1 : this._changedVariables) {
        String s = cv1.getFirst();
        Expr x = cv1.getSecond();
        if (!seen.contains(s)) {
            seen.add(s);
            Expr e = find(other._changedVariables, s);
            Pair<Expr, Expr> pair = new Pair<>(x, e);
            vars = vars.plus(new Pair<>(s, pair));
        }
    }
    for (Pair<String, Expr> cv1 : other._changedVariables) {
        String s = cv1.getFirst();
        Expr x = cv1.getSecond();
        if (!seen.contains(s)) {
            seen.add(s);
            Expr e = find(this._changedVariables, s);
            // preserve order
            Pair<Expr, Expr> pair = new Pair<>(e, x);
            vars = vars.plus(new Pair<>(s, pair));
        }
    }
    return vars;
}
Also used : Expr(com.microsoft.z3.Expr) HashSet(java.util.HashSet) Pair(org.batfish.common.Pair)

Example 62 with Expr

use of com.google.api.expr.v1alpha1.Expr in project batfish by batfish.

the class Z3ContextJob method computeSmtConstraintsViaNod.

protected BoolExpr computeSmtConstraintsViaNod(NodProgram program, boolean negate) {
    Fixedpoint fix = mkFixedpoint(program, true);
    Expr answer = answerFixedPoint(fix, program);
    return getSolverInput(answer, program, negate);
}
Also used : BitVecExpr(com.microsoft.z3.BitVecExpr) BoolExpr(com.microsoft.z3.BoolExpr) Expr(com.microsoft.z3.Expr) Fixedpoint(com.microsoft.z3.Fixedpoint)

Example 63 with Expr

use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.

the class StateTest method testGetStateConstraint.

@Test
public void testGetStateConstraint() {
    HashMap<String, Expr> map1 = new HashMap<>();
    map1.put("x", z3Context.mkInt(11));
    map1.put("y", z3Context.mkInt(12));
    State state1 = new State(map1);
    State state2 = new State(new HashMap<>());
    assertEquals("(and (= x 11) (= y 12))", state1.getStateConstraint(z3Context).toString());
    assertNull(state2.getStateConstraint(z3Context));
}
Also used : Expr(com.microsoft.z3.Expr) HashMap(java.util.HashMap) State(de.bmoth.modelchecker.State) Test(org.junit.Test)

Example 64 with Expr

use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.

the class StateTest method testToString.

@Test
public void testToString() throws Exception {
    HashMap<String, Expr> map = new HashMap<>();
    map.put("z", z3Context.mkInt(13));
    map.put("x", z3Context.mkInt(11));
    map.put("y", z3Context.mkInt(12));
    map.put("a", z3Context.mkInt(-200));
    State state = new State(map);
    assertEquals("{a=-200, x=11, y=12, z=13}", state.toString());
}
Also used : Expr(com.microsoft.z3.Expr) HashMap(java.util.HashMap) State(de.bmoth.modelchecker.State) Test(org.junit.Test)

Example 65 with Expr

use of com.google.api.expr.v1alpha1.Expr in project bmoth by hhu-stups.

the class StateTest method testStateEquals.

@Test
public void testStateEquals() throws Exception {
    HashMap<String, Expr> map1 = new HashMap<>();
    HashMap<String, Expr> map2 = new HashMap<>();
    map1.put("x", z3Context.mkInt(11));
    map2.put("x", z3Context.mkInt(11));
    State state1 = new State(map1);
    State state2 = new State(map2);
    assertEquals(state1, state2);
    assertEquals(state1.hashCode(), state2.hashCode());
}
Also used : Expr(com.microsoft.z3.Expr) HashMap(java.util.HashMap) State(de.bmoth.modelchecker.State) Test(org.junit.Test)

Aggregations

Expr (edu.stanford.CVC4.Expr)57 Test (org.junit.Test)55 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)49 SExpr (edu.stanford.CVC4.SExpr)42 Expr (com.microsoft.z3.Expr)32 Result (edu.stanford.CVC4.Result)32 Rational (edu.stanford.CVC4.Rational)28 Expr (com.google.api.expr.v1alpha1.Expr)23 BoolExpr (com.microsoft.z3.BoolExpr)22 ArrayType (edu.stanford.CVC4.ArrayType)12 BitVectorType (edu.stanford.CVC4.BitVectorType)12 Status (com.microsoft.z3.Status)11 Type (edu.stanford.CVC4.Type)11 HashMap (java.util.HashMap)11 Test (org.junit.jupiter.api.Test)11 ParsedExpr (com.google.api.expr.v1alpha1.ParsedExpr)10 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)9 ArithExpr (com.microsoft.z3.ArithExpr)8 BitVecExpr (com.microsoft.z3.BitVecExpr)8 Val (org.projectnessie.cel.common.types.ref.Val)7