SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

Unexpected dif/2 failure #112

Closed ghost closed 2 years ago

ghost commented 2 years ago

I tried this query on SWISH:

?- current_prolog_flag(version, V).
V = 80510.
?- A=[B|_], C=[_|_], dif(C, A), C=[B|B].
false.
?- 

I also tested it on stable version 8.4.2 and I have the same result.

JanWielemaker commented 2 years ago

Thanks for reporting. This is a known problem with cyclic terms for dif/2. If I recall correctly a work around is to use this alternative. Unfortunately there are scenarios where this behaves quadratic while dif/2 behaves linear.

?- when(?=(A,B), A \=B).
ghost commented 2 years ago

Cyclic term but:

?- A=[B|_], C=[_|_], C=[B|B], acyclic_term([A,B,C]).
A = [B|_],
C = [B|B].

?- A=[B|_], C=[_|_], C=[B|B], C=A, acyclic_term([A,B,C]).
A = C, C = [B|B].

I don't understand.

JanWielemaker commented 2 years ago

You are right. I misread. Looks like a new bug. The work-around still works.

JanWielemaker commented 2 years ago

Thanks for your patience. Should be fixed with SWI-Prolog/swipl-devel@e8c2e0dd02446e61543e6c41bb76429c8186c5f0