use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.
the class Simplifier method visitNotExpr.
@Override
public BooleanExpr visitNotExpr(NotExpr notExpr) {
BooleanExpr oldArg = notExpr.getArg();
BooleanExpr newArg = simplifyBooleanExpr(oldArg);
if (newArg == FalseExpr.INSTANCE) {
return TrueExpr.INSTANCE;
} else if (newArg == TrueExpr.INSTANCE) {
return FalseExpr.INSTANCE;
} else if (newArg instanceof NotExpr) {
return ((NotExpr) newArg).getArg();
} else if (newArg != oldArg) {
return new NotExpr(newArg);
} else {
return notExpr;
}
}
use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitIfExpr.
@Test
public void testVisitIfExpr() {
BooleanExpr p1Batfish = newBooleanAtom();
BooleanExpr p2Batfish = newBooleanAtom();
BoolExpr p1Z3 = toBoolExpr(p1Batfish, _input, _nodContext);
BoolExpr p2Z3 = toBoolExpr(p2Batfish, _input, _nodContext);
assertThat(toBoolExpr(new IfExpr(p1Batfish, p2Batfish), _input, _nodContext), equalTo(_ctx.mkImplies(p1Z3, p2Z3)));
}
use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitNotExpr.
@Test
public void testVisitNotExpr() {
BooleanExpr p1Batfish = newBooleanAtom();
BoolExpr p1Z3 = toBoolExpr(p1Batfish, _input, _nodContext);
assertThat(toBoolExpr(new NotExpr(p1Batfish), _input, _nodContext), equalTo(_ctx.mkNot(p1Z3)));
}
use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.
the class BoolExprTransformerTest method testVisitRangeMatchExpr.
@Test
public void testVisitRangeMatchExpr() {
BooleanExpr expr = RangeMatchExpr.fromSubRanges(BasicHeaderField.DSCP, BasicHeaderField.DSCP.getSize(), ImmutableSet.of(new SubRange(1, 3), new SubRange(5, 7)));
assertThat(toBoolExpr(expr, _input, _nodContext), instanceOf(BoolExpr.class));
}
use of org.batfish.z3.expr.BooleanExpr in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitIp.
@Test
public void testVisitIp() {
Ip ip = new Ip("1.2.3.4");
BooleanExpr matchSrcExpr = ip.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchSrcExpr, equalTo(HeaderSpaceMatchExpr.matchSrcIp(ImmutableSet.of(new IpWildcard(ip)))));
BooleanExpr matchDstExpr = ip.accept(DST_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchDstExpr, equalTo(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(ip)))));
BooleanExpr matchSrcOrDstExpr = ip.accept(SRC_OR_DST_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchSrcOrDstExpr, equalTo(HeaderSpaceMatchExpr.matchSrcOrDstIp(ImmutableSet.of(new IpWildcard(ip)))));
}
Aggregations