-
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.2.3/bin/x86_64-linux/swipl
but it's linked to /bin/swipl
)
SWI-Prolog starts up as follows:
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.2.3)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For 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 into the pl command line shell.
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.
Display a listing of the current contents of the Prolog database.
Look for changes in file dates 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.
Another way of executing Prolog code is to create a SWISH notebook (read more), which is equivalent to Jupyter environment in Python.
To run it, first go to cd /opt/swish/
and then run swipl run.pl
. This should start a SWISH server, so now you can open your favourite web browser and go to http://localhost:3050/
.
SWISH examples and help are available through its interface.
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.