There are five library files that are specifically concerned with list processing. They are
compare/3in the reference pages) so as to be much more efficient than
library(sets)for any but the smallest sets.
As a general rule, if a predicate defined here has a counter
(a non-negative integer) as one of its arguments, it will suffice
for the counter argument to be instantiated. Otherwise, at least one of
the list arguments must be a proper list. Failing this, the
predicate may backtrack forever trying ever longer lists.
When you look at the code you will see that some of the library routines
same_length/3 to ensure termination.