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.
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.