1
votes

If I had the following SWI Prolog queries and answers

[A,B,C] ins 1..3, A#= B + C.

And needed to select from below which were incorrect:

A in 2..3,
B in 1..3,
C in 1..3.

Would I be correct in thinking that A in 2..3 is not possible as in no case can A = 3?

1
there's only one answer here. What do you mean? - m09
and this query gives back A in 2..3, A #= B + C, B in 1..2, C in 1..2, not what you gave - m09
and if you want A, B and C to be different you have to say so, for example with an all_different constraint. - m09

1 Answers

2
votes

Actually, what the constraint does, is to reduce the domains of B and C.

Since their sum must be in range 1..3, and both have range 1..3. they must assume values in range 1..2.

Then A in 2..3 it's the only right answer there.