The University of Arizona
banner image

  Towards Banishing the Cut from Prolog

Saumya Debray and David S. Warren
Department of Computer Science
SUNY at Stony Brook
Stony Brook, NY 11794, U.S.A.
 

Abstract
There has been a great deal of interest in logic programming languages in recent years. This is due, in great part, to the advantages offered by these languages: declarative readings of programs and separation of program logic from control. However, logic programs can often be dismayingly inefficient. The usual solution to this problem has been to return some control to the user in the form of impure language features like cut. Unfortunately, this often results in the loss of precisely those features that made logic programming attractive in the first place.

We argue that it is not necessary to resort to such impure features for efficiency. This point is illustrated by considering how most of the common uses of cut can be eliminated from Prolog source programs, relying on static analysis to generate them at compile time. Three common situations where the cut is used are considered. Static analysis techniques are given to detect such situations, and applicable program transformations are described. We also suggest two language constructs, firstof and oneof, for situations involving ``don't-care'' nondeterminism. These constructs have better declarative readings than the cut, and extend better to parallel evaluation strategies. Together, these proposals result in a system where users need rely much less on cuts for efficiency, thereby promoting a purer programming style without sacrificing efficiency.