use of org.batfish.z3.expr.NotExpr in project batfish by batfish.
the class SimplifierTest method testSimplifyIfStaticallyTrue.
/**
* Test that an IF with antecedent statically FALSE, or consequent statically TRUE, or antecedent
* statically equal to consequent simplifies to TRUE.
*/
@Test
public void testSimplifyIfStaticallyTrue() {
BooleanExpr p1 = newAtom();
// Antecedent is false
assertThat(simplifyBooleanExpr(new IfExpr(FalseExpr.INSTANCE, newAtom())), equalTo(TrueExpr.INSTANCE));
assertThat(simplifyBooleanExpr(new IfExpr(new NotExpr(new NotExpr(FalseExpr.INSTANCE)), newAtom())), equalTo(TrueExpr.INSTANCE));
// Consequent is true
assertThat(simplifyBooleanExpr(new IfExpr(newAtom(), TrueExpr.INSTANCE)), equalTo(TrueExpr.INSTANCE));
assertThat(simplifyBooleanExpr(new IfExpr(newAtom(), new NotExpr(FalseExpr.INSTANCE))), equalTo(TrueExpr.INSTANCE));
// Antecedent == Consequent
assertThat(simplifyBooleanExpr(new IfExpr(p1, p1)), equalTo(TrueExpr.INSTANCE));
assertThat(simplifyBooleanExpr(new IfExpr(new NotExpr(new NotExpr(p1)), p1)), equalTo(TrueExpr.INSTANCE));
}
use of org.batfish.z3.expr.NotExpr in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOut.
@Test
public void testVisitPreOut() {
SynthesizerInput input = MockSynthesizerInput.builder().setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOut.State.INSTANCE)));
// PostInNotMine
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2)))), ImmutableSet.of(new PostIn(NODE1)), new PreOut(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4)))), ImmutableSet.of(new PostIn(NODE2)), new PreOut(NODE2))));
}
use of org.batfish.z3.expr.NotExpr in project batfish by batfish.
the class IpSpaceBooleanExprTransformer method visitIpWildcardSetIpSpace.
@Override
public BooleanExpr visitIpWildcardSetIpSpace(IpWildcardSetIpSpace ipWildcardSetIpSpace) {
BooleanExpr matchBlacklist = HeaderSpaceMatchExpr.matchIp(ipWildcardSetIpSpace.getBlacklist(), _useSrc, _useDst);
BooleanExpr matchWhitelist = HeaderSpaceMatchExpr.matchIp(ipWildcardSetIpSpace.getWhitelist(), _useSrc, _useDst);
return new AndExpr(ImmutableList.of(new NotExpr(matchBlacklist), matchWhitelist));
}
Aggregations