Search in sources :

Example 21 with RuleStatement

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

the class ReachabilityProgramOptimizerTest method pruneIrrelevant.

/*
   * No query statement, so everything is irrelevant
   */
@Test
public void pruneIrrelevant() {
    StateExpr state1 = freshStateExpr();
    addRuleFor(state1);
    StateExpr state2 = freshStateExpr();
    addRuleFor(state2, state1);
    Set<RuleStatement> rules = optimize();
    assertThat(rules, empty());
}
Also used : TestStateExpr(org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr) Test(org.junit.Test)

Example 22 with RuleStatement

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

the class ReachabilityProgramOptimizerTest method testStraightLineNoPruning.

@Test
public void testStraightLineNoPruning() {
    StateExpr initialState = freshStateExpr();
    RuleStatement axiom = addRuleFor(initialState);
    StateExpr queryState = freshQueryStateExpr();
    RuleStatement rule = addRuleFor(queryState, initialState);
    Set<RuleStatement> rules = optimize();
    assertThat(rules, hasSize(2));
    assertThat(rules, hasItems(axiom, rule));
}
Also used : TestStateExpr(org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr) Test(org.junit.Test)

Example 23 with RuleStatement

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

the class ReachabilityProgramOptimizerTest method pruneUnreachable.

@Test
public void pruneUnreachable() {
    StateExpr state1 = freshStateExpr();
    StateExpr state2 = freshQueryStateExpr();
    addRuleFor(state2, state1);
    Set<RuleStatement> rules = optimize();
    assertThat(rules, empty());
}
Also used : TestStateExpr(org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr) Test(org.junit.Test)

Example 24 with RuleStatement

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

the class ReachabilityProgramOptimizerTest method pruneStateWithMissingDependency.

@Test
public void pruneStateWithMissingDependency() {
    StateExpr state1 = freshStateExpr();
    StateExpr state2 = freshStateExpr();
    StateExpr state3 = freshStateExpr();
    StateExpr goal = freshQueryStateExpr();
    RuleStatement state1Axiom = addRuleFor(state1);
    RuleStatement state3Rule = addRuleFor(state3, state1, state2);
    RuleStatement goalState1Rule = addRuleFor(goal, state1);
    RuleStatement goalState3Rule = addRuleFor(goal, state3);
    Set<RuleStatement> rules = optimize();
    // all rules involving state 3 have been removed
    assertThat(rules, not(hasItem(state3Rule)));
    assertThat(rules, not(hasItem(goalState3Rule)));
    // all other rules remain
    assertThat(rules, hasItems(goalState1Rule, state1Axiom));
}
Also used : TestStateExpr(org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr) Test(org.junit.Test)

Example 25 with RuleStatement

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

the class ReachabilityProgramOptimizerTest method pruneStateWithMissingDependency2.

/*
   * Round 1 should remove the rule for state2 because state3 is underivable
   * Round 2 should remove the axiom for state1 because it's irrelevant (it can only lead to
   * the goal through state2).
   */
@Test
public void pruneStateWithMissingDependency2() {
    StateExpr state1 = freshStateExpr();
    StateExpr state2 = freshStateExpr();
    StateExpr state3 = freshStateExpr();
    StateExpr goal = freshQueryStateExpr();
    addRuleFor(state1);
    addRuleFor(state2, state1, state3);
    addRuleFor(goal, state2);
    Set<RuleStatement> rules = optimize();
    // all rules involving state 3 have been removed
    assertThat(rules, empty());
}
Also used : TestStateExpr(org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)36 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)35 RuleStatement (org.batfish.z3.expr.RuleStatement)34 MockSynthesizerInput (org.batfish.z3.MockSynthesizerInput)30 SynthesizerInput (org.batfish.z3.SynthesizerInput)30 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)30 TestStateExpr (org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr)6 PreOut (org.batfish.z3.state.PreOut)6 PreOutEdge (org.batfish.z3.state.PreOutEdge)6 ImmutableList (com.google.common.collect.ImmutableList)5 Edge (org.batfish.datamodel.Edge)5 BooleanExpr (org.batfish.z3.expr.BooleanExpr)5 NotExpr (org.batfish.z3.expr.NotExpr)5 AclLineMatch (org.batfish.z3.state.AclLineMatch)5 AclPermit (org.batfish.z3.state.AclPermit)5 NodeDropAclIn (org.batfish.z3.state.NodeDropAclIn)5 NodeDropNoRoute (org.batfish.z3.state.NodeDropNoRoute)5 PostOutEdge (org.batfish.z3.state.PostOutEdge)5 QueryStatement (org.batfish.z3.expr.QueryStatement)4 AclDeny (org.batfish.z3.state.AclDeny)4