Minimum depth limit



Prolog is not Logic. This is evident. So, in many introductory Prolog books,
facts are suggested to be separated by rules. For example, the following is
a bad practice, according to most...

f(t,z).
f(e,q).
f(b,e).
f(w,i).
f(a,b).
f(q,w).
f(i,t).

f(X,X).
f(X,Y) :- f(Y,X).
f(X,Y) :- f(X,Z), f(Z,Y).

In this example, facts and rules, are both represented by f/1.
A call like:

?- f(a,z).

will start an infinite loop.
A suggestion is to replace database facts, with another name, and to use
this into the rules. This has to be done to avoid recursion.
Another method could be to limit the depth (i.e. recursion level) of a call.
In SWI Prolog this is done via call_with_recursion_limit/3 predicate.
So, one can write such a predicate:

prove(Goal) :-
call_with_depth_limit(Goal, ???, Result),
Result \= depth_limit_exceeded.

In this way, it will be possible to call, for example:

?- prove(f(a,z)).
yes

Anyone know if a formal description of depth-limited calls does exist?
I found that the number in the place of ??? must be at least 5 (try
?-prove(f(z,a)).).

Any suggestions will be appreciated.

Thank you,
M


.



Relevant Pages

  • Re: Some of the Logic of KRS discussion
    ... Ancillary facts such as the failure of European ... > Are you referring to the suggestion of John N. Harris that the vikings ... Atlantis to Norse colonists in Oklahoma. ...
    (sci.archaeology)
  • Re: XORShift PRNG as a diffusion structure
    ... I said that I attempt to improve the atmosphere. ... Facts can be presented. ... the last sentence is your suggestion. ... offers or asks nonsensical questions. ...
    (sci.crypt)
  • Re: REPOST: Guru Challenge
    ... > in his hosts file which was giving him problems. ... where exactly in that bit of wisdom is a suggestion of something to ... It feels so good to be right Juan, ... Perhaps you were unaware of these facts. ...
    (microsoft.public.dotnet.framework.aspnet)