public static Set<DefaultRule> selectNonisomorphicDefaultRules(
     Iterable<DefaultRule> defaultRules) {
   List<Clause> candidates = new ArrayList<Clause>();
   for (DefaultRule rule : defaultRules) {
     DefaultRule preprocessed = preprocess(rule);
     candidates.add(
         new Clause(
             Sugar.<Literal>iterable(
                 preprocessed.antecedent().literals(), preprocessed.consequent().literals())));
   }
   Matching m = new Matching();
   Set<DefaultRule> retVal = new HashSet<DefaultRule>();
   for (Clause c : m.nonisomorphic(candidates)) {
     List<Literal> head = new ArrayList<Literal>();
     List<Literal> body = new ArrayList<Literal>();
     for (Literal l : c.literals()) {
       Literal newLiteral =
           new Literal(
               l.predicate().substring(l.predicate().indexOf(":") + 1), l.isNegated(), l.arity());
       for (int i = 0; i < l.arity(); i++) {
         newLiteral.set(l.get(i), i);
       }
       if (l.predicate().startsWith("antecedent:")
           || l.predicate().startsWith(SymmetricPredicates.PREFIX + "antecedent:")) {
         body.add(newLiteral);
       } else {
         head.add(newLiteral);
       }
     }
     retVal.add(new DefaultRule(new Clause(body), new Clause(head)));
   }
   return retVal;
 }
 private static Clause preprocessClause(Clause c, String prefix) {
   List<Literal> newLiterals = new ArrayList<Literal>();
   int specialID = 0;
   for (Literal l : c.literals()) {
     String predicate = l.predicate();
     if (predicate.equals(SpecialBinaryPredicates.NEQ)
         || predicate.equals(SpecialBinaryPredicates.EQ)
         || predicate.equals(SpecialVarargPredicates.ALLDIFF)) {
       predicate = SymmetricPredicates.PREFIX + prefix + predicate;
     } else {
       predicate = prefix + predicate;
     }
     Literal newLit = new Literal(predicate, l.isNegated(), l.arity());
     for (int i = 0; i < l.arity(); i++) {
       newLit.set(l.get(i), i);
     }
     newLiterals.add(newLit);
   }
   return new Clause(newLiterals);
 }