bimbart@kulcs.uucp (Bart Demoen) (09/06/88)
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
ok@quintus.uucp (Richard A. O'Keefe) (09/07/88)
In article <1431@kulcs.kulcs.uucp> bimbart@kulcs.UUCP (Bart Demoen) writes: >In article <619@ecrcvax.UUCP> bruno@ecrcvax.UUCP (Bruno Poterie) writes: >>This may be alright if you seek only efficiency, but: >> o you increase the size of your database by a non-negligible factor >> o you fill up your dictionary with functors >[Demoen also included "repr1" and "repr2" again] >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 Demoen has recently been attacking my tutorial as being dialect-specific. In the current version of Quintus Prolog, repr2 occupies 412 bytes (clauses + procedure records) repr1 occupies 312 bytes (clauses + procedure records) rule/3 occupies 300 bytes (clauses + procedure records) where rule/3 is the representation which looks like e.g. rule(append([H|T],L,[H|R]), [append(T,L,R)|Goals], Goals). When making a comparison like this, it is important to make sure that no other storage is being consumed, so I first compiled a dummy file which mentioned all the atoms that appeared in Demoen's examples. There is at least one otherwise sensible Prolog system for PCs which has a rather low limit on the number of predicates a user can define. That's not my reason for not having described the method Demoen refers to as 'repr2', but it does show that Poterie is complaining about a real problem. (The real problem is such low limits, of course.) I don't expect these figures for Quintus Prolog to generalise to other systems, and I was surprised by them myself.