I found compare/3 to be disappointingly illogical as a learner ![]()
Exceptions are a last resort, for when there are no other reasonable actions… how about, for a point-in-time comparison:
compare_sound(C, X, Y) :-
( X \= Y
-> compare(S, X, Y),
% Will be < or > sign
C = comp(S)
; X == Y
-> C = comp(=)
% Insufficiently instantiated for sound comparison
; C = insuf
).
Results:
?- compare_sound(C, A, A).
C = comp(=).
?- compare_sound(C, b(_), a(_)).
C = comp(>).
?- compare_sound(C, A, B).
C = insuf.
I think these results would be the least surprising for a learner.