Textbook Info
- Prolog is not covered in any of the course texts. There will be paper handouts in addition to material in the Olin Library and the online links provided here.
Writing/Running Prolog
gprolog is a fairly reasonable interpreter, and it's GNU, so you can find versions for most operating systems. For Windows XP:
- Download the Windows binary ("Win32 auto-install setup")
- Run the installer. Remember where you put it, if you don't use the defaults.
Run gprolog -- either from the Start Menu or Desktop if you created icons there, or from "GNU-Prolog/bin/gprolog.exe" otherwise.
Make most excellent use of the gprolog manual
IMPORTANT NOTE: gprolog itself only allows queries. To actually tell it information, you must either consult the user or a file. See http://gprolog.inria.fr/manual/manual006.html#toc3 for more info.
- === To test gprolog ===
Type the following(things you should type are in double quotes. Type these expressions without quotes.):
| ?- "[user]." compiling user for byte code... "man(socrates). man(aristotle). mortal(X):-man(X). [CTRL-D]" user compiled, 4 lines read - 403 bytes written, 18096 ms (2323 ms) yes | ?- "mortal(X)." X = socrates ? ";" X = aristotle yes | ?-
Online resources
- === Learning prolog ===
Fun with Prolog is short and sweet, though it assumes some basic familiarity. It's probably best to start here for an overview, then go into some of the more detailed manuals/tutorials once you've got a first pass understanding.
Guide to Prolog has some good explanations, but isn't finished. (I like this one best-kmr)
Prolog Tutorial has lots of examples in chapter 2.
Programming Prolog: a first course is fairly exhaustive, but their copy editors seem be on vacation.
Introduction to Prolog is comprehensive, if fast-paced.
http://cs.wwc.edu/~cs_dept/KU/PR/Prolog.html very clear, short, thorough, but not an easy intro
CS320 Prolog Examples awesome examples. Write bad science fiction, make magic squares, go nuts. === Running Prolog ===
gprolog is an ok interpreter; useful with this is the gprolog manual.
SWI-Prolog is similar to gprolog but its features appear to be slightly more obvious.
specifically: SWI prolog is more forgiving to the user and appears to give more informative error messages. Its manual is slightly better. It has commnds like ls and cd that let you look at and change the directory from where the program is currently looking for files. It has less idiotic handling of infinite loops. HOWEVER it does not allow you to list all matches to a query (like gprolog does when you type an 'a'), and may be missing other features I haven't managed to catch yet. -kmr