Clone wiki

prologlib / Home


prologlib is an ISO Prolog processor written in Python 3. The idea behind it is to provide an open source Prolog implementation that strictly follows the non-free ISO standard document (ISO/IEC 13211-1), from execution model to builtin predicates and functors.

To use prologlib, you need to clone the Mercurial repository hosted on Bitbucket:

$ hg clone

then execute from the project root. Python 3.1 is required, due to the use of some new syntax for the strings formatting mini-language. You will enter an interactive interpreter where... well, you can do the basic things that you are able to do in every Prolog console. Type help. in the console for further details.

No real API is provided. If you want to integrate prologlib into Python code, have a look at prologlib.ui to see how the processor has been called from within the interactive interpreter.

Please be warned: ISO compliance is not complete, there are some missing functionalities you should be aware of. There are also some known issues.

prologlib is very slow. Extremely slow. So slow as to be embarassing. So slow as to be unusable for any serious (and even less serious) work. Slowness is probably due to how the stack driving the processor has been implemented. Strictly following the execution model described in the ISO standard, which has been likely tuned for clarity rather than efficiency, the stack grows by copying some structures from itself (each cell in the execution stack contains another stack where subgoals are stored). During execution, the data that need to be copied become bigger and bigger, thus leading to poor performance.

Variable management is another factor in prologlib's slowness: still following the bare-bones explanations published in the ISO standard, binding is handled both by an external data structure (core.Substitution), representing a Most General Unifier, and by the value field in parser.Variable. Also, variables in MGU are handled by name, not by object identity; this means, among other things, that the processor must perform the same operation multiple times for variables that have the same name (and thus would be "the same variable") but are represented by different objects.


TBD Some historical perspective on prologlib's development?