/** * Searches for expression of the form ?var = const * * <p>TODO We are not considering equals between variables. A space efficient way to achieve this * is by creating a new expression, where the substitution ?x ?y has been applied. * * <p>?x = const . ?y = const . ?x = ?y . * * @param clause * @return */ public static Map<Var, ValueSet<NodeValue>> extractValueConstraintsDnf(Set<Set<Expr>> dnf) { Map<Var, ValueSet<NodeValue>> result = null; if (dnf == null) { return result; } for (Set<Expr> clause : dnf) { Map<Var, ValueSet<NodeValue>> map = extractValueConstraintsDnfClause(clause); if (result == null) { result = map; continue; } Iterator<Map.Entry<Var, ValueSet<NodeValue>>> itEntry = result.entrySet().iterator(); // for(Map.Entry<Var, ValueSet<NodeValue>> entry : result.entrySet()) { while (itEntry.hasNext()) { Map.Entry<Var, ValueSet<NodeValue>> entry = itEntry.next(); ValueSet<NodeValue> a = entry.getValue(); ValueSet<NodeValue> b = map.get(entry.getKey()); a.merge(b); if (a.isUnknown()) { itEntry.remove(); } } if (result.isEmpty()) { break; } } return (result == null) ? new HashMap<Var, ValueSet<NodeValue>>() : result; }