Prolog for Squeak 4
by Stéphane Rollandin
The original Prolog
Up to version 3.7 of Squeak, it was possible to load the Prolog/V implementation by Mike Teng, ported to Squeak by Bolot Kerimbaev.
This code is still available from SqueakMap.
For newer Squeak images, a refactored version is provided here. It is almost the same, only the names of the prolog methods have been modified to allow the loading of the code. If you want to work on the original code, this is the place to start. The original documentation is v-prolog.pdf
The new Prolog
In the process of testing the original Prolog, it became clear that some improvements could easily be made. A couple of bugs were present, too, along with uncompletely implemented features. So I started hacking the code up to the point it became quite different (even not backward compatible), although it is fundamentally the same since the evaluation algorithm and core structure did not change (yet).
Here are the main points of divergence:
- Prolog methods and primitives have a different naming scheme: a method defining the Prolog predicate
predicate must be named
logicPredicate. If it is a primitive (e.g. written in Smalltalk) then it must be named
primlogicPredicate: and have its single argument named
List class implementing the cons cell data structure used by the original Prolog has been replaced by
PrologList, a subclass of
ConsCell used by LispKit. There is no
EmptyList class anymore, this is simply
- The PrologWorkspace is deprecated. It has been replaced by a more powerful and semantically consistent GUI coupling a code browser and a read-eval-print-loop (picture below).
- Important predicates that were either badly implemented or had strange semantics have been fixed, such as
- Predicates with zero arguments do not require parenthesis any more.
- The core code has been drastically simplified.
value selector used for referencing logic bindings from Smalltalk code has been replaced by
- The system-wide Database has been completed with class-local and instance-local databases.
- An API for directly feeding a Prolog interpreter with Smalltalk queries, bypassing the parser, has been implemented.
- Generic input and output streams have been added to each interpreter instance.
- SUnit tests and documentation have been added; many bugs were found and fixed in the process.
The Prolog GUI in Squeak 4.5
Note the usage of input/output streams in the animals game,
and the pretty-printing of the answers
The most current code is available on SqueakMap: check up the entry Prolog.
Prolog can be installed in a 3.8 or newer image (last tested on 5.1).
You can also get it here: PrologSPFA-23.sar (February 9th, 2014), although this may not be the latest version.
what are we talking about here ?
Squeak and Smalltalk links