In Prolog you only have variables that maybe different or aliased. _
is just a concept of read_term/2 which makes variables that have the same name be the same variable except for _
, which produces a new variable for every occurrence.
So, [_|_]
is exactly the same as [_1, _2]
(using numeric syntax to avoid the discussion about singleton/multiton).
list_to_set/2, like sort/2 and the ord_* predicates all compare terms based on the standard order of terms. This means that only terms that compare equal under ==/2
are removed. Further instantiation of elements may cause more elements to become equal under ==/2
unless ?=/2 is true for all pairs of the set. ?=/2 is true if the two arguments are equal or can never become equal.