If Sub is a sub term of Term, Vars is bound to the list of variables
in Sub that also appear outside Sub in Term. Note that if Sub
appears twice in Term, its variables are all considered shared.
An example use-case is refactoring a large clause body by
introducing intermediate predicates. This predicate can be used to
find the arguments that must be passed to the new predicate.