I use Prolog to code some fairly complex rules in my project. There are many recursions, including mutual recursion. Part of the rules looks something like this:
pred1(X) :- ...
pred1(X) :- someguard(X), pred2(X).
pred2(X) :- ...
pred2(X) :- othercondition(X), pred1(X).
There is a fairly obvious endless cycle between pred1and pred2. Unfortunately, the interaction between these predicates is very difficult and difficult to distinguish. I was able to eliminate an infinite loop in this instance by passing a list of objects that were passed in pred1, but it is extremely cumbersome! In fact, this greatly downplays the purpose of using Prolog in this application.
How to make Prolog avoid endless loops? For example, if during the test pred1(foo)he tries to prove pred1(foo)how sub-goal, failure and return.
Can this be done using meta-interpreters ?
source
share