Source:
public ASTNode transform(ConjunctiveFormula conjunctiveFormula) { Substitution<Variable, Term> transformedSubstitution = ImmutableMapSubstitution.empty(), tmp; List<Pair<Term, Term>> transformedEntries = new ArrayList<>(); for (Map.Entry<Variable, Term> entry : conjunctiveFormula.substitution().entrySet()) { Term key = (Term) entry.getKey().accept(this); Term value = (Term) entry.getValue().accept(this); if (key instanceof Variable && (tmp = transformedSubstitution.plus((Variable) key, value)) != null) { transformedSubstitution = tmp; } else { transformedEntries.add(Pair.of(key, value)); } } ConjunctiveFormula transformedConjunctiveFormula = ConjunctiveFormula.of( transformedSubstitution, resolveGlobalContext(conjunctiveFormula)); for (Pair<Term, Term> pair : transformedEntries) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( pair.getLeft(), pair.getRight()); } for (Equality equality : conjunctiveFormula.equalities()) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( (Term) equality.leftHandSide().accept(this), (Term) equality.rightHandSide().accept(this)); } for (DisjunctiveFormula disjunctiveFormula : conjunctiveFormula.disjunctions()) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( (DisjunctiveFormula) disjunctiveFormula.accept(this)); } if (conjunctiveFormula.globalContext().stage == Stage.REWRITING) { transformedConjunctiveFormula = context == null ? transformedConjunctiveFormula.simplify() : transformedConjunctiveFormula.simplify(context); } return !transformedConjunctiveFormula.equals(conjunctiveFormula) ? transformedConjunctiveFormula : conjunctiveFormula; }

Target:
public ASTNode transform(ConjunctiveFormula conjunctiveFormula) { Substitution<Variable, Term> transformedSubstitution = ImmutableMapSubstitution.empty(); List<Pair<Term, Term>> transformedEntries = new ArrayList<>(); for (Map.Entry<Variable, Term> entry : conjunctiveFormula.substitution().entrySet()) { Term key = (Term) entry.getKey().accept(this); Term value = (Term) entry.getValue().accept(this); if (key instanceof Variable) { Substitution<Variable, Term> tmp = transformedSubstitution.plus((Variable) key, value); if (tmp != null) { transformedSubstitution = tmp; } else { transformedEntries.add(Pair.of(key, value)); } } else { transformedEntries.add(Pair.of(key, value)); } } ConjunctiveFormula transformedConjunctiveFormula = ConjunctiveFormula.of( transformedSubstitution, resolveGlobalContext(conjunctiveFormula)); for (Pair<Term, Term> pair : transformedEntries) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( pair.getLeft(), pair.getRight()); } for (Equality equality : conjunctiveFormula.equalities()) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( (Term) equality.leftHandSide().accept(this), (Term) equality.rightHandSide().accept(this)); } for (DisjunctiveFormula disjunctiveFormula : conjunctiveFormula.disjunctions()) { transformedConjunctiveFormula = transformedConjunctiveFormula.add( (DisjunctiveFormula) disjunctiveFormula.accept(this)); } if (conjunctiveFormula.globalContext().stage == Stage.REWRITING) { transformedConjunctiveFormula = context == null ? transformedConjunctiveFormula.simplify() : transformedConjunctiveFormula.simplify(context); } return !transformedConjunctiveFormula.equals(conjunctiveFormula) ? transformedConjunctiveFormula : conjunctiveFormula; }