Scryer-prolog: dif/2 incorrect

Created on 16 Apr 2019  路  6Comments  路  Source: mthom/scryer-prolog

?- 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.

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!

All 6 comments

The most naive implementation is to recheck

  1. X == Y -> upon success, dif/2 does not hold.
  2. 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mkohlhaas picture mkohlhaas  路  3Comments

UWN picture UWN  路  4Comments

notoria picture notoria  路  4Comments

UWN picture UWN  路  3Comments

triska picture triska  路  4Comments