tabling.pl -- Tabled execution (SLG WAM)
This library handled tabled execution of predicates using the characteristics if the SLG WAM. The required suspension is realised using delimited continuations implemented by reset/3 and shift/1. The table space and work lists are part of the SWI-Prolog core.
- table(+PredicateIndicators)
- Prepare the given PredicateIndicators for tabling. Can only be
used as a directive. The example below prepares the predicate
edge/2 and the non-terminal statement//1 for tabled execution.
:- table edge/2, statement//1.
In addition to using predicate indicators, a predicate can be declared for mode directed tabling using a term where each argument declares the intended mode. For example:
:- table connection(_,_,min).
Mode directed tabling is discussed in the general introduction section about tabling.
- start_tabling(+Variant, +Implementation)
- Execute Implementation using tabling. This predicate should not be called directly. The table/1 directive causes a predicate to be translated into a renamed implementation and a wrapper that involves this predicate.
- delim(+Wrapper, +Worker, +WorkList)[private]
- delim(+Wrapper, +WrapperNoModes, +Worker, +WorkList)[private]
- Call/resume Worker
- update(+Wrapper, +A1, +A2, -A3) is det[private]
- Update the aggregated value for an answer. Wrapper is the tabled goal, A1 is the aggregated value so far, A2 is the new answer and A3 should be unified with the new aggregated value. The new aggregate is ignored if it is the same as the old one.
- completion[private]
- Wakeup suspended goals until no new answers are generated.
- abolish_all_tables
- Remove all tables. This is normally used to free up the space or recompute the result after predicates on which the result for some tabled predicates depend.
- abolish_table_subgoals(:Subgoal) is det
- Abolish all tables that unify with SubGoal.
- current_table(:Variant, -Trie) is nondet
- True when Trie is the answer table for Variant.
- extract_modes(+ModeSpec, +Head, -Variant, -Modes, -ModedAnswer) is det[private]
- Split Head into its variant and term that matches the moded arguments.
- separate_args(+ModeSpecArgs, +HeadArgs, -NoModesArgs, -Modes, -ModeArgs) is det[private]
- Split the arguments in those that need to be part of the variant identity (NoModesArgs) and those that are aggregated (ModeArgs).
- updater_clauses(+Modes, +Head, -Clauses)[private]
- Generates a clause to update the aggregated state. Modes is a list of predicate names we apply to the state.
- first(+S0, +S1, -S) is det[private]
- last(+S0, +S1, -S) is det[private]
- min(+S0, +S1, -S) is det[private]
- max(+S0, +S1, -S) is det[private]
- sum(+S0, +S1, -S) is det[private]
- Implement YAP tabling modes.
- prolog:rename_predicate(:Head0, :Head) is semidet[multifile]
- Hook into term_expansion for post processing renaming of the generated predicate.
- sandbox:safe_directive(+Directive) is semidet[multifile]
- Allow tabling directives that affect locally defined predicates.
- delim(+Wrapper, +Worker, +WorkList)[private]
- delim(+Wrapper, +WrapperNoModes, +Worker, +WorkList)[private]
- Call/resume Worker
- first(+S0, +S1, -S) is det[private]
- last(+S0, +S1, -S) is det[private]
- min(+S0, +S1, -S) is det[private]
- max(+S0, +S1, -S) is det[private]
- sum(+S0, +S1, -S) is det[private]
- Implement YAP tabling modes.
- first(+S0, +S1, -S) is det[private]
- last(+S0, +S1, -S) is det[private]
- min(+S0, +S1, -S) is det[private]
- max(+S0, +S1, -S) is det[private]
- sum(+S0, +S1, -S) is det[private]
- Implement YAP tabling modes.
- first(+S0, +S1, -S) is det[private]
- last(+S0, +S1, -S) is det[private]
- min(+S0, +S1, -S) is det[private]
- max(+S0, +S1, -S) is det[private]
- sum(+S0, +S1, -S) is det[private]
- Implement YAP tabling modes.
- first(+S0, +S1, -S) is det[private]
- last(+S0, +S1, -S) is det[private]
- min(+S0, +S1, -S) is det[private]
- max(+S0, +S1, -S) is det[private]
- sum(+S0, +S1, -S) is det[private]
- Implement YAP tabling modes.