Loading and querying knowledge bases
Download the knowledge bases
kb3.pl(which are the knowledge bases that we just talked about). To download, right click on the following links and choose 'save link to disk'.
kb1.pl kb2.pl kb3.pl
?-prompt. This loads knowledge base
kb1.pl. Prolog should respond with
% kb1.pl compiled 0.00 sec, 0 bytes Yes
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
Is ron a wizard?
Is ron a muggle?
Who is a muggle?
Who does crookshanks chase?
Who chases whom?
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 start writing crazy
things on the screen without getting back to showing you the
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
Load and query the other two knowledge bases (kb2.pl and
kb3.pl), as well. It is probably a good idea to clean Prologs
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
Play a bit with the knowledge bases
kb3.pl, before going on to the next section, which will tell you how to write your own knowledge bases.
Next: Writing knowledge bases.