[not loaded]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. This predicate is
normally used as a directive, but SWI-Prolog also allows runtime
conversion of non-tabled predicates to tabled predicates by calling
table/1. 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.
- untable(M:PIList) is det
- Remove tabling for the predicates in PIList. This can be used to undo the effect of table/1 at runtime. In addition to removing the tabling instrumentation this also removes possibly associated tables using abolish_table_subgoals/1.
- start_tabling(:Closure, :Wrapper, :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.
- start_subsumptive_tabling(:Closure, :Wrapper, :Implementation)
- (*) We should not use trie_gen_compiled/2 here as this will
enumerate all answers while '$tbl_answer_update_dl'/2 uses the
available trie indexing to only fetch the relevant
answer(s)
. - start_abstract_tabling(:Closure, :Wrapper, :Worker)
- Deal with
table p/1 as subgoal_abstract(N)
. This is a merge between variant and subsumptive tabling. If the goal is not abstracted this is simple variant tabling. If the goal is abstracted we must solve the more general goal and use answers from the abstract table.Wrapper is e.g., user:
p(s(s(s(X))),Y)
Worker is e.g., call(<closure>(p/2)(s(s(s(X)))
,Y)) - start_moded_tabling(+Closure, :Wrapper, :Implementation, +Variant, +ModeArgs)
- As start_tabling/2, but in addition separates the data stored in the answer trie in the Variant and ModeArgs.
- tnot(:Goal)
- Tabled negation.
(*): Only variant tabling is allowed under tnot/1.
- not_exists(:P) is semidet
- Tabled negation for non-ground goals. This predicate uses the tabled meta-predicate tabled_call/1. The tables for tabled_call/1 must be cleared if `the world changes' as well as to avoid aggregating too many variants.
- $wfs_call(:Goal, :Delays)
- Call Goal and provide WFS delayed goals as a conjunction in Delays. This predicate is the internal version of call_delays/2 from library(wfs).
- 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.
Abolishes both local and shared tables. Possibly incomplete tables are marked for destruction upon completion. The dependency graphs for incremental and monotonic tabling are reclaimed as well.
- abolish_table_subgoals(:Subgoal) is det
- Abolish all tables that unify with SubGoal.
- abolish_module_tables(+Module) is det
- Abolish all tables for predicates associated with the given module.
- abolish_nonincremental_tables is det
- Abolish all tables that are not related to incremental predicates.
- abolish_nonincremental_tables(+Options)
- Allow for skipping incomplete tables while abolishing.
- current_table(:Variant, -Trie) is nondet
- True when Trie is the answer table for Variant. If Variant has an unbound module or goal, all possible answer tries are generated, otherwise Variant is considered a fully instantiated variant and the predicate is semidet.
- $set_table_wrappers(:Head)
- Clear/add wrappers and notifications to trap dynamic predicates. This is required both for incremental and monotonic tabling.
- $start_monotonic(+Head, +Wrapped)
- This is called the monotonic wrapper around a dynamic predicate to collect the dependencies between the dynamic predicate and the monotonic tabled predicates.
- abolish_monotonic_tables
- Abolish all monotonic tables and the monotonic dependency relations.
- undefined is undefined
- Expresses the value bottom from the well founded semantics.
- answer_count_restraint is undefined
- radial_restraint is undefined
- Similar to undefined/0, providing a specific undefined for restraint violations.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.