This library (loaded with :- lib(dfid))defines predicates for bounded depth-first search, which can replace the usual depth first search in cases when a complete proof procedure is needed. By limiting the number of ancestors of each goal infinite paths can be cut down and endless loops eliminated, of course assuming that the cut branch did not contain a solution.
The library provides two basic ways to use the depth limitations: depth-first iterative deepening and plain bounded depth-first search. Both require that programs which should be executed with this search strategy are compiled with the dfid_compile compiler flag. Predicates which are compiled without it can be called as well, but their depth will not be taken into account, and they will be executed using the standard depth-first rule. Since this is more efficient, code which is known not to contain any infinite loops can be compiled without the dfid_compile flag, and only the potentially non-terminating parts have to be compiled using the flag. Predicates compiled with and without the flag can be freely mixed.