Table mode declarations

By default, all of the arguments of a tabled subgoal are used for variant checking. Furthermore, by default, if a predicate is tabled, then all of its answers are tabled. A table mode declaration allows the system to only use the input arguments for variant checking, and allows the system to select the answers that it should table. The declaration
      :-table p(M1,...,Mn):C.
instructs the system about how it should table p/n, where C, which is called a cardinality limit, is an integer that limits the number of answers to be tabled, and Mi is a mode which can be min, max, + (input), or - (output). An argument that has the mode min or the mode max is assumed to be output. For variant checking, the system uses only input (+) arguments. If the cardinality limit C is 1, the declaration can simply be written as
      :-table p(M1,...,Mn).
Only one declaration can be given per predicate.

An argument with the mode min or max is called an optimized or aggregate argument. In a tabled predicate, only one argument can be optimized, and the built-in @</2 is used to select answers with minimum or maximum values.





Subsections
Neng-Fa Zhou 2013-01-25