Notes and Errata for "A Concise Introduction to Prolog"
David Matuszek

These are some notes on the differences between SWI-Prolog and the version of Prolog that I used when writing my Concise Introduction to Prolog.


member/2 and append/3 are defined in SWI-Prolog (the paper says they are not).

restore/1 is not defined in SWI-Prolog.

So far, the only way I've been able to consult a file is by using a full path name. (I'm pretty sure this is just a minor problem with my configuration, but I haven't had time to look into the problem.)

Unix-style forward slashes are accepted:
        consult('C:/WINDOWS/Start Menu/Programs/SWI-Prolog/examples.pl').
DOS-style backslashes are accepted, but have to be doubled:
        consult('C:\\WINDOWS\\Start Menu\\Programs\\SWI-Prolog\\examples.pl').

If you accidently get
        Action (h for help) ?
just hit an a (for "abort").

If you accidently get
        % Break level 1
hit control-D.

If Prolog gives an answer but does not follow it with a new prompt, there may be other answers. Hit ; (semicolon) for the next answer, or <return> to get a new prompt.

Use \+ for "not," for example, child(X) :- human(X), \+ man(X), \+ woman(X).

Use consult/1 instead of reconsult/1. (SWI-Prolog doesn't even define reconsult/1; it just defines consult/1 to do what reconsult/1 does in other dialects.)


Additional Notes

Some versions of Prolog, including Quintus and SWI, require that predicates which may be asserted or retracted must be declared as "dynamic." An example of a dynamic clause is:

:- dynamic at/2, i_am_at/1, alive/1.

As part of your assignment, you must turn in a transcript of a sample run of your program.

  1. After executing the program, go to the very top of the transcript.
  2. Left-click at the beginning of the first line. (Nothing appears to happen.)
  3. Use the scroll bar to scroll to the end of the transcript.
  4. Right-click at the end of the part you wish to copy. The transcript should now be highlighted; you can scroll back and forth to make sure you have everything you want (if not, see "Warnings" below). The highlighted part is automatically copied to the clipboard.
  5. Paste into some editor.

Warnings:

  1. Prolog keeps a limited amount of information in its window; after some point things are lost "off the top," so if you want to copy a long transcript, you have to stop and copy from time to time.
  2. The amount you can copy is less than the amount that the transcript window can show, so even if you can see everything in one window, you may still need to copy it in pieces.

Any significant improvements to this procedure will earn someone another 10 points of extra credit.