-
Notifications
You must be signed in to change notification settings - Fork 1
Getting started
Log on to a (Linux) lab machine and start up SWI-Prolog with the command swipl. (The location of the most recent swipl binary is /lib64/swipl-7.4.2/bin/x86_64-linux/swipl
but it's linked to /bin/swipl
)
SWI-Prolog starts up as follows:
Welcome to SWI-Prolog (threaded, 64 bits, version 7.4.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?-
'?-' is the Prolog prompt at which you can type a query, ended by a period. Prolog programs should be stored in a file and then read into the Prolog interpreter, by means of the query ?-consult(file). (which can be abbreviated ?-[file].). The default extension of a SWI-Prolog file is .pl, so the query ?-consult(file). will either load file or file.pl. If your filename contains non-alphanumeric characters you should use single quotes (e.g. ?-consult('file.txt'). or ?-['file.txt'].).
The following command terms can be typed at the pl prompt ?-
.
Type straight into the database. Type <Ctrl-d> to stop. This is only useful for trying things out quickly; consulting a file is the normal way to edit a Prolog program.
Load the Prolog program in mycode.pl
into the Prolog database.
Display a listing of the current contents of the Prolog database.
Look for changes in time stamps of the consulted Prolog program (or programs) and reconsult them if changes have occurred.
Display manual at the specified topic. e.g. help(bagof).
Display manual and do a free text search for the word. e.g. apropos(append).
Close the SWI-Prolog shell - without confirmation!
pl shell can also be closed with <Ctrl-d>.
See this page for details.
See this page for details.
Important: Please note that your assignments must work on the lab machines even if you develop them on your own computer. SWI-Prolog is highly portable between platforms provided that you do not use platform-specific features (e.g. such as calling MS Windows API). None of the assignments require the use of platform-specific features.