[net.lang.prolog] Investigating implementations of cut

cdsm@icdoc.UUCP (06/28/85)

		Implementations of CUT

	As part of the BSI Prolog standardisation process I am
looking at the way in which cut is implemented in different
Prolog systems. The following program illustrates the
differences which have been found. I would be grateful if you
could run the program on your system and send me the answers; if
you have an interpreter and compiler please execute it for both
systems. 

---------------------------------------------------------
/* Tests to distinguish various implementations of cut */
/* Chris Moss, Imperial College, June 1985 */

test1 :- do('Testing that cut is implemented). ', t1).
test2 :- do('Test if cut acts within disjunction', t2).
test3 :- do('Test if it cuts previous choices within disjunction', t3).
test4 :- do('Test if cut acts when passed as metacall', t4).
test5 :- do('Test if & cut acts within metacall', t5 ).
test6 :- do('Test if cut acts through not', t6).

do(Message,Test) :- w(Message), Test.
do(Message,Test) :- w('Does act').
w(X) :- write(X), nl.  
t :- w('Does not act').

t1  :- (true;w('Did not cut alternatives correctly'),fail),
       !, w('Succeeds going forwards'), fail.
t1  :- w('Failed to cut goal'). 

t2  :- (!;w('Fails to cut disjoint alternatives')), fail.
t2  :- t.

t3  :- t3a(X),(!,fail;w('Fails to cut disjunction')).
t3  :- t.
t3a(!).
t3a(X) :- w('Did not cut alternatives'), fail.

t4  :- t3a(X), X, w('Ok going forwards'),fail.
t4  :- t.

t5  :- t5a(X), X, fail.
t5  :- t.
t5a((true,!)).

t6  :- not(not(!)), fail.
t6  :- t.

-------------------------------------------------

From initial tests we have the following results:

Implementation		Test 1  2  3  4  5  6  

DEC10 Compiler		     Y  Y  Y  Y  Y  Y
Waterloo, MUprolog	     Y  Y  Y  Y  Y  N
DEC10 int, CProlog	     Y  Y  Y  N  N  N
POPLOG			     Y  Y  Y  I  I  I
micro, sigma		     Y  N  N  Y  Y  N

where Y means did cut, N means did not cut and I means that it
was trapped as an illegal use and failed.
Note that in all cases 2=3 and 4=5; however in some
implementations this may not be the case.
If there are any other discriminating cases not covered above I
would be glad to hear of them.