public Term substitute(Term term, Term replacement) {
        // The only thing that you can substitute in a predicate is an argument,
        // so we just have to iterate over all arguments and propagate the
        // substitution request.
        List<Term> substitutedArgs = new ArrayList<Term>(args.size());
        for (Term arg : args) {
            substitutedArgs.add(arg.substitute(term, replacement));
        }

        return new Predicate(name, substitutedArgs);
    }