Interacting with Tabling contents

Hi

I have enjoyed getting to know the capabilities provided by Tabling in SWI-Prolog.

(The very draft book by D S Warren is a delight – particularly his chapter on Negation. He explains different semantics of negation in a gentle and lucid fashion.)

In my experimentations, I would like to be able to peek inside the tables to see a bit more of what is going on.

  • Is there a way to list the contents of a table?
  • Is it possible watch the table grow (e.g. from the debugger)?
  • Is it possible to reason with the contents of the table (e.g. get the number of atoms; get all atoms that match a pattern)?

I don’t really want to get into the implementation of the tables, but rather what their contents are.

Many thanks,

Steve

Many thanks,

Steve

Yes. Most is possible. See get_calls/3 and get_returns/2. You find some handy command line utilities in GitHub - JanWielemaker/my-prolog-lib: Personal SWI-Prolog utilities library. Notably tdump/0,1, idg/0,1 and the statistics predicates in tstat.pl can be helpful. Eventually this should go into the normal library. “Seeing the table grow” is not there.

There is also GitHub - SWI-Prolog/webstat: Examine SWI-Prolog resources and data using your browser, though it is not very complete. The idea of this tool was provide a comprehensive web tool to monitor the state of a SWI-Prolog program in real time. If anyone wishes to turn it into a full featured tool … I’m happy to explain all the low level stuff that allows getting the data out of Prolog. Mostly requires JavaScript skills.

1 Like