Directions for using PDProlog
written by Dr. Elizabeth Adams
Use any editor you
want to create your Prolog database. I
have two databases in this directory.
Make sure that
your file has the extension
.pro
To get into PDProlog, click on PDProlog.exe or in DOS type PDProlog <cr>
To get out of PDProlog type exitsys.<cr> at the prompt
To load a file, which is easier if you have it in the same directory as your
PDProlog.exe,
type consult filename.<cr>
where filename is the name of the file For example: consult
family.<cr>
alternatively you can type consult (‘filename.pro’). – using single quotes. You can use a path if the database you wish
to consult isn’t in the same directory.
To see what was
loaded or what is currently in the database type listing.<cr>
To see what the
predicates in the database are and how many of each there are type dir p.<cr>
To add a fact or
rule to your database type either asserta or assertz followed by the fact or rule. asserta
adds what you type to the front of the database. assertz adds what
you type to the end of the database. Here's an example
: assertz
(female(mary)).<cr>
will add the predicate female(mary).
to the end of the database.
Neither adds anything to the file that you loaded. Nothing that you typed in using asserta or assertz will still be
there when you exit pdprolog and come back.
If you want to ask
a question (i.e. pose a query), just type it in. For example, to see who the women in the
family data base are, just type: female(Who).<cr> Upper case
letters in the argument list are variables.
Lower case are constants.
If you look at the
predicate (fact)
mother (martha, astrid),
you have no way of knowing who is the mother and who is the daughter so you
don't know whether to pose the query
mother(Mother, Daughter).<cr> or mother
(Daughter, Mother).<cr>
There is nothing
in the language which tells you which is correct. Sometimes, it is possible to tell if one of
the names is male but the best thing to do when you are constructing a database
is to put in a comment showing which is appropriate. In PDProlog, comments are
enclosed in /*
*/
An appropriate
comment would be /* mother (mother child)
*/
You can keep a
record of your work by using the built-in predicate tell. The problem with using
tell is that it is a total re-direct to disk
and you don't see what is happening while it is occurring.
If you want to try
it type
tell 'drivename:\path\filename.out'. <cr> You need the single quotes if you are not
using a filename in the current directory (i.e. if you need to specify drive
and path).
When you are done
working type told.<cr>
before you type exitsys.
Try posing some
queries on the family database.
There is a word
file labeled PrologAssignment.doc which asks you to tell what the
results of some queries will be and to write some other queries using the
database in officePro.txt
The file Prolog.doc is
documentation for the Automata Design Associates PDProlog. The PD stands for Public Domain which is why
we can give it to you. The file is 60
pages long so it's probably not a good idea to print it . You can search it and print selected
information as needed.