B-Prolog was a high-performance implementation of the standard Prolog language with several extended features including matching clauses, action rules for event handling, finite-domain constraint solving, arrays and hash tables, declarative loops, and tabling.
B-Prolog is a commercial product, but it can be used for learning and non-profit research purposes free of charge (since version 7.8 for individual users, including commercial individual users, B-Prolog is free of charge [4]).
B-Prolog is not anymore actively developed, but it forms the basis for the Picat programming language.
To avoid reconstructing the term, we can rewrite the clause into the following: The call Ys=[Y|_] in the guard matches Ys against the pattern [Y|_].
To overcome this, B-Prolog provides a simple and yet powerful language, called Action Rules (AR), for programming agents.
When the event pattern E together with the enclosing braces is missing, an action rule degenerates into a matching clause.
A set of built-in events is provided for programming constraint propagators and interactive graphical user interfaces.
AR has been found useful for programming simple concurrency, implementing constraint propagators, and developing interactive graphical user interfaces.
It has served as an intermediate language for compiling Constraint Handling Rules (CHR) and Answer Set Programs (ASP).
That solver was implemented in an early version of AR, called delay clauses.
Recently, the two built-ins in/2 and notin/2 have been extended to allow positive and negative table (also called extensional) constraints.
This notation is interpreted as an array access when it occurs in an arithmetic expression, a constraint, or as an argument of a call to @=/2.
The emergence of constraint programming constructs such as CLP(FD) has further revealed this weakness of Prolog as a modeling language.
Syntactically, foreach is a variable-length call whose last argument specifies a goal to be executed for each combination of values in a sequence of collections.
The following gives a program for the N-queens problem in B-Prolog: The array notation on lists helps shorten the description.
Without it, the foreach loop in the program would have to be written as follows: where Qi and Qj are declared local to each iteration.
With tabling, any query to the program is guaranteed to terminate as long as the term sizes are bounded.
For example, the following program encodes the Dijkstra's algorithm for finding a path with the minimum weight between a pair of nodes.