I have the following fact in my knowledge base: distance(c2, c5, 20, 1)
.
But when I try to query distance(c2, c5, X-0, 1)
, (or any other number instead of 0), this returns false. Why is that? Shouldn't X just bind to 20 since 20-0=20?
Prolog interprets that as a term with functor name dash
and arity 2
- evidence:
?- Term = X-0, Term = -(X, 0), functor(Term, Name, Arity).
Term = X-0,
Name = (-),
Arity = 2.
Use e.g. is for arithmetic:
?- X = 5, Y is X - 0.
X = Y, Y = 5.
?- X = 5, Y is X-0.
X = Y, Y = 5.