A reported bug on standard order for cyclic terms (#1529) made it free to detect cyclic terms that have no defined order. As a result, SWI-Prolog now has a flag incomparable that can be set to arbitrary (default, old behaviour, i.e., different representation leads to different results and transitivity is not guaranteed) and error, raising representation_error(standard_order(Sub1, Sub2)), where the culprits are the cycles that cause the problem. So, now we get
102 ?- set_prolog_flag(incomparable, error).
true.
103 ?- X=f(X,0),Y=f(Y,1), sort([X,Y], L).
ERROR: Cyclic terms have no standard order: @(S_1,[S_1=f(S_1,0)]) and @(S_1,[S_1=f(S_1,1)])
ERROR: In:
ERROR: [16] sort([f(...,0),...],_280)
ERROR: [14] toplevel_call(user:user: ...) at /home/jan/src/swipl-devel/build/home/boot/toplevel.pl:1678
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
In addition, the new partial_compare/3 gives (regardless of the flag):
109 ?- X=f(X,0),Y=f(Y,1), partial_compare(Diff, X, Y).
X = f(X, 0),
Y = f(Y, 1),
Diff = incomparable(f(X, 0), f(Y, 1)).