🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3278

:- deterministic (HP Prolog)

#3278
From: Richard A. O'Keefe
Date: Mon, 25 Apr 1988 23:31
48 lines
2119 bytes
HP Prolog has a declaration ":- deterministic".  The entire description
in the manual reads thus:

    "	The deterministic predicate specifies predicates having at most
	one solutions.

	@b<deterministic> @i<Pred1>, @i<Pred2>, ...

	Predn	: a predicate specification.

	The specified predicates are deterministic, i.e. they can never
	have more than one solution.  This information is used by the
	compiler and interpreter to increase efficiency.  A determinstic
	declaration must stand before all clauses of the predicate in the
	source file.	"

Now plagiarism is the sincerest form of flattery, and I don't see why
Quintus shouldn't flatter any good ideas that are going around, but it
is hard to steal an idea you don't understand.  My problem is that I
can't figure out what :- deterministic @i<means>.  (Somewhere at the
bottom of about 20 feet of reports and papers I have a copy of something
by Kamran Parsaye, I think in 1982 or 1983, where he proposed a
:-determinate declaration, or was it :-function pred(<mode>), but I
don't remember grasping that either.)

There is an obvious kludge, namely interpreting this as "add a cut at
the end of every clause of the indicated predicate", but that is clearly
not what is intended, because it would be a sure-fire recipe for making
non-steadfast predicates.  What I'm getting at is that if you do e.g.

	:- deterministic fac/2.

	fac(0, 1).
	fac(1, 1).
	fac(N, F) :- M is N-1, fac(M, G), F is G*N.

then it should be translated as

	fac(0, X) :- !, X = 1.
	fac(1, X) :- !, X = 1.
	fac(N, F) :- M is N-1, fac(M, G), F is G*N.

not as

	fac(0, 1) :- !.

and so on.  So presumably the :-deterministic directive must take the
declared :-mode into account, but how exactly does it do this?  Anyone know?
Technical Details
Message-ID: <900@cresswell.quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: :- deterministic (HP Prolog)
Message-ID: <900@cresswell.quintus.UUCP>
Date: 25 Apr 88 23:31:04 GMT
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 48