A Tutoring Lab
for Logic Programming and Artificial Intelligence
Table of Contents
-
How do I write a Prolog program and execute it ?
-
Where can I find a Prolog interpreter?
-
Why special symbols do not appear in the screen ?
-
What is 'Warning: singleton variable' ?
-
What do I do if I get 'Action (h for help)' ?
How do I write a Prolog program and execute it ?
Create a directory in your hard disk (e.g. C:\MyPrologPrograms).
You can write your Prolog program in any text editor (e.g. notepad). If
you are using SWI-Prolog, save it with an extension ".pl" in the directory
with your programs, so that it can be recognised as a SWI-Prolog program.
Leave the editor open. You may need it.
Click on SWI-Prolog icon. You are prompt with a "?-".
Make sure you are working in the appropriate directory (where your program
is stored). Type "?-pwd." to get the
name of the current directory. If it is different from the one you need
then type for example "?-cd('C:\MyPrologPrograms')."
If you type "?-ls." you are going to
get a list of files contained in this directory.
In order to load the file into the Prolog interpreter
use consult/1 and type the name of
the file, for example "?-consult(test)"
if test has an extention .pl or the complete filename included in single
quotes. Alternatively, you could use "?-[test].".
Now you can pose any query.
Where can I find a PROLOG interpreter ?
You can download a PROLOG interpreter to be used for running the programs
that you will need to implement. We recommend that you download SWI-PROLOG
from the site:
http://www.swi.psy.uva.nl/usr/jan/SWI-Prolog.html
In there you will find installation instructions. Installing it is
quite straightforward. In case you have any other PROLOG available please
contact us to discuss compatibility issues.
Why special symbols do not appear on the screen ?
The easiest way to get around it is to set the option "Use document specified
fonts" in the Preferences/Fonts option, if you are using Netscape Navigator.
What is "Warning: Singleton Variable" ?
It is just a warning you get from the SWI-interpreter. Singleton is a variable
that appears only once in a program clause and therefore there is no reason
to have a name (it could have been anonymous "_"
instead). However, you are prompt with this warning because you might
have mispelled the name of the variable. For example:
father(Father,Child):-
parent(Father,Child), male(Fathr).
In the above, Fathr is a singleton
variable.
What do I do if I get "Action (h for help)" ?
Well, you type "h" to get a menu for
possible actions. Normally, you type "a"
for aborting the execution and get back to the "?-".
In any case to abort execution type "Ctrl-C".
P.Kefalas.
Copyright © [TEI Thessaloniki]. All rights reserved.
Revised: 12/3/99.