# How to get mode directed tabling from a predicate, programmatically

**URL:** <https://swi-prolog.discourse.group/t/how-to-get-mode-directed-tabling-from-a-predicate-programmatically/9142>\
**Category:** Help!\
**Tags:** how-to, tabling\
**Created:** [July 30, 2025, 4:57pm UTC](https://swi-prolog.discourse.group/t/how-to-get-mode-directed-tabling-from-a-predicate-programmatically/9142 "2025-07-30T16:57:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![meditans](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/meditans/32/1768_2.png) [@meditans](https://swi-prolog.discourse.group/u/meditans)\
**Post date:** [July 30, 2025, 4:57pm UTC](https://swi-prolog.discourse.group/t/how-to-get-mode-directed-tabling-from-a-predicate-programmatically/9142/1 "2025-07-30T16:57:15Z")

</div>

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

```prolog
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](https://us.swi-prolog.org/pldoc/man?section=tabling-shared).
> 
> **incremental**
> 
> The table is subject to _incremental tabling_. See [section 7.7](https://us.swi-prolog.org/pldoc/man?section=tabling-incremental)

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

```prolog
:- 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?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [July 30, 2025, 6:40pm UTC](https://swi-prolog.discourse.group/t/how-to-get-mode-directed-tabling-from-a-predicate-programmatically/9142/2 "2025-07-30T18:40:23Z")

</div>

> [@meditans](#):
>
> 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.
