7.8.1 Eager and lazy monotonic tabling
There are two types of monotonic tabling. The default is eager,
which implies that an asserted clause is immediately propagated through
the dependency network. Possibly resulting new answers can be tracked as
described in section
7.8.2. The alternative is
lazy. A predicate is marked for lazy using the lazy
option as shown below, or by setting the table_monotonic flag to lazy
.
:- table p/1 as (monotonic,lazy).
If a predicate is tabled as monotonic and lazy and an answer is added to one of the monotonic dynamic predicates, all dependent monotonic or incremental tables are invalidated and the answer is queued together with the dependency. A subsequent call to one of the invalidated tabled predicates re-evaluates the tables. For a monotonic table this implies pushing the queued answers through the dependencies. Removing a clause from one of a monotonic dynamic predicates invalidates all dependent tables and marks all these tables for forced reevaluation, which implies they are reevaluated using the same algorithm as used for incremental tabling.
Lazy monotonic tables may depend on eager monotonic tables. There is no point in making an eager monotonic table depend on a lazy monotonic table as one would have to reevaluate the lazy table to make the eager table consistent. Therefore, a dependency of an eager table on a lazy table is silently converted into a lazy dependency.