How to get mode directed tabling from a predicate, programmatically

I can use predicate_property/2 to read the tabling mode of a predicate:

predicate_property(foo(_,_), tabled(Flag)).

But from the documentation:

tabled(?Flag)

True of the predicate is tabled and Flag applies. Any tabled predicate has one of the mutually exclusive flags variant or subsumptive. In addition, tabled predicates may have one or more of the following flags

shared

The table is shared between threads. See section 7.9.

incremental

The table is subject to incremental tabling. See section 7.7

So I get either variant or subsumptive and optionally one of the other two. What about a declaration like:

:- table rightmost(_, po(onX_more)).

made with po or lattice? Ideally I’d love to be able to gather programmatically enough information to reconstruct the predicate. How should I do this?

Look at boot/tabling.pl. That should give all the information you need. I’m happy to accept pull requests that improve predicate_property/2 for this.

1 Like