use of org.batfish.z3.expr.IntExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyEqStaticallyFalse.
/**
* Test that an EQ node with LHS and RHS statically determinable to be unequal simplifies to
* FALSE.
*/
@Test
public void testSimplifyEqStaticallyFalse() {
IntExpr i1 = new LitIntExpr(Ip.ZERO);
IntExpr i2 = new LitIntExpr(Ip.MAX);
EqExpr eq = new EqExpr(i1, i2);
assertThat(simplifyBooleanExpr(eq), equalTo(FalseExpr.INSTANCE));
}
use of org.batfish.z3.expr.IntExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyEqSame.
/**
* Test that an EQ node with syntactically equal LHS and RHS simplifies to TRUE.
*/
@Test
public void testSimplifyEqSame() {
IntExpr i1 = new VarIntExpr(BasicHeaderField.DST_IP);
EqExpr eq = new EqExpr(i1, i1);
assertThat(simplifyBooleanExpr(eq), equalTo(TrueExpr.INSTANCE));
}
use of org.batfish.z3.expr.IntExpr 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.IntExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyEqPreserveUnalteredInstance.
/**
* Test that an EQ node with LHS and RHS not statically determinable is unchanged by
* simplification.
*/
@Test
public void testSimplifyEqPreserveUnalteredInstance() {
IntExpr i1 = new VarIntExpr(BasicHeaderField.DST_IP);
IntExpr i2 = new VarIntExpr(BasicHeaderField.SRC_IP);
EqExpr eq = new EqExpr(i1, i2);
assertThat(simplifyBooleanExpr(eq), sameInstance(eq));
}
use of org.batfish.z3.expr.IntExpr in project batfish by batfish.
the class Simplifier method visitEqExpr.
@Override
public BooleanExpr visitEqExpr(EqExpr eqExpr) {
IntExpr lhs = eqExpr.getLhs();
IntExpr rhs = eqExpr.getRhs();
if (lhs.equals(rhs)) {
return TrueExpr.INSTANCE;
} else if (lhs instanceof LitIntExpr && rhs instanceof LitIntExpr) {
return FalseExpr.INSTANCE;
} else {
return eqExpr;
}
}
Aggregations