Search in sources :

Example 1 with Statement

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

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

the class Simplifier method visitBasicRuleStatement.

@Override
public Statement visitBasicRuleStatement(BasicRuleStatement basicRuleStatement) {
    /**
     * TODO: something smarter
     */
    BooleanExpr originalPreconditionStateIndependentConstraints = basicRuleStatement.getPreconditionStateIndependentConstraints();
    BooleanExpr simplifiedPreconditionStateIndependentConstraints = simplifyBooleanExpr(originalPreconditionStateIndependentConstraints);
    if (originalPreconditionStateIndependentConstraints != simplifiedPreconditionStateIndependentConstraints) {
        return simplifyStatement(new BasicRuleStatement(simplifiedPreconditionStateIndependentConstraints, basicRuleStatement.getPreconditionStates(), basicRuleStatement.getPostconditionState()));
    } else if (simplifiedPreconditionStateIndependentConstraints == FalseExpr.INSTANCE) {
        return VACUOUS_RULE;
    } else {
        return basicRuleStatement;
    }
}
Also used : BooleanExpr(org.batfish.z3.expr.BooleanExpr) BasicRuleStatement(org.batfish.z3.expr.BasicRuleStatement)

Example 3 with Statement

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

the class Simplifier method visitTransformationRuleStatement.

@Override
public Statement visitTransformationRuleStatement(TransformationRuleStatement transformationRuleStatement) {
    /**
     * TODO: something smarter
     */
    BooleanExpr originalPreconditionStateIndependentConstraints = transformationRuleStatement.getPreconditionStateIndependentConstraints();
    BooleanExpr simplifiedPreconditionStateIndependentConstraints = simplifyBooleanExpr(originalPreconditionStateIndependentConstraints);
    if (originalPreconditionStateIndependentConstraints != simplifiedPreconditionStateIndependentConstraints) {
        return simplifyStatement(new TransformationRuleStatement(simplifiedPreconditionStateIndependentConstraints, transformationRuleStatement.getPreconditionPreTransformationStates(), transformationRuleStatement.getPreconditionPostTransformationStates(), transformationRuleStatement.getPostconditionTransformationState()));
    } else if (simplifiedPreconditionStateIndependentConstraints == FalseExpr.INSTANCE) {
        return VACUOUS_RULE;
    } else {
        return transformationRuleStatement;
    }
}
Also used : TransformationRuleStatement(org.batfish.z3.expr.TransformationRuleStatement) BooleanExpr(org.batfish.z3.expr.BooleanExpr)

Aggregations

BooleanExpr (org.batfish.z3.expr.BooleanExpr)2 BasicRuleStatement (org.batfish.z3.expr.BasicRuleStatement)1 TransformationRuleStatement (org.batfish.z3.expr.TransformationRuleStatement)1 TestStateExpr (org.batfish.z3.expr.visitors.RelationCollectorTest.TestStateExpr)1 Test (org.junit.Test)1