General
Material
Lecture 1
 Slides Practical Session
Lecture 2
 Slides Practical Session
Lecture 3
 Slides Practical Session
Lecture 4
 Slides Practical Session
Lecture 5
 Slides Practical Session

# 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).
```
Logically, the order of the goals should not make a difference. For all X, if X is magical and not a dementor, then Harry likes it means the same as for all X, if X is not a dementor and is magical, then Harry likes it..

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.