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