# XSB auto\_table

**URL:** <https://swi-prolog.discourse.group/t/xsb-auto-table/833>\
**Category:** Help!\
**Created:** [June 19, 2019, 3:46am UTC](https://swi-prolog.discourse.group/t/xsb-auto-table/833 "2019-06-19T03:46:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [June 19, 2019, 3:46am UTC](https://swi-prolog.discourse.group/t/xsb-auto-table/833/1 "2019-06-19T03:46:11Z")

</div>

Does SWI-Prolog support XSB’s `auto_table` ?  
[(page 67,68)](http://xsb.sourceforge.net/manual1/manual1.pdf#subsection.3.10.5)

This is very useful for DCG’s as shown here [(from XSB manual p. 427)](http://xsb.sourceforge.net/manual1/manual1.pdf#subsection.11.2.1):

> 11.2.1 Definite Clause Grammars and Tabling
> 
> Tabling can be used in conjunction with Definite Clause Grammars to get the effect of a more complete parsing strategy. When Prolog is used to evaluate DCG’s, the resulting parsing algorithm is“recursive descent”. Recursive descent parsing, while efficiently implementable, is known to suffer from several deficiencies: 1) its time canbe exponential in the size of the input, and 2) it may not terminate for certain context-free grammars (in particular, those that are left or doubly recursive). By appropriate use of tabling, both of these limitations can be overcome. With appropriate tabling,the resulting parsing algorithm is a variant of Earley’s algorithm and of chart parsing algorithms.

> In the simplest cases, one needs only to add the directive **`:- auto_table`** (seeSection3.10.5) to the source file containing a DCG specification. This should generate any necessary table declarations so that infinite loops are avoided (for context-freegrammars). That is, with a **`:- auto_table`** declaration, left-recursive grammars can be correctly processed.

---

<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:** [June 19, 2019, 6:43am UTC](https://swi-prolog.discourse.group/t/xsb-auto-table/833/2 "2019-06-19T06:43:56Z")

</div>

Not yet. It has been discussed. I wanted to have it to run more of the XSB test suite unmodified, but Theresa (Swift) thinks there are several issues with `auto_table` and wants to rethink some of this. The next target is _incremental tabling_, but first there is some work to realize safe destruction of tables, notably tables that are related through _undefined answers_.

Now that we can dynamically switch tabling on and off, you can write your own analysis code that creates tables at the necessary places 🙂

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [June 19, 2019, 5:27pm UTC](https://swi-prolog.discourse.group/t/xsb-auto-table/833/3 "2019-06-19T17:27:33Z")

</div>

I see. Great progress is being made! Thanks for that work. I hope to see incremental tabling soon!
