RTLExpression xprime = ExpressionFactory.createVariable("xprime" + lhs.getBitWidth(), lhs.getBitWidth());
Context subCtx = new Context();
subCtx.substitute(lhs, xprime);
Solver solver = Solver.createSolver();
RTLExpression stateFormula = s.getStateFormula(prec);
solver.addAssertion(stateFormula);
solver.addAssertion(ExpressionFactory.createEqual(xprime,
stmt.getRightHandSide()));
for (int predIdx = 0; predIdx <= PredicateMap.getMaxIndex(); predIdx++) {
RTLExpression p = PredicateMap.getPredicate(predIdx);
if (!p.getUsedVariables().contains(lhs))
continue;
// substitute x by xprime
p = p.evaluate(subCtx);
// Clear variable from predicate BDD
setVariableDontCare(postPreds, predIdx);
// check if the predicate holds or not
solver.push();
solver.addAssertion(ExpressionFactory.createNot(p));
if (solver.isUnsatisfiable()) {
postPreds.andWith(bddFactory.ithVar(predIdx));
} else {
// Now check whether the negative of the predicate holds
solver.pop();
solver.push();
solver.addAssertion(p);
if (solver.isUnsatisfiable()) {
postPreds.andWith(bddFactory.nithVar(predIdx));
}
}
// nothing for don't know, the predicate is already cleared from the BDD
solver.pop();
}
return Collections.singleton((AbstractState)new PredicateAbstractionState(postPreds));
}
@Override
public Set<AbstractState> visit(RTLMemoryAssignment stmt) {
// Memory assignments not supported
return fallThroughState();
}
@Override
public Set<AbstractState> visit(RTLAssume stmt) {
Solver solver = Solver.createSolver();
solver.addAssertion(s.getStateFormula(prec));
solver.addAssertion(stmt.getAssumption());
if (solver.isUnsatisfiable())
return Collections.emptySet();
// OK? was empty in old impl
BDD postPreds = s.predicates.id();
for (int predIdx = 0; predIdx <= PredicateMap.getMaxIndex(); predIdx++) {
RTLExpression p = PredicateMap.getPredicate(predIdx);
// check if the predicate holds or not
solver.push();
solver.addAssertion(ExpressionFactory.createNot(p));
if (solver.isUnsatisfiable()) {
setVariableDontCare(postPreds, predIdx);
postPreds.andWith(bddFactory.ithVar(predIdx));
} else {
// Now check whether the negative of the predicate holds
solver.pop();
solver.push();
solver.addAssertion(p);
if (solver.isUnsatisfiable()) {
setVariableDontCare(postPreds, predIdx);
postPreds.andWith(bddFactory.nithVar(predIdx));
}
}
solver.pop();
}
return Collections.singleton((AbstractState)new PredicateAbstractionState(postPreds));
}