Why is this prolog query both true and false?

My SWI-Prolog knowledge base contains the following two facts:

f(a,b).
f(a,c).

Now if I pose the query

?- f(a,c).
true.

But

?- f(a,b).
true ;
false.

Why is f(a,b) both true and false? This also happens when there are three facts in the KB. If I append f(a,d). to the KB, then f(a,d) is true (only), but f(a,b) and f(a,c) are both true and false. What's going on, and what can I do so that Prolog answers (only) true to these queries?



Bookmark and Share   Read more Read more...   Source: Stack Overflow