Article View: comp.lang.prolog
Article #3283Re: :- deterministic (not HP Prolog, but Trilogy)
From: Paul Voda
Date: Wed, 27 Apr 1988 05:39
Date: Wed, 27 Apr 1988 05:39
42 lines
2376 bytes
2376 bytes
I do not know how the deterministic predicates are implemented in HP-Prolog,
but I do know what they are in Trilogy. Maybe this will help.
When you declare a Trilogy predicate as a 'proc' rather than a 'pred'
then the Trilogy system uses the mode information about the arguments
extensively in order to check that the predicate can never backtrack.
Consequently, a call to a deterministic predicate, i.e. to a procedure,
can return at most one set of results. The compiler generates a code
of Pascal-like quality in such a case.
Generally, the system checks that all calls to 'preds', i.e. to the
true backtracking predicates are enclosed in an all (min, one) solution
construct, that there are no values returned through an "or" and
that there are no symbolic (logic) variables with constraints used
(except enclosed in all,min one constructs).
For instance the declaration
proc P(x:>I) iff x = 1 | x = 2
with the output argument "x" is rejected because in order
to satisfy the goal P(2) which is compiled as P(z) & z = 2 we need
backtracking.
Incidentally, the version 1.3 of Trilogy now contains a one-solution
construct of the form
one x,y..,z A(x,y,z)
where one (the first solution found) satisfying the formula A is
communicated to the outside through the variables x,y,z. The one
solution construct can also contain non-local parameters.
The one-solution construct in Trilogy is a tame version of the
cut of Prolog. I have included it in the version 1.3 and not in
the previous versions because until now I could not explain it
logically, and obviously I do not want any hacks in Trilogy.
I have written a paper on the one solution construct which I will
mail to all interested parties on request. The title is:
The Logical Reconstruction of Cuts as One Solution Operators.
Technical Details
Message-ID:
<2217@ubc-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ll-xn!mit-eddie!uw-beaver!ubc-cs!vodaReferences:
<900@cresswell.quintus.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ll-xn!mit-eddie!uw-beaver!ubc-cs!voda From: voda@ubc-cs (Paul Voda) Newsgroups: comp.lang.prolog Subject: Re: :- deterministic (not HP Prolog, but Trilogy) Message-ID: <2217@ubc-cs.UUCP> Date: 27 Apr 88 05:39:04 GMT References: <900@cresswell.quintus.UUCP> Sender: nobody@ubc-cs.UUCP Reply-To: voda@ubc-cs.UUCP (Paul Voda) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 41 Keywords: Deterministic predicates and also Cuts