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?