private static MultiMap<Variable, Variable> surelyDifferent(DefaultRule rule) { Clause body = rule.antecedent(); Clause head = rule.consequent(); final MultiMap<Variable, Variable> different = new MultiMap<Variable, Variable>(); for (Literal literal : Sugar.union( body.getLiteralsByPredicate(SpecialBinaryPredicates.NEQ), body.getLiteralsByPredicate(SpecialBinaryPredicates.GT), body.getLiteralsByPredicate(SpecialBinaryPredicates.LT), body.getLiteralsByPredicate(SpecialVarargPredicates.ALLDIFF), head.getLiteralsByPredicate(SpecialBinaryPredicates.NEQ), head.getLiteralsByPredicate(SpecialBinaryPredicates.GT), head.getLiteralsByPredicate(SpecialBinaryPredicates.LT), head.getLiteralsByPredicate(SpecialVarargPredicates.ALLDIFF))) { for (Term a : literal.terms()) { if (a instanceof Variable) { Variable v1 = (Variable) a; for (Term b : literal.terms()) { if (b instanceof Variable) { Variable v2 = (Variable) b; if (v1 != v2) { different.put(v1, v2); } } } } } } return different; }