private RTLExpression addClause(RTLExpression formula, RTLExpression clause) { if (formula != null) { return ExpressionFactory.createAnd(formula, clause); } else { return clause; } }
public RTLExpression getStateFormula(ValuationState state) { RTLExpression result = null; for (Iterator<Map.Entry<RTLVariable, AbstractDomainElement>> entryIt = state.variableIterator(); entryIt.hasNext(); ) { Map.Entry<RTLVariable, AbstractDomainElement> entry = entryIt.next(); RTLVariable var = entry.getKey(); IntervalElement interval = (IntervalElement) entry.getValue(); if (interval.size() == 1) { result = addClause( result, ExpressionFactory.createEqual( var, ExpressionFactory.createNumber(interval.getLeft(), var.getBitWidth()))); } else { if (!interval.leftOpen()) { result = addClause( result, ExpressionFactory.createLessOrEqual( ExpressionFactory.createNumber(interval.getLeft(), var.getBitWidth()), var)); } if (!interval.rightOpen()) { result = addClause( result, ExpressionFactory.createLessOrEqual( var, ExpressionFactory.createNumber(interval.getRight(), var.getBitWidth()))); } } } if (result == null) { result = ExpressionFactory.TRUE; } return result; }