public static void addDomainConstants(
     Iterable<Term> constants, MultiList<Object, Set<Term>> interchangeable) {
   MultiMap<Object, Term> typed = new MultiMap<Object, Term>();
   for (Term t : constants) {
     typed.put(t.type() == null ? Sugar.NIL : t.type(), t);
   }
   for (Map.Entry<Object, Set<Term>> entry : typed.entrySet()) {
     interchangeable.put(entry.getKey(), entry.getValue());
   }
 }
 private static boolean sameType(Term a, Term b) {
   if (a.type() == null && b.type() == null) {
     return true;
   } else if ((a.type() == null && b.type() != null) || (a.type() != null && b.type() == null)) {
     return false;
   } else {
     return a.type().equals(b.type());
   }
 }