これは簡単な方法です (ただし、組み込みの述語を十分に活用しているわけではありません)。
% an item is sorted when the two terms are in standard order of terms
% note that you use @< and @> when you are comparing things that aren't numbers
sortitem((A, B), Item) :-
(A @< B,
Item = (A, B));
(A @> B,
Item = (B, A)).
% a list of items is sorted when each of the individual item's terms are sorted (but we
% don't care if the items themselves are in order)
sortlistitems([], []).
sortlistitems([H|T], List) :-
sortitem(H, HSorted),
sortlistitems(T, TSorted),
List = [HSorted|TSorted].
% sorting with sort/2 removes duplicates and puts the items in order
removeduplicateitems(X, Y) :-
sortlistitems(X, XSorted),
sort(XSorted, Y).
テスト:
?- removeduplicateitems([(a, b), (a, c), (b, a), (b, c),(c, a),(c, b)], X).
X = [ (a, b), (a, c), (b, c)]