Using BinProlog

BinProlog uses R.A. O'Keefe's public domain tokeniser and parser and write utilities (see the files read.pl, write.pl), DCGs and a transformer to binary programs. It compiles itself in less than 1 minute on a Sparcstation 10-40.

The system has very fast (heap-based) copy_term/2, findall/3 and findall/4 predicates, floating point, global logical variables, but still lacks full garbage collection.

A new term compression technique [#!TN94:PLILP!#] (joint work with Ulrich Neumerkel) reduces heap-consumption and adds some extra speed . Ulrich's iterative copy_term/2 algorithm further accelerates BinProlog's `copy-once' heap-based findall/3 and findall/4 so that findall-intensive programs may run 2-3 times faster in BinProlog than in other (even native code) implementations.

All data areas are now user configurable, and all except the heap are garbage collected. A garbage collector for the heap will be released soon.

Although other Prolog's assert and retract primitives are emulated in BinProlog, their functionality has been decomposed in separate simpler operations that give also improved efficiency.

For permanent information BinProlog has a new, garbage-collected data area the blackboard where terms can be stored and accessed efficiently with a a 2-key hashing function using something like

?-bb_def(likes,joe,[any(beer),good(vine),vegetarian(food)]).

and updated with something like

?-bb_set(likes,joe,nothing).

or

?-bb_rm(likes,joe).

To get its value:

?-bb_val(likes,joe,What).

BinProlog 3.30 has also backtrackable global variables, with 2-keyed names.

Try:

?- Person=joe, friend#Person:=:mary, bb.

and then

?- friend # joe:=:X.

The blackboard can be used either directly or through an assert-retract style interface.

A small exercise: if you want backtrackable behaviour of assert and retract you can modify extra.pl and use A#B:=:X style global variables in their definition, instead of bb_def/3 etc.

The blackboard also gives constant-time sparse arrays and lemmas. For example try:

?- for(I,1,99),bb_def(table,I,f(I,I)),fail.
?- bb.

BinProlog 3.30 has Edinburgh behaviour and tries to be close to Sicstus and Quintus Prolog on the semantics of builtins without being too pedantic on what's not really important.

All the basic Prolog utilities are now supported (dynamic clauses, a metainterpreter with tracing facility, sort, setof, dynamic operators floating point operations and functions).

A fast deterministic append det_append/3 (i,i,o) has been added. Naive reverse using det_append/3 makes more than 3 MegaLIPS on a Sparc 20-41 (a 3-times speed-up).

Almost all the builtins are now expanded inline resulting in improved heap consumption and performance.

A few programs (an automatic Tetris player, a knight-tour, an OR-parallel simulator, Fibonacci, Tak with lemmas, a small neural-net simulator backprop.pl) illustrate some of the new features. A few well-known benchmarks have been added to help compare BinProlog with other implementations.

BinProlog has supported from start 30 bit integer arithmetic. Now it has also floating point operations and functions like sin, cos, tan, log, exp, pow, etc. They can be used either through the is/2 interface3:

?- X is cos(3.14)+sin(0).

or in relational form

?- cos(1,X).

Note that you should use something like Y=3+4, X is 1+expr(Y) instead of Y=3+4, X is 1+Y which will not work in compiled code.

Floating point works has the same precision and semantics as the type double in C. Floating point operations are close in speed to emulated Sicstus. To try them out use the toy neural-network simulator bp.pl. This program uses also constant time arrays and is therefore unusually fast compared to its execution in other Prologs like Quintus or Sicstus.



Subsections