SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

Incorrect behaviour for a simple logical disjunction. #125

Closed RECHE23 closed 1 year ago

RECHE23 commented 1 year ago

With this code:

test1(A, B) :- member(A, [true, false]), member(B, [true, false]), (A ; B).
test2(A, B) :- member(A, [true, false]), member(B, [true, false]), (((A ; B) -> true) ; A ; B).

I get this result:

1 ?- test1(A, B).
A = B, B = true ;
A = B, B = true ;
A = true,
B = false ;
A = false,
B = true ;
false.

2 ?- test2(A, B).
A = B, B = true ;
A = true,
B = false ;
A = false,
B = true ;
false.

For a simple logical disjunction, I don't see any logical reason why A = B, B = true appears twice in test1(A, B).

Both expressions should behave the same way since they are logically equivalent.

JanWielemaker commented 1 year ago

Prolog does not remove duplicate answers. You can do so using tabling or distinct/1. Please do not use the issues pages for basic Prolog questions. Use the forum on Discourse or Stackoverflow.

RECHE23 commented 1 year ago

Prolog does not remove duplicate answers. You can do so using tabling or distinct/1. Please do not use the issues pages for basic Prolog questions. Use the forum on Discourse or Stackoverflow.

So you don't see any flaw in this? This is really the expected behaviour?

JanWielemaker commented 1 year ago

Try discourse, I'm not going to read this in all detail. Just, logically equivalent answers are part of normal Prolog SLD resolution.