use of org.batfish.z3.expr.LitIntExpr in project batfish by batfish.
the class BlacklistDstIpQuerySynthesizer method getReachabilityProgram.
@Override
public ReachabilityProgram getReachabilityProgram(SynthesizerInput input) {
ImmutableList.Builder<BooleanExpr> queryConditionsBuilder = ImmutableList.builder();
queryConditionsBuilder.add(SaneExpr.INSTANCE);
for (Ip blacklistIp : _blacklistIps) {
BooleanExpr blacklistIpCondition = new NotExpr(new EqExpr(new VarIntExpr(BasicHeaderField.DST_IP), new LitIntExpr(blacklistIp)));
queryConditionsBuilder.add(blacklistIpCondition);
}
return ReachabilityProgram.builder().setInput(input).setQueries(ImmutableList.of(new QueryStatement(Query.INSTANCE))).setRules(ImmutableList.of(new BasicRuleStatement(new AndExpr(queryConditionsBuilder.build()), ImmutableSet.of(), Query.INSTANCE))).build();
}
use of org.batfish.z3.expr.LitIntExpr 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.LitIntExpr 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