This Article 
 Bibliographic References 
 Add to: 
Towards Banishing the Cut from Prolog
March 1990 (vol. 16 no. 3)
pp. 335-349

Logic programs can often be 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. The authors 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. Two language constructs, firstof and oneof, for situations involving don't-care nondeterminism, are suggested. 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.

[1] M. Bruynooghe, "The memory management ot PROLOG implementations," inLogic Programming, K. L. Clark and S. Tarnlund, Eds. London: Academic, 1982; also A.P.I.C. Studies in Data Processing, no. 16.
[2] K. L. Clark, "Negation as failure," in Logic and Data Bases, H. Gallaire and J. Minker, Eds. New York: Plenum, 1978.
[3] W. F. Clocksin and C. S. Mellish,Programming in Prolog. New York: Springer-Verlag, 1984.
[4] S. K. Debray, "Program transformations for failure driven space reclamation in Prolog," Dep. Comput. Sci., SUNY at Stony Brook, Stony Brook, NY, Tech. Rep. 85/32, Dec. 1985.
[5] S. K. Debray, "The SB-Prolog System Version 2.3.2 A user manual," Dep. Comput. Sci., Univ. Arizona, Tucson, Tech. Rep. 87-15, Dec. 1987; revised Mar. 1988.
[6] S. K. Debray and P. Mishra, "Denotational and operational semantics for Prolog,"J. Logic Program., vol. 5, no. 1, pp. 61-91, Mar. 1988.
[7] S. K. Debray and D. S. Warren, "Automatic mode inference for logic programs,"J. Logic Program., vol. 5, no. 3, pp. 207-229, Sept. 1988.
[8] S. K. Debray and D. S. Warren, "Functional computation in logic programs,"ACM Trans. Programming Languages and Syst., vol. 11, no. 3, pp. 451-481, July 1989.
[9] N. D. Jones and A. Mycroft, "Stepwise development of operational and denotational semantics for PROLOG," inProc. 1984 Int. Symp. Logic Programming, IEEE Comput. Soc., Atlantic City, NJ, Feb. 1984, pp. 289-298.
[10] K. Kahn, "Unique features of LISP machine Prolog," Univ. Uppsala, Sweden, UPMAIL Rep. 14, 1983.
[11] J. W. Lloyd,Foundations of Logic Programming, New York: Springer, 1984.
[12] D. Maier,The Theory of Relational Databases. Rockville, MD: Computer Science Press, 1983.
[13] C. S. Mellish, "The automatic generation of mode declarations for Prolog programs," Dep. Artificial Intell., Univ. Edinburgh, DAI Res. Paper I63, Aug. 1981.
[14] C. S. Mellish, "Some global optimizations for a Prolog compiler,"J. Logic Program., vol. 2, no. 1, pp. 43-66, Apr. 1985.
[15] C. Moss, "Results of cut tests,"Prolog Electron. Dig., vol. 3, no. 42, Oct. 9, 1985.
[16] R. A. O'Keefe, "On the treatment of cuts in Prolog source-level tools," inProc. 1985 Symp. Logic Programming, Boston, MA, July 1985, pp. 73-77.
[17] P. Reintjes, "AUNT--A universal netlist translator," inProc. Fourth IEEE Symp. Logic Programming, San Francisco, CA, Aug. 1987, pp. 508-515.
[18] J. A. Robinson, "A machined-oriented logic based on the resolution principle,"J. Assoc. Comput. Mach., vol. 12, no. 1, pp. 23-41, Jan. 1965.
[19] J. A. Robinson, "Logic programming--Past, present and future,"New Generation Comput., vol. 1, no. 2, 1983.
[20] H. Sawamura and T. Takeshima, "'Recursive unsolvability of determinacy, solvable cases of determinacy and their applications to Prolog optimization," inProc. 1985 Symp. Logic Programming. Boston, MA, July 1985, pp. 200-207.
[21] D. H. D. Warren, "Implementing Prolog--Compiling predicate logic programs," Dep. Artificial Intell., Univ. Edinburgh, Res. Reps. 39, 40, 1977.
[22] D. H. D. Warren, "An improved Prolog implementation which optimises tail recursion," Dep. Artificial Intell., Univ. Edinburgh, Scotland, Res. Paper 156, 1980; presented at the 1980 Logic Programming Workshop, Debrecen, Hungary.

Index Terms:
logic programs; impure language features; impure features; Prolog source programs; static analysis; compile time; program transformations; language constructs; firstof; oneof; nondeterminism; declarative readings; cut; parallel evaluation strategies; purer programming style; logic programming; PROLOG.
S.K. Debray, D.S. Warren, "Towards Banishing the Cut from Prolog," IEEE Transactions on Software Engineering, vol. 16, no. 3, pp. 335-349, March 1990, doi:10.1109/32.48941
Usage of this product signifies your acceptance of the Terms of Use.