bimbart@kulcs.uucp (Bart Demoen) (09/12/88)
This is a reply to article <358@quintus.UUCP> (R. O'Keefe) whose author does not understand why the mentioned metainterpreter does not work for programs containing metacall if ! does cut outside the scope of call/1; so, I will show it: first of all, the metainterpreter does not handle builtinpredicates, so one has to add a rule like: prove(Goal) :- builtin(Goal) , ! , call(Goal) . suppose there are two definitions of rule/4: rule(a(X),[],0,[call(X)]) . rule(a(X),[],0,[write('not cut away')]) . and execute the query ?- prove(a(!)) . the result is the same is for the program a(X) :- call(X) . a(X) :- write('not cut away') . and query ?- a(!) . only if !/0 does NOT cut outside call/1
ok@quintus.uucp (Richard A. O'Keefe) (09/14/88)
In article <1435@kulcs.kulcs.uucp> bimbart@kulcs.UUCP (Bart Demoen) writes: >This is a reply to article <358@quintus.UUCP> (R. O'Keefe) >whose author does not understand why the mentioned metainterpreter does not >work for programs containing metacall if ! does cut outside the scope of call/1; >so, I will show it: This is an unwarranted inference about what I do and do not understand. The thing I didn't understand was >>Demoen's message<<. Bear in mind that *NONE* of the interpreters described in my tutorial is supposed to be able to handle call/1, and only one of them is supposed to be able to handle cuts. >first of all, the metainterpreter does not handle builtinpredicates, so >one has to add a rule like: > prove(Goal) :- > builtin(Goal), > !, > call(Goal). People who have read the tutorial in question or who have followed the discussion in this newsgroup will recall that the interpreters I described (a) aren't *supposed* to handle arbitrary built-in predicates, but (b) can handle any *specific* built-in predicate by building it into the rule/3 table. For example, rule(write(X), B, B) :- write(X). rule(nl, B, B) :- nl. In particular, since the Horn-clause languages I presented interpreters for do not use the same representation as Prolog, it simply would not make SENSE for them to call Prolog's call/1. It does make sense for them to call prove/1, which can be done by adding the clause rule(prove(X), B, B) :- prove(X). or even rule(prove(X), [X|B], B). >Suppose there are two definitions of rule/4: > rule(a(X),[],0,[call(X)]) . > rule(a(X),[],0,[write('not cut away')]) . >and execute the query > ?- prove(a(!)) . >The result is the same as for the program > a(X) :- call(X) . > a(X) :- write('not cut away') . > and query ?- a(!) . >only if !/0 does NOT cut outside call/1 And that is exactly the way that call/1 works in DEC-10 Prolog and C Prolog and ALS Prolog and others. I'm afraid that I didn't feel any obligation in my tutorial to explain how to do everything in every possible dialect of Prolog. I didn't even feel obliged to say how to do everything in VM/PROLOG or micro-PROLOG. The mnemonic, by the way, is that cuts can cut through built in control structures made of punctuation marks (',', ';', '|', '->', '(' ')', '{' '}', even '\+') but not through ones made of letters (call, setof, bagof, findall, once, forall, ...). It is possible to break *any* program by making it do things the author deliberately chose not to make it do and then assuming that the primitives the new code uses don't work properly. Big deal.
bruno@ecrcvax.UUCP (Bruno Poterie) (09/15/88)
In article <1435@kulcs.kulcs.uucp> bimbart@kulcs.UUCP (Bart Demoen) writes: >This is a reply to article <358@quintus.UUCP> (R. O'Keefe) >whose author does not understand why the mentioned metainterpreter does not >work for programs containing metacall if ! does cut outside the scope of call/1; >so, I will show it: [...deleted...] >only if !/0 does NOT cut outside call/1 First point: i consider that the war O'Keefe/Demoen --> Quintus/BIM is going somehow outside of control, and that the metainterpret looks more like an innocent hostage, or like a pretext, or both. So why do you not choose a place and a time (say, Hyde Park, 1st November, 5 am), pick up 4 of us as witness, and try to solve it with some sword? I think it is time to stop and cool the thing down, or the net will burn soon :-) Second point: now i am probably so stupid, but i was taught the following model for prolog procedures, predefined or not: Head<1> :- Goal<1,1>, ...Goal<1,i>, ... Goal<1,n>. ... Head<j> :- Goal<j,1>, ...Goal<j,i>, ... Goal<j,n>. ... Head<m> :- Goal<m,1>, ...Goal<m,i>, ... Goal<m,n>. where a cut appearing in the list of goals being the body of the clause <j> had as effect to remove all choices created since passing the neck of this clause, and including the neck itself, i.e. forgetting the remaining clauses [j+1 .. m]. and that BIPs had the following form: BipHead :- { and-written body } then the call/1 predicate is defined as: call(X) :- X. where X is dynamically replaced by its value. Now considering both sub-models, if the value of the variable X is the term ! <atom>, then the effect of call(!) is to remove all choices between the neck of call/1 and the substitution of X by !, including remaining clauses for call/1. But the cut will -and can- NEVER affect choices which are olders than the passing of the neck of call/1. If you want this can of thing, then you have to use a labelled cut, in fact a set of BIPs which as a side-effect update the choice-points stack (or whatever you use as a backtrack control structure). But then this is completely different from a cut, which is integrated into the virtual machine (as well as the if-then-else (A->B;C)). Therefore building your critic on the final remark that >only if !/0 does NOT cut outside call/1 is almost surrealistic ;-)
ok@quintus.uucp (Richard A. O'Keefe) (09/17/88)
In article <623@ecrcvax.UUCP> bruno@ecrcvax.UUCP (Bruno Poterie) writes: >First point: I consider that the war O'Keefe/Demoen --> Quintus/BIM is going > somehow outside of control, and that the meta-interpreter looks more > like an innocent hostage, or like a pretext, or both. So why do you > not choose a place and a time (say, Hyde Park, 1st November, 5 am), > pick up 4 of us as witnesses, and try to solve it with some sword? > I think it is time to stop and cool the thing down, or the net will > burn soon :-) Funny, I thought the attack was over. You are throwing oil on a dying fire, not troubled waters! I have no desire to attack Demoen, nor is there any dissension between Quintus-the-company and BIM-the-company. As for Quintus-Prolog-the-language and BIM-Prolog-the-language, the official Quintus viewpoint is "probeat emptor"(*), and no doubt BIM have the same justified confidence in their product. Indeed, I owe Demoen a debt of gratitude: as a result of the publicity he has given my tutorial in this newsgroup I have had several enquiries about its availability. The answer is that I have submitted it to a publisher as a work in progress; as for the version which was around at the conference, you'll have to ask the conference organisers. (*) "Let (the) buyer try (it)".