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());
}
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));
}
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());
}
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));
}
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());
}
Aggregations