I am doing some revision for constraint logic programming and wanted to know how I can read the following queries in order to predicate their results correctly.
Basically there is a question which asks whether or not the answer provided by the following query is correct or not.
So this is the question
Consider the following queries and answers. Some answers coincide
with what SWI-Prolog would infer whereas others are erroneous.
Indicate which answers are genuine and which ones are fake (no
explanation is required).
(i) ?- [X, Y, Z] ins 0 .. 4, X #= Y + 1.
X in 1..4, Y in 0..3, Z in 0..4.
(ii) ?- [X, Y, Z] ins 0 .. 4, X #= Y + Z.
X in 0..4, Y in 0..2, Z in 0..2.
(iii) ?- [X, Y, Z] ins 0 .. 4, X #= Z - Y.
X in 0..4, Y in 0..4, Z in 0..4.
(iv) ?- [X, Y, Z] ins 0 .. 4, X #= Y * Y, Z #= -Y.
Y = 0, Z = 0.
My question is what is the best way to read the query in order to determine whether the answer is correct or not.
Several steps:
In your case, the shown answer is a syntactically valid conjunction, so it is definitely a candidate for a correct solution. However, the answer admits solutions (exercise: which?) that the original query does not, and so the answer is not correct.