Definite programs, also called Horn Clause Programs, are those
programs without negation. In XSB, this means without the \+/1
,
fail_if/1, not/1 or tnot/1 operators. Consider the
Prolog program
path(X,Y) :- path(X,Z), edge(Z,Y). path(X,Y) :- edge(X,Y). |
A number of approaches have been developed to address this problem by
reusing partial answers to the query path(1,Y)
[21,48,4,50,51]. The ideas behind these
algorithms can be described in the following manner. Calls to tabled
predicates, such as path(1,Y) in the above example, are stored
in a searchable structure together with their proven instances. This
collection of tabled subgoals paired with their answers,
generally referred to as a table, is consulted whenever a new
call, C, to a tabled predicate is issued. If C is sufficiently
similar to a tabled subgoal S, then the answer set associated
with S may be used to satisfy C5.1.
In such instances, C is resolved against the answers in
, and
hence we refer to C as a consumer of
(or S). If there is no such S, then C is entered into the
table and is resolved against program clauses as in Prolog -- i.e.,
using SLD resolution. As each answer is derived during this process,
it is inserted into the table entry associated with C if it contains
information not already in
. We hence refer to C as a
generator, or producer, as resolution of C in this manner produces the answers
stored in its table entry. If the answer is in fact added to this
set, then it is additionally scheduled to be returned to all consumers
of C. If instead it is rejected as redundant, then the evaluation
simply fails and backtracks to generate more answers.
Notice that since consuming subgoals resolve against unique answers rather than repeatedly against program clauses, tabling will terminate whenever