This FAQ is designed specifically for Lehigh students taking CSE 327. If you don't find the answer to your question here, you may also want to try the official SWI-Prolog FAQ.
If you are in a public Lehigh computer lab, first check to see if SWI-Prolog is already installed by clicking "Start" and "All Programs". If you see the program in the list, then you do not need to do anything else but select it in order to run it. If it is missing, you can do a standard Lehigh network installation. If you have the standard Lehigh background screen, then you can simply click "Install Software". Otherwise, go to the Start menu, select "All Programs", and then select "Install Software" (it should be at the top of the menu). From the list of available software, select SWI-Prolog and proceed with the install instructions. Note, if you have WIRED access from your dorm room, then this install method should also work.
If you do not have access to Lehigh's standard software installation process, you can download SWI-Prolog yourself. Go to the SWI-Prolog download page and get the stable release. Follow the installation instructions given in the download.
The editor I used in class (called PCE Emacs) comes with your SWI Prolog download. However, the default install is configured to use your normal text editor (usually Notepad). In order to make PCE Emacs the default editor from SWI Prolog, do the following
% :- set_prolog_flag(editor, pce_emacs).
:- set_prolog_flag(editor, pce_emacs).
Sometimes when you consult your Prolog code, you will see an error such as:
Warning: (c:/program files/prolog/myprogram.pl:5): Clauses of mypred/2 are not together in the source-file % myprogram compiled 0.00 sec, 0 bytes
Generally, Prolog programs are easier to read when all of the clauses with the same head are grouped together. Note, this is not required, which is why it is only a warning and not an error. To make the message go away, simply make sure all rules with the same functor in the head (i.e., left hand side) and all facts with the same functor are on consectutive lines.
This warning indicates that you have a statement in which a variable only appears once. This lets you know that there may be a spelling mistake or that you forgot to use the variable elsewhere in the statement. However, there are cases where you simply don't care what binding the variable has. In those cases, you can make the warning go away by replacing the variable with the underscore character "_". This essentially serves as a wildcard that will match anything.
In the following statements, Y, Z and W are all singleton variables:
p(X,Y) :- q(X). s(X) :- t(X,W). r(Z).To may, the warnings disappear, simply change the statements to:
p(X,_) :- q(X). s(X) :- t(X,_). r(_).
Usually, CTRL+D works. If it doesn't, type CTRL-ALT-DELETE and use the Task Manager to shut down SWI-Prolog.
This happens in Windows 7 because SWI Prolog needs administrator privileges to update an index. Simply run the SWI Prolog in administrator mode (right click on the icon and select "Run as administrator") and then select "Reload modified files." This should build the index and you can run SWI Prolog in normal mode from then on. Note, if you are in a public Lehigh lab, you will not be able to run in administrator mode; you'll just have to ignore these errors, which should not affect you ability to write and run Prolog programs.