Download the knowledge bases kb1.pl, kb2.pl, and kb3.pl
(which are the knowledge bases that we just talked about). To
download, right click on the following links and save the file in
your disk: in My Documents/Prolog.
kb1.pl kb2.pl kb3.pl
Now type [kb1]. at the ?- prompt. (Use Alt Gr [ to type [ ). This loads
knowledge base kb1.pl. Prolog should respond with
% kb1.pl compiled 0.00 sec, 1,448 bytes
true
Type listing. to see which facts and clauses Prolog now knows about.
If you now send queries to Prolog, they will be answered based on this knowledge. Try this. Here are some queries that you could send.
Is ron a wizard? wizard(ron).
Is ron a muggle? muggle(ron).
Who is a muggle? muggle(X).
Who does crookshanks chase? chases(crookshanks,X).
Who chases whom? chases(X,Y).
To let prolog show all the possible answers to e.g. muggle(X) type next to the provided answer ; till it shows no (no other answers).
Don't forget to put a full stop at the end of each query before
pressing return. If you do forget to put a full stop, Prolog will
react by just doing nothing. This is what you will see on the
screen:
?- wizard(harry)
|
To fix it just type a full stop and press return again:
?- wizard(harry)
| .
Yes
If something else goes wrong and Prolog starts writing crazy
things on the screen without getting back to showing you the ?-
prompt, type Ctrl-c. This should show you the following line:
Action (h for help) ?
Type a (for abort) and press return. This should get you back to
the ?- prompt.
Load and query the other two knowledge bases (kb2.pl and
kb3.pl), as well. It is probably a good idea to clean Prolog's
internal knowledge base before loading a new one. The easiest way
to do this, is to actually leave Prolog by typing halt. and
restart it (by typing swipl).
Play a bit with the knowledge
bases kb1.pl, kb2.pl, and kb3.pl, before going on to the next
section, which will tell you how to write your own knowledge
bases.