How to run SWI-Prolog under Windows-XP?


1)        Select the Start-Button on the desktop (left-bottom),

            Go to the menu-points: Programme, SWI-Prolog, SWI-Prolog

            You get the command prompt of SWI-Prolog:



2)        Change to your local directory on c: or to your unix directory on h::

            ?- chdir(’c:/allusers/loginname’). or ?- chdir(’h:’).


          (for subdirectories SWI-Prolog uses the char / (UNIX-like ) instead of \ (Windows-XP-like))


3)        Read in the source code of a Prolog program (line 1, ... line n) from the user prompt:

            ?- consult(user).

            |: line 1.

            |: ...

            |: line n.

            |: end_of_file.


4)        To see what you have read in the memory give the command listing.


5)        There are different possibilities for reading in the source code from a file (e.g.

            (To create a file use the texteditor: Start/Programme/Zubehör/Editor

-          end the file with an additional newline and save it

-          use the suffix ‘pl’ for the filename (it is the standard for prolog)

or download the file from the homepage of Logic Programming Engineering, additional information)


(a)  ?- consult(‘h:/’).


(b)  ?- consult(family).

                (If the actual path is set with chdir-command to h:)


            (c) ?- [family].

                (If the actual path is set with chdir-command to h:)


6)        Now you can ask questions:

            ?- father(ali, Child).


After the answer


              Child = guna


you can respond with return-key if you don't want more solutions:


  .  (this is the end of the question)         


            or with the semicolon (or the space key) if you want more solutions:


              Child = hugo.  (the dot shows that there are no more solutions)





7)       Ask now who is the daughter of ina.


          ?- mother(ina, Child), female(Child).

          You get the answer:

          Child = wera


          If you respons with a semicolon then you get the output:



8)        If you have problems you can get help:


(a) help(topic). -explains the syntax of topic

            (b) explain(topic). -explains the syntax of topic

            (c) apropos(topic). - finds topic in help texts

            (d) use the Manual for SWI-Prolog available at Walter Nauber's web page

9)        To use the debugger type the command:


?- trace. (end the debugger with command nodebug.)

With a return key you can execute a single step with the debugger.

A running debugger session can you abort with the command a (abort).

Use the debugger for the query:

?- mother(ina, Child), female(Child).


10)      To finish the work with Prolog give the command:


?- halt.