Information Technology Reference
In-Depth Information
Appendix D
Other Prolog Systems
There are many implementations of Prolog other than the SWI-Prolog that is used
in this topic. Fortunately, many of the more recent systems (including SWI-Prolog,
SICStus Prolog, ECLiPSe, and GNU Prolog) use the same
ISO Standard
Prolog dialect.
Variations are found mainly in older systems (such as C-Prolog, Open Prolog, LPA
Prolog, Quintus Prolog, and Amzi! Prolog). There are many other Prolog systems out
there, however, which can be found by searching online. Each of these systems has
its own advantages and disadvantages regarding special features (including language
additions), speed of execution, and in some cases, commercial support.
Before talking about language differences, it is worth noting that even in systems
that use the
same dialect
of Prolog, the behavior of the systems is not always precisely
the same. It should be possible to run the same queries on the same programs to get
the same answers, but there are variations. For example, in this topic, it is assumed
that the system responds to queries by printing
Yes
(for success) or
No
(for failure),
as it does in release 5.6.43 of SWI-Prolog. But more recent versions of SWI-Prolog,
including release 5.6.63, print
true
or
false
instead.
This topic uses a very small subset of SWI-Prolog. For anyone trying to run the
examples here or write their own programs on a different Prolog system, here are
some things to watch for:
Negation.
The symbol
\+
is used to indicate negation (see chapter 3, page 49). Many
earlier Prolog systems used the more mnemonic
not
instead.
Comments.
Comments in a Prolog program are indicated with a
%
and continue to
the end of the line (see chapter 3, page 44). In other Prologs, comments are placed
between
/*
and
*/
characters.
Loading files.
Program files are loaded using square parentheses (see appendix B).
So the query
[myfile]
is how the program file
myfile.pl
is loaded. In other
Prolog systems, the query
consult(myfile)
is used instead.
Reloading files.
In SWI-Prolog, if a file is reloaded (using the square brackets or with
the special SWI-Prolog query
make
introduced in appendix C), the new definition
replaces the previous one. In other Prologs, new clauses are
added
to the old ones,
unless the special query
reconsult
is used.