use of org.batfish.z3.expr.BitVecExpr in project batfish by batfish.
the class AbstractNodJob method getOriginateVrfConstraints.
/**
* Try to find a model for each OriginateVrf. If an OriginateVrf does not have an entry in the
* Map, then the query is unsat when originating from there.
*/
protected Map<OriginateVrf, Map<String, Long>> getOriginateVrfConstraints(Context ctx, SmtInput smtInput) {
Solver solver = ctx.mkSolver();
solver.add(smtInput._expr);
int originateVrfBvSize = _originateVrfInstrumentation.getFieldBits();
BitVecExpr originateVrfFieldConst = ctx.mkBVConst(OriginateVrfInstrumentation.ORIGINATE_VRF_FIELD_NAME, originateVrfBvSize);
ImmutableMap.Builder<OriginateVrf, Map<String, Long>> models = ImmutableMap.builder();
// keep refining until no new models
while (true) {
try {
Map<String, Long> constraints = getSolution(solver, smtInput._variablesAsConsts);
int originateVrfId = Math.toIntExact(constraints.get(OriginateVrfInstrumentation.ORIGINATE_VRF_FIELD_NAME));
OriginateVrf originateVrf = _originateVrfInstrumentation.getOriginateVrfs().get(originateVrfId);
models.put(originateVrf, constraints);
// refine: different OriginateVrf
solver.add(ctx.mkNot(ctx.mkEq(originateVrfFieldConst, ctx.mkBV(originateVrfId, originateVrfBvSize))));
} catch (QueryUnsatException e) {
break;
}
}
return models.build();
}
use of org.batfish.z3.expr.BitVecExpr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitEqExpr.
@Test
public void testVisitEqExpr() {
IntExpr i1Batfish = newIntAtom();
IntExpr i2Batfish = newIntAtom();
BitVecExpr i1Z3 = toBitVecExpr(i1Batfish, _nodContext);
BitVecExpr i2Z3 = toBitVecExpr(i2Batfish, _nodContext);
assertThat(toBoolExpr(new EqExpr(i1Batfish, i2Batfish), _input, _nodContext), equalTo(_ctx.mkEq(i1Z3, i2Z3)));
}
use of org.batfish.z3.expr.BitVecExpr in project batfish by batfish.
the class ExprPrinter method visitBitVecExpr.
@Override
public void visitBitVecExpr(BitVecExpr bitVecExpr) {
List<Expr> subExpressions = ImmutableList.of(new IdExpr("_"), new IdExpr("BitVec"), new IdExpr(Integer.toString(bitVecExpr.getSize())));
printCollapsedComplexExpr(subExpressions);
}
Aggregations