Given a table entry
, the set of variables in
is
sometimes called the substitution factor of
. The order of
arguments in the substitution factor corresponds to the order of
distinct variables in a left-to-right traversal of
. Each answer
in
substitutes values for the variables in the substitution
factor of
; this substitution is sometimes called an answer
substitution. The table inspection predicates allow access to
substitution factors and answer substitutions through a family of terms
whose principle functors are ret/n, where n is the size of the
substitution factor.
To take a slightly more complex example, consider the subgoal
q(X) where X is an attributed variable whose attribute is
f(Z,Y,Y). In this case the substitution factor is
ret(X,Z,Y).![]()
In a similar manner, XSB maintains substitutions between producer subgoals and consuming subgoals when subsumption-based tabling is used. The return template for a consuming call is a substitution mapping variables of its producer to subterms of the call. This template can then be used to select returns from the producer which satisfy the consuming call. Note, then, that a return template of a subsumed subgoal may show partial instantiations. Return templates are also represented as ret/n terms in the manner described above.