Installing SWI Prolog
1. Visit the SWI-Prolog Download page.
2. Choose the binary distribution appropriate for your operating system, such as the Unix Binaries. The remaining instructions are for the Windows install. The instructor or the GTA can help with the Linux install during office hours.
3. Use the default installation location: “C:\Program Files\SWI-Prolog”.
4. During the installation process, you will be asked if you would like to associate SWI-Prolog with a particular file extension--the default is .pl . You can choose any extension you like. Since some people already use .pl as the extension for Perl files (and have an appropriate file association) you can use a different extension for Prolog (Dr. Edwards uses .plg , for example).
5. Download a prolog program (e.g., agatha_christie.plg) and save it to the folder of your choice.
6. Start SWI-Prolog using the SWI-Prolog shortcut that was added to your start menu, which will open a window with the Prolog prompt. Note that you can edit the properties of that shortcut to specify a working directory of your choice when Prolog starts up.
?-
cd('
c:/this/is/a/path ').
9. Use Unix-style forward slashes ( / ) rather than backslashes in the path name. Prolog uses the backslash as an escape character within strings. Use the cd predicate to change the working directory to the folder where you have saved the sample Prolog program. You can also use pwd (no arguments, no parentheses) as a Prolog goal to print out the current working directory.
10. At the Prolog prompt, type ['agatha_christie.plg']. Be sure to include the period at the end. To load and execute a file that is not in the current working directory, you can specify a full pathname instead of just the file name inside the ['...']. For full path names, use Unix-style paths where "/" is the separator, which are understood Prolog on all platforms.
?- ['agatha_christie.plg'].
husband killed brother.
son and alice were together in the bar.
daughter was alone.
agatha_christie.plg compiled, 0.00 sec, 3,904 bytes.
12. If you receive this output, then your installation is successful.
?- halt.
14. Note that you can choose to use either .plg (as shown here) or whatever you have chosen as the SWI-Prolog default file extension in your file name. Prolog will be happy with whatever extension you use. If you use the file extension that you chose as SWI-Prolog's default during installation, then you need not specify the extension when loading a file. Prolog will also read in any other file you specify with any other extension, as long as you provide your extension as part of the file name when loading it.
15. Send email to arthur@vt.edu if you find errors in this procedure or if you have serious difficulty installing Scheme by this procedure. You may prefer to see the instructor or the GTA during office hours.
Prolog and Logic Programming Tutorials Online
A number of Prolog resources are available on the web. Here is a selection of links to tutorials. Feel free to browse and follow the one that best suits your tastes:
· The On-Line Guide to Prolog Programming is an excellent on-line source of information. It includes a tutorial section and a wealth of other details about logic programming.
· Prolog: A Tutorial Introduction is used by the undergrad programming languages class at another university, and assumes SWI-Prolog. It has a good section on Prolog lists.
· Another Prolog tutorial with many example programs
o Section 2.7 on lists and sequences
· SWI-Prolog's own list of Prolog tutorials and links