SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

dif/2 incorrect Ⅳ #118

Closed UWN closed 1 year ago

UWN commented 1 year ago

By adding an unrelated equation sharing a variable, success turns into failure.


Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.16)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- set_prolog_flag(occurs_check,true).
true.

?- -X=X.
false.

?- dif(A, B),         A=[D|C], B=[E|D], A=[E|B], E = e.
A = [e, e|e],
B = C, C = [e|e],
D = E, E = e.

?- dif(A, B),  _=C,       A=[D|C], B=[E|D], A=[E|B], E = e.
false, unexpected.
JanWielemaker commented 1 year ago

Interesting. Possibly variable ordering plays a role (of course this should not be the case).

UWN commented 1 year ago

Maybe more helpful:

?- dif(A, B),       A=[D|C], B=[E|D], A=[F|B],E=F, E = e.
A = [e, e|e],
B = C, C = [e|e],
D = E, E = F, F = e.

?- dif(A, B), _=C,  A=[D|C], B=[E|D], A=[F|B],E=F, E = e.
false, unexpected.

?- dif(A, B), _=C,  A=[D|C], B=[E|D], A=[F|B],E=F.
false, unexpected.

?- dif(A, B), _=C,  A=[D|C], B=[E|D], A=[F|B].
A = [F, E|F],
B = C, C = [E|F],
D = F.