?- dif(XM,-a),XM= -X,X=a.
X = a, XM = - a.
BTW, X \= Y is a safe approximation for dif/2 too. If it succeeds, there is no need for further investigation.
The most naive implementation is to recheck
X == Y -> upon success, dif/2 does not hold. X \= Y -> upon success. dif/2 does hold.whenever something "happens" with variables in subterms of X and Y.
The big advantage of this seemingly naive implementation is that it avoids reposting of redundant dif/2 goals:
?- X\=Y.
false.
?- dif(X,Y),X\=Y.
X = _28, Y = _52, dif(X, Y).
Perhaps @triska could advise on porting the dif/2 code he co-wrote for SWI to Scryer?
I'd say: become more conforming first.
@mthom: Once the conformity issues are solved, I will implement a new dif/2 implementation that takes Scryer's better interface for attributed variables into account.
I am looking forward to doing this with a system where strong syntactic guarantees hold!
An implementation would be fine (and simple) which only traverses qua term_variables/2
Most helpful comment
@mthom: Once the conformity issues are solved, I will implement a new dif/2 implementation that takes Scryer's better interface for attributed variables into account.
I am looking forward to doing this with a system where strong syntactic guarantees hold!