cdsm@icdoc.UUCP (Chris Moss) (03/20/85)
Logically, though not in implementation terms, the standard cut/slash primitive in Prolog does two things: 1. It prevents backtracking to any calls in this clause. 2. It prevents the evaluation of other clauses for the same predicate. What I would like to ask Prolog implementors is: are there any major problems in providing a primitive which does the second of these without the first? There's a paper by Smolka (Making Control and Data Flow in Logic Programs Explicit. by Gert Smolka (Cornell), in ACM Functional Programming Conference, 1984, pp 311-322.) which proposes replacing the standard cut by this 'soft' cut and a 'functional call' primitive, which between them seem to cater for all the reasonable uses of cut. I am at the moment asking something more modest (provide it in addition), but I need to motivate what are the advantages of such a primitive. It is impossible at the moment to provide a test which is fully equivalent to the addition of negation of the test added to subsequent clauses: e.g. A if test & then. A if not(test) & else. is NOT equivalent to: A if test & ! & then. A if else. because if 'then' backtracks to 'test' the second formulation does not yield extra answers. The 'soft' cut does the trick fine. In general it is impossible to evaluate all the solutions to a subproblem with cut distinguishing the case which there are no answers from the case in which there is one or more. An obvious example where this is desirable is a supervisor which prints "no answers" in the first case and the answers in the second case. We usually have to resort to "no (more) answers" or similar. Again, the soft cut is adequate. In a straightforward Prolog implementation there seem to be no problems in implementing this, although some entries on the reset list might never be accessed. But there may be interactions with various tail recursion and other optimisations in compiling that I don't know about. I'd be interested in people's ideas, whether they see problems or not.