I not shure how in my exam answer to this qestion:
Let's consider this prolog program:
p(a,b).
p(b,c).
p(c,a).
q(X,X).
q(X,Y):-p(X,Z),q(Z,Y).
and question:
?- q(X,X).
And valid? answer is:
Above aim is fulfilled in infinitely many ways, but none of them is substitution X = b.
And I don't get it, really. IMO this predicate can be fullfilled in 3 ways:
q(a,a) or q(b,b) or q(c,c).
What I don't understand here? Or maybe the answer is wrong and I just waste time and my answer is good?
X=b. - nhahtdhq(d,d)orq(e,e)to be evaluated to true. As long as the 2 arguments are the same, the query will satisfy the ruleq(X,X). - nhahtdh?- q(X,X).. Noq(b,b)will be ever produced. Were you to issue a query?- q(b,b).or?- q(42,42).the two would indeed succeed; but that is not what is asked. - Will Ness