2.1.1.1 Starting SWI-Prolog on Unix
By default, SWI-Prolog is installed asâswipl'. 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:
$ swipl Welcome to SWI-Prolog ... ... 1 ?-
After starting Prolog, one normally loads a program into it using consult/1, which 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]. true. ?-
Alternatively, the source file may be given as command line arguments:
$ swipl likes.pl Welcome to SWI-Prolog ... ... 1 ?-
Both the above assumelikes.pl
is in your working directory. If you use the command line version swipl the working directory is the same as the shell from which you started SWI-Prolog. If you started the GUI version (swipl-win) this depends largely on the OS. You can use pwd/0 and cd/0 to find and change the working directory. The utility ls/0 lists the contents of the working directory.?- pwd. % /home/janw/src/swipl-devel/linux/ true. ?- cd('~/tmp'). true. ?- pwd. % /home/janw/tmp/ true.The file
likes.pl
is also installed in a subdirectorydemo
insides SWI-Prolog's installation directory and may be loaded regardless of the working directory using the command below. See absolute_file_name/3 and file_search_path/2 for details on how SWI-Prolog specifies file locations.?- [swi(demo/likes)]. true.
After this point, Unix and Windows users unite, so if you are using Unix please continue at section 2.1.2.