The following example is based on using the C-Prolog system on a BSD Unix system, but many Prolog interpreters have a similar interface. When the interpreter is started it immediately prompts for a goal:
% prolog
C-Prolog Version 1.4
| ?-
However a program consists of facts, rules and
a goal. To enter a program either (a) put the facts and rules in a
file and type the file name enclosed in brackets followed by a period
.:
| ?- [testprog].
........
| ?-
or (b) give the file name ``user'' and enter the program directly:
| ?- [user].
supports(a,b).
supports(a,c).
supports(b,d).
supports(c,e).
^d
[eof]
| ?-
To terminate program entry and get the goal prompt type the
end-of-file character (usually control and d). The above is hardly a
program as it only contains simple asserted relationships (or facts)
but it is only intended to demonstrate facts and goals.
The above facts are supposed to describe the state of a few blocks on a table:
© University of Hertfordshire Higher Education Corporation (1998)