Article View: comp.lang.prolog
Article #394Re: different Prologs?
From: Brad Miller
Date: Tue, 10 Oct 1989 17:03
Date: Tue, 10 Oct 1989 17:03
43 lines
2527 bytes
2527 bytes
[[Protect quoted material from broken mail interface to pnews]]
Date: 10 Oct 89 02:02:18 GMT
From: ok@cs.mu.oz.au (Richard O'Keefe)
Prolog does *not* find solutions. Prolog finds **proofs**, and shows you
(part of) the substitution it found for each proof. The goal
?- member(a, [a,a,a]).
has three proofs. So that's the number of times Prolog should come back
to you with an answer substitution. However, there is a fine point to do
with the user interface. Many Prolog systems check the query that you
type in, and if it hasn't got any variables, just say "yes" or "no".
NU Prolog does this, except it says "true" or "false". Transcript:
% np
NU-Prolog 1.4
1?- member(a, [a,a,a]).
true.
However, if you put a variable in there to fool it, you will see that it
is prepared to find the other proofs. Transcript:
2?- X=dummy, member(a, [a,a,a]).
X = dummy ;
X = dummy ;
X = dummy ;
fail.
Another way of seeing that the three proofs are found is
3?- member(a, [a,a,a]), write(*), fail.
***fail.
On the other hand, it seems perfectly reasonable for a PROLOG or any logic
language implementation to note that in the variable case above, reproving
the member doesn't change the binding of X and refuse to do it, rather
simply fail. This is what would happen if "intelligent backtracking" were
being used. Similarly, in the last example, since no variable can be rebound
by the current frame, fail should exit the proof immediately after the first
write.
I think part of the issue is that Prolog really doesn't find "proofs" in the
logical sense, rather it does SLD resolution. That is to say, one shouldn't
confuse PROLOG, which is a programming language, with LOGIC which isn't.
That is, it does not return proof trees. If it did, then techniques like
intelligent backtracking could not be used, nor could "side effects" be
allowed (Side effects in the programming language sense).
Technical Details
Message-ID:
<1989Oct10.170353.9755@cs.rochester.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!rochester!daemonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!rochester!daemon From: miller@CS.ROCHESTER.EDU (Brad Miller) Newsgroups: comp.lang.prolog Subject: Re: different Prologs? Message-ID: <1989Oct10.170353.9755@cs.rochester.edu> Date: 10 Oct 89 17:03:53 GMT Sender: daemon@cs.rochester.edu (Old Scratch) Organization: University of Rochester Computer Science Department Lines: 43