The current stable release of SWI Prolog is 7.2.3; other recent versions should be fine as well.
When you start Prolog, you should see an introductory greeting and then the Prolog command prompt:
Welcome to SWI-Prolog ..... ?-
The Lab says it will have SWI Prolog installed on attu.cs.washington.edu by the start of the quarter; you can run it there if you don't want to install it on a personal machine.
If you're planning on loading a file, on attu (and on other linux or Macintosh systems) it's simplest to first navigate to the directory that contains your file, so that Prolog can find it without specifying a path or changing the working directory.
Run Prolog from the command line using
swipland then load the file from within Prolog.
You can also give a command line argument with a file to be loaded, for example
swipl basics.pl
The Lab has also installed SWI Prolog on the Windows machines in the undergrad labs.
SWI Prolog is available for Windows, Mac, and Linux. Here's the download page: http://www.swi-prolog.org/Download.html.
Macintosh hints: if you use the Finder and double-click on SWI Prolog in Applications, depending on your security settings, you may get an error. If you do, try right-clicking (or control-clicking) on the application instead, and say “run it anyway”. You can also run it from the command line using the swipl executable in /Applications/SWI-Prolog.app/Contents/MacOS, assuming you installed it in the default location. To use the graphical debugger, install xquartz (X11), then open a X11 terminal, and run Prolog from there.
Windows hints: if you want to load a file, at least on the instructional machines you'll either need to specify an absolute file path, or change the current working directory to the appropriate place. Here's how to change the current working directory from within Prolog. If your files are in Z:\cse599, type this at the Prolog command prompt:
working_directory(X, 'Z:\\cse599').
(The double backslash is needed because a single backslash indicates some special character, e.g. \n for newline. And in case you're wondering, X will be unified with the previous working directory.)
Double-clicking on a .pl Prolog source file is going to start perl, so that's not going to work.
A few essential commands:
Prepare source files using any convenient editor. The standard file extension for Prolog files is .pl
If you want to use emacs, include this in your .emacs file in your home directory:
(setq auto-mode-alist (cons (cons "\\.pl" 'prolog-mode) auto-mode-alist))(Without this, emacs is going to think you're writing in perl.)
There are other versions of emacs Prolog mode if you want to try one - see e.g. Using SWI-Prolog with GNU-Emacs.
SWI Prolog provides two interfaces to the debugger: a text-based and a graphical interface:
The graphical debugger doesn't seem to be installed with the version of Prolog on the Lab linux machines, unfortunately. It is on the Lab Windows machines, though.For old-school debugging use the write goal. For example, here it is in the body of a rule:
notworkingyet(A) :- complicated(A), write('the result after calling complicated is: \n'), write(A), yetmorecomplicated(A).