kwc@naucse.UUCP (Ken Collier) (02/10/90)
I am in need of a prolog interpreter that supports the following utilities: recorda recordz erase recorded We are currently using version 3.0 of the SBProlog interpreter from Sunny Brook New York, running on a MicroVAX on top of Berkeley UNIX. Does anyone know of any public domain Prolog which supports these utilities? If so, how can I get them? (I can ftp if I know the archive) Please email any relevant information. Thanx in advance. Ken Collier ...arizona!naucse!kwc College of Engineering and Technology Bitnet: collier@nauvax Northern Arizona University Flagstaff, Arizona
ok@goanna.oz.au (Richard O'keefe) (02/13/90)
In article <1871@naucse.UUCP>, kwc@naucse.UUCP (Ken Collier) writes: > I need a Prolog interpreter that supports the following utilities: > recorda/3 > recordz/3 > erase/1 > recorded/3 > We are currently using version 3.0 of the SB Prolog interpreter from > Sunny Brook New York, running on a MicroVAX on top of Berkeley UNIX. Given that the SB in SB Prolog stands for Stony Brook and that SB Prolog is a compiler, are you _sure_ you're using SB Prolog? I just FTPd a copy of the 3.1 SB Prolog manual, and each of these commands is described in that manual. The commands recorda/3, recordz/3, recorded/3, and erase/1 can be simulated quite easily. Recall the interface: recorda(+Key, +Term, -Ref) recordz(+Key, +Term, -Ref) recorded(+Key, ?Term, ?Ref) or recorded(?Key, ?Term, +Ref) erase(+Ref) In this interface, the significant part of Key is the FUNCTOR, that is the *pair* FunctionSymbol/Arity; Term is any term, even a variable, and all that is guaranteed about Refs is that they are ground terms uniquely labelling (records in the recorded data base or clauses in the clause store). Data base references are not an "efficiency" hack but a SEMANTIC hack; they are unique names. So, let's maintain two tables. The first table will be a table of counters and the second will be a table of the actual records. We'll represent a data base reference by a triple '$REF'(F,N,I) meaning the Ith tuple to be stored under the key F/N. :- dynamic ref_counter/2, recorded/3. recorda(Key, Term, Ref) :- ref_counter(Key, Tag, Ref), asserta(recorded(Tag,Term,Ref)). recordz(Key, Term, Ref) :- ref_counter(Key, Tag, Ref), assertz(recorded(Tag,Term,Ref)). erase(Ref) :- retractall(recorded(_,_,Ref)). ref_counter(Key, Tag, '$REF'(F,N,I)) :- functor(Key, F, N), functor(Tag, F, N), ( ref_counter(Tag, I0) -> I is I0+1, asserta(ref_counter(Tag,I)), retractall(ref_counter(Tag, I0)) ;/* this Tag has not been used as a Key before */ I is 1, asserta(ref_counter(Tag,I)) ). Note that DEC-10 Prolog accepts integers as Keys (Quintus Prolog imitates this) and so does this code. However, this code also accepts floats as Keys, which DEC-10 Prolog and Quintus Prolog don't. I assume that this doesn't matter. This implementation is not supposed to be particularly fast, but then if speed were of the first importance you wouldn't be using a free compiler. More seriously, the counters may run out, but you should be able to do ~100 million recordas or recordzs under any given key before that happens. There are obvious ways around that.