Search in sources :

Example 1 with State

use of org.batfish.z3.expr.StateExpr.State 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 2 with State

use of org.batfish.z3.expr.StateExpr.State 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

TestStateExpr (org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr)2 Test (org.junit.Test)2