🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3639

rule/2

#3639
From: Bart Demoen
Date: Tue, 06 Sep 1988 12:06
52 lines
1905 bytes
In article <619@ecrcvax.UUCP> bruno@ecrcvax.UUCP (Bruno Poterie) writes:

>This may be alright if you seek only efficieny, but:
>	o  you cannot use rule/2 for clause retrieval anymore
>	o  you increase the size of your database by a non-neglectable factor
>	o  you fill up your dictionnary with functors 

Just for the sake of completeness, I include the 2 representations again:

repr1
-----
rule(append([],_l,_l),[]) .
rule(append([_x|_l1],_l2,[_x|_l3]),[append(_l1,_l2,_l3)]) .

rule(nrev([],[]),[]) .
rule(nrev([_x|_r],_o),[nrev(_r,_o1) , append(_o1,[_x],_o)]) .


repr2
-----
rule(append(_x,_y,_z),_b) :- append(_x,_y,_z,_b) .
rule(nrev(_x,_y),_b) :- nrev(_x,_y,_b) .

append([],_l,_l,[]) .
append([_x|_l1],_l2,[_x|_l3],[append(_l1,_l2,_l3)]) .

nrev([],[],[]) .
nrev([_x|_r],_o,[nrev(_r,_o1) , append(_o1,[_x],_o)]) .


repr1 is repr2 partially evaluated; so, if you can use repr1 for clause
retrieval, you can use repr2 for clause retrieval as well (of course you can)

I tested your second remark, on the database size, in BIMprolog, but the result
might be the same for other implementations as well; and the result is not
that surprising:

repr2 uses 8 WAM instructions LESS than repr1
repr2 uses 260 native code bytes LESS than repr1

doesn't that outweight the 2 entries more repr2 takes in the functor table ?

of course, I only tested this one small program, but I think it is applicable
to most programs

bimbart@kulcs.uucp
Bart Demoen
Dept. of Computer Science
Celestijnenlaan 200A
B-3030 Leuven
Belgium
Technical Details
Message-ID: <1431@kulcs.kulcs.uucp>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!prlb2!kulcs!bimbart

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!prlb2!kulcs!bimbart
From: bimbart@kulcs.uucp (Bart Demoen)
Newsgroups: comp.lang.prolog
Subject: rule/2
Message-ID: <1431@kulcs.kulcs.uucp>
Date: 6 Sep 88 12:06:46 GMT
Reply-To: bimbart@kulcs.UUCP (Bart Demoen)
Organization: Katholieke Universiteit Leuven, Dept. Computer Science
Lines: 52