Negation (cont.)
Consider the following two knowledge bases. The only difference is the order of the two goals in the body of the rule.
-
kb.day1.not1.pl
magical(norbert). magical(buckbeat). magical(ssss). dementor(ssss). like(harry,X) :- magical(X), not(dementor(X)).
-
kb.day1.not2.pl
magical(norbert). magical(buckbeat). magical(ssss). dementor(ssss). like(harry,X) :- not(dementor(X)), magical(X).
However, check out what happens if you ask the query
like(harry,X)
. You haven't learned anything about
how the Prolog interpreter goes about finding an answer. We will
discuss that tomorrow and then you will be able to explain why
Prolog is answering differently when the first knowledge base is
loaded then when the second knowledge base is loaded. For the
moment, just remember to be a bit careful when using
not
--- it may not do exactly what you think it
should do.