By default, SWI-Prolog is installed as `pl', though some administrators call it `swipl' or `swi-prolog'. The command-line arguments of SWI-Prolog itself and its utility programs are documented using standard Unix man pages. SWI-Prolog is normally operated as an interactive application simply by starting the program:
machine% pl Welcome to SWI-Prolog (Version 5.6.42) Copyright (c) 1990-2007 University of 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). 1 ?-
After starting Prolog, one normally loads a program into it using
which --- for historical reasons --- may be abbreviated by putting the
name of the program file between square brackets. The following goal
loads the file
likes.pl containing clauses for the
predicates likes/2 :
?- [likes]. % likes compiled, 0.00 sec, 596 bytes. Yes ?-
After this point, Unix and Windows users unite, so if you are using Unix please continue at section 2.1.2.
After SWI-Prolog has been installed on a Windows system, the following important new things are available to the user:
plcontaining the executables, libraries, etc. of the system. No files are installed outside this directory.
.plis associated with the program plwin.exe. Opening a
.plfile will cause plwin.exe to start, change directory to the directory in which the file-to-open resides and load this file.
The normal way to start with the
likes.pl file mentioned
section 188.8.131.52 is by simply
double-clicking this file in the Windows explorer.
After loading a program, one can ask Prolog queries about the program. The query below asks Prolog what food `sam' likes. The system responds with X = <value> if it can prove the goal for a certain X. The user can type the semi-colon (;)3On most installations, single-character commands are executed without waiting for the RETURN key. if (s)he wants another solution, or RETURN if (s)he is satisfied, after which Prolog will say Yes. If Prolog answers No, it indicates it cannot find any (more) answers to the query. Finally, Prolog can answer using an error message to indicate the query or program contains an error.
?- likes(sam, X). X = dahl ; X = tandoori ; ... X = chips ; No ?-