Entity: predicate

not_deeper_than(Deep), goal.

Restricts the stack size. If the stack size at the moment of execution of not_deeper_than(Deep) is S then the stack is restricted by S+Deep. All answers and branches of the Proof Tree which fill the stack more than S+Deep will be cut. This mean that will be given only that answers of goal which need less than Deep steps (of course, here we don't count the steps which you lose in backtracking).

You can use this predicate for goals which are cycling. For example, when you prove theorems.


?- not_deeper_than(10), p(X), write(X), nl.

p(f(X)) :- p(X).

This program will search for answers of goal which have a proof tree with less than ten knots.