You will see that two of the original rules contain the test
not( flies(A) )The
not
predicate is unique amongst those you have
met so far because it
takes
a goal as argument. Suppose you have the fact
flies( pip ).and you ask the question
not( flies(pip) ).You will get the answer
no
. If you then delete flies(pip)
and ask
the same question, you'll get the answer yes
. So not
inverts the
truth of its argument.
In some circumstances, not
can be tricky to
use. You can get an example of this by asking
not( flies(P) ).and observing that it does not give you the names of all the non-flying animals. More will be said about this in Lesson 6; in brief,
not
does funny things if its argument contains variables which don't have values
when not
is called. This doesn't happen in the classifier, because I've
written it so that all such variables will get values before not
is
called.
Finally, please note again that Prolog is not an expert system. It lacks features that an expert system should have, such as an easy means of entering observable data, and an explanation in English of its conclusions. However, for the purpose of this course, that does not matter, and you can use Prolog to simulate the kind of reasoning a real expert system would do.