Search in sources :

Example 1 with OrExpr

use of org.batfish.z3.expr.OrExpr in project batfish by batfish.

the class BoolExprTransformerTest method testVisitOrExpr.

@Test
public void testVisitOrExpr() {
    BooleanExpr p1Batfish = newBooleanAtom();
    BooleanExpr p2Batfish = newBooleanAtom();
    BoolExpr p1Z3 = toBoolExpr(p1Batfish, _input, _nodContext);
    BoolExpr p2Z3 = toBoolExpr(p2Batfish, _input, _nodContext);
    assertThat(toBoolExpr(new OrExpr(of(p1Batfish, p2Batfish)), _input, _nodContext), equalTo(_ctx.mkOr(p1Z3, p2Z3)));
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) BoolExprTransformer.toBoolExpr(org.batfish.z3.expr.visitors.BoolExprTransformer.toBoolExpr) BooleanExpr(org.batfish.z3.expr.BooleanExpr) OrExpr(org.batfish.z3.expr.OrExpr) Test(org.junit.Test)

Example 2 with OrExpr

use of org.batfish.z3.expr.OrExpr in project batfish by batfish.

the class SimplifierTest method testChainedSimplifications.

/**
 * Test that we keep simplifying until no more simplifications are possible.
 */
@Test
public void testChainedSimplifications() {
    OrExpr or = new OrExpr(of(new OrExpr(of(new OrExpr(of())))));
    assertThat(simplifyBooleanExpr(or), equalTo(FalseExpr.INSTANCE));
}
Also used : OrExpr(org.batfish.z3.expr.OrExpr) Test(org.junit.Test)

Example 3 with OrExpr

use of org.batfish.z3.expr.OrExpr in project batfish by batfish.

the class SimplifierTest method testSimplifyOrFalse.

/**
 * Test that any FALSE children of an OR node are removed.
 */
@Test
public void testSimplifyOrFalse() {
    BooleanExpr p1 = newAtom();
    BooleanExpr p2 = newAtom();
    OrExpr and = new OrExpr(of(FalseExpr.INSTANCE, p1, FalseExpr.INSTANCE, p2));
    assertThat(simplifyBooleanExpr(and), equalTo(new OrExpr(of(p1, p2))));
}
Also used : BooleanExpr(org.batfish.z3.expr.BooleanExpr) Simplifier.simplifyBooleanExpr(org.batfish.z3.expr.visitors.Simplifier.simplifyBooleanExpr) OrExpr(org.batfish.z3.expr.OrExpr) Test(org.junit.Test)

Example 4 with OrExpr

use of org.batfish.z3.expr.OrExpr in project batfish by batfish.

the class SimplifierTest method testSimplifyEmptyOr.

/**
 * Test that an empty OR node is simplified to false (the identity under OR).
 */
@Test
public void testSimplifyEmptyOr() {
    OrExpr or = new OrExpr(of());
    assertThat(simplifyBooleanExpr(or), equalTo(FalseExpr.INSTANCE));
}
Also used : OrExpr(org.batfish.z3.expr.OrExpr) Test(org.junit.Test)

Example 5 with OrExpr

use of org.batfish.z3.expr.OrExpr in project batfish by batfish.

the class DefaultTransitionGenerator method visitDropAcl.

@Override
public void visitDropAcl(DropAcl.State dropAcl) {
    // CopyDropAclIn
    _rules.add(new BasicRuleStatement(DropAclIn.INSTANCE, DropAcl.INSTANCE));
    // CopyDropAclOut
    _rules.add(new BasicRuleStatement(DropAclOut.INSTANCE, DropAcl.INSTANCE));
// ProjectNodeDropAcl (unused for now)
// _rules.add(
// new RuleStatement(
// new OrExpr(
// _input
// .getEnabledNodes()
// .keySet()
// .stream()
// .map(NodeDropAcl::new)
// .collect(ImmutableList.toImmutableList())),
// DropAcl.INSTANCE));
}
Also used : BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement)

Aggregations

OrExpr (org.batfish.z3.expr.OrExpr)7 Test (org.junit.Test)6 BooleanExpr (org.batfish.z3.expr.BooleanExpr)5 Simplifier.simplifyBooleanExpr (org.batfish.z3.expr.visitors.Simplifier.simplifyBooleanExpr)3 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)2 Predicates (com.google.common.base.Predicates)1 ImmutableList (com.google.common.collect.ImmutableList)1 BoolExpr (com.microsoft.z3.BoolExpr)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 AndExpr (org.batfish.z3.expr.AndExpr)1 BitVecExpr (org.batfish.z3.expr.BitVecExpr)1 Comment (org.batfish.z3.expr.Comment)1 CurrentIsOriginalExpr (org.batfish.z3.expr.CurrentIsOriginalExpr)1 EqExpr (org.batfish.z3.expr.EqExpr)1 Expr (org.batfish.z3.expr.Expr)1 ExtractExpr (org.batfish.z3.expr.ExtractExpr)1 FalseExpr (org.batfish.z3.expr.FalseExpr)1 GenericStatementVisitor (org.batfish.z3.expr.GenericStatementVisitor)1 HeaderSpaceMatchExpr (org.batfish.z3.expr.HeaderSpaceMatchExpr)1