Homework #3 FAQ

  1. In class you showed us a special editor that colorizes the Prolog program. How do I use this editor?

    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

    1. Select Settings -> User init file... from SWI Prolog's menu bar. As a result, a file should be opened in a text editor.
    2. Add the following line to the file:
      :- set_prolog_flag(editor, pce_emacs).
    3. Save the file and close it.
    4. Close and restart SWI Prolog. Now when you use the New or Edit menu options, PCE Emacs should be the default editor.

  2. When I compile my Prolog code, I get an error such as:
    Warning: (c:/program files/prolog/problem1.pro:5):
            Clauses of likes/2 are not together in the source-file
    % problem1 compiled 0.00 sec, 0 bytes
    What does this mean?

    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.

  3. On page 377, the book says that preconditions and effects may only have variables that appear in the action's parameter list. However, in problem #4, Go(x,y) doesn't specify a room variable but the preconditions require that both x and y be in the same room. How would we specify this?

    The rule in the book is overly restrictive. In fact, you are allowed to use variables in your precondition that do not appear in the action's parameter list. However, it is true that all variables in the effect must appear in the parameter list.

  4. In problem #5, part b, it says "Add a causal link to achieve the precondition of ActionB ...". Is this a typo?

    Yes, it should read "Add a causal link to achieve the precondition of ActionD ...".