Long delay when using tabling -- for highly recursive and interdependent code


I have written a number of rules that are highly circular and recursive.

There is also a lot of negation going on.

To avoid infinite loops i am using tabling on some of the predicates – and it works.

However, i also noticed that a first call – to any goal/predicate – takes quite some time – several seconds – to complete, and then answers, including next backtracked answers are obtained immediately.

I guess, due to the highly circular rules, many rules related to many other rules, and hence no matter what is called first, the call gets threaded across others, and takes time.

Is there a way to smoothen this “startup” time – i guess, many goals with non-ground are recursively called and put in “suspense” until ground answers are filled in – but, is there a better way to distribute the “lazy” workload better over time?



As is, not. The tabling people have defined two major completion scheduling strategies. One is called local, which tries to fill tables eagerly. The other is called global and provides answers as they become available. For most use cases local tabling is preferable and it is the only scheduling that is currently implemented in SWI-Prolog.

As the data changes there is incremental and monotonic tabling. Also think about what you table. Possibly you only need to table a small and difficult cyclic core.

Hi Jan,

Thank you.

I will try to identify the core – perhaps this helps.

I am also wondering if i can do some memoing and visited path tracking as alternative or to augment for speed.