We have ?=/2 , to determine whether 2 terms are certainly different.
However, I’d like to know whether comparing the 2 terms results in
=, i.e. the result of compare/3 , and to be able to use it confidently when the terms might be non-ground - it should fail if uncertain.
I’m probably asking for an imaginary
comparable/2, with results such as:
comparable(f(1, 0), f(X, 0)).
… fails - X is not sufficiently instantiated to be comparable to 1.
comparable(f(2, X), f(1, Y)).
… succeeds - 2 is greater than 1, no need to care about X and Y.
Surely there is something better than waiting for both terms to be ground/1?
Google finds sorting - How to define (and name) the corresponding safe term comparison predicates in ISO Prolog? - Stack Overflow , but the answers there are, erm, not obviously sound or verifiable
The inspiration for this question comes from posting my comparison code in hubris, and having it collide with false’s scrutiny