Path: 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 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 @i, @i, ... 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. (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(), 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?