next up previous contents index
Next: Potential Pitfalls in Tabling Up: Interaction Between Prolog Constructs Previous: Cuts and Tabling   Contents   Index


Subsumption-Based Tabling and Meta-Logical Predicates

Meta-logical predicates like var/1 can be used to alter the choices made during an evaluation. However, this is dangerous when used in conjunction with a paradigm that assumes that if a specific relation holds -- e.g., p(a) -- then a more general query -- e.g., p(X) -- will reveal this fact.

Example 5.2.3   Consider the following simple program
        p(X) :- var(X), X = a.
to which the queries
        ?- p(X).
        ?- p(a).
are posed. Let us compare the outcome of these queries when p/1 is (1) a Prolog predicate, (2) a variant-tabled predicate, and (3) a subsumptive-tabled predicate.

Both Prolog and variant-based tabling yield the same solutions: X = a and no, respectively. Under subsumption-based tabling, the query ?- p(X). likewise results in the solution X = a. However, the query ?- p(a). is subsumed by the tabled subgoal p(X) -- which was entered into the table when that query was issued -- resulting in the incorrect answer yes.$ \Box$

As this example shows, incorrect answers can result from using meta-logical with subsumptive predicates in this way.



Luis Fernando P. de Castro 2003-06-27