# Adding equations to NU-Prolog

## Abstract

This paper describes an extension to NU-Prolog which allows evaluable functions to be defined using equations. We consider it to be the most pragmatic way of combining functional and relational programming. The implementation consists of several hundred lines of Prolog code and the underlying Prolog implementation was not modified at all. However, the system is reasonably efficient and supports coroutining, optional lazy evaluation, higher order functions and parallel execution. Efficiency is gained in several ways. First, we use some new implementation techniques. Second, we exploit some of the unique features of NU-Prolog, though these features are not essential to the implementation. Third, the language is designed so that we can take advantage of implicit mode and determinism information. Although we have not concentrated on the semantics of the language, we believe that our language design decisions and implementation techniques will be useful in the next generation of combined functional and relational languages.

## Keywords

Logic Program Logic Programming Function Definition Choice Point Functional Language## Preview

Unable to display preview. Download preview PDF.

## References

- [BCM88]P.G. Bosco, C. Cecchi, and C. Moiso. Exploiting the full power of logic plus functional programming. In Kenneth A. Bowen and Robert A. Kowalski, editors,
*Proceedings of the Fifth International Conference/Symposium on Logic Programming*, pages 3–17, Seattle, Washington, August 1988.Google Scholar - [BCM+90]P.G. Bosco, C. Cecchi, C. Moiso, M. Porta, and G. Sofi. Logic and functional programming on distributed memory architectures. In
*Proceedings of the Seventh International Conference on Logic Programming*, Jerusalem, Israel, June 1990.Google Scholar - [CvER90]M.H.M. Cheng, M.H. van Emden, and B.E. Richards. On warren's method for functional programming in logic. In
*Proceedings of the Seventh International Conference on Logic Programming*, Jerusalem, Israel, June 1990.Google Scholar - [DFP85]J. Darlington, A.J. Field, and H. Pull. The unification of functional and logic languages. In Doug DeGroot and Gary Lindstrom, editors,
*Logic programming: relations, functions, and equations*, pages 37–70. Prentice-Hall, 1985.Google Scholar - [DW86]Saumya K. Debray and David S. Warren. Detection and optimisation of functional computations in prolog. In Ehud Shapiro, editor,
*Proceedings of the Third International Conference on Logic Programming*, pages 490–504, London, England, July 1986. published as Lecture Notes in Computer Science 225 by Springer-Verlag.Google Scholar - [Fri85]Laurent Fribourg. SLOG: a logic programming language interpreter based on clausal superposition and rewriting. In
*Proceedings of the Second IEEE Symposium on Logic Programming*, pages 172–184, Boston, Massachusetts, July 1985.Google Scholar - [GM85]Joseph A. Goguen and Jose Meseguer. EQLOG: equality, types, and generic modules for logic programming. In Doug DeGroot and Gary Lindstrom, editors,
*Logic programming: relations, functions, and equations*, pages 295–363. Prentice-Hall, 1985.Google Scholar - [Gre87]Steve Gregory.
*Parallel logic programming in parlog*. Addison-Wesley, Wokingham, England, 1987.Google Scholar - [JD86]Alan Josephson and Nachum Dershowitz. An implementation of narrowing the RITE way. In
*Proceedings of the Third IEEE Symposium on Logic Programming*, pages 187–197, Salt Lake City, Utah, September 1986.Google Scholar - [Jon87]S. Peyton Jones.
*The implementation of functional programming languages*. Prentice Hall International series in computer science. Prentice Hall, London, 1987.Google Scholar - [Nai86]Lee Naish.
*Negation and control in Prolog*. Number 238 in Lecture Notes in Computer Science. Springer-Verlag, New York, 1986.Google Scholar - [Nai88]Lee Naish. Parallelizing NU-Prolog. In Kenneth A. Bowen and Robert A. Kowalski, editors,
*Proceedings of the Fifth International Conference/Symposium on Logic Programming*, pages 1546–1564, Seattle, Washington, August 1988.Google Scholar - [Nai90]Lee Naish. Adding equations to NU-prolog. Technical Report 91/2, Department of Computer Science, University of Melbourne, Melbourne, Australia, 1990.Google Scholar
- [Nar86]Sanjai Narain. A technique for doing lazy evaluation in logic.
*Journal of Logic Programming*, 3(3):259–276, October 1986.Google Scholar - [Nar88]Sanjai Narain.
*LOG(F): An optimal combination of logic programming, rewriting and lazy evaluation*. Ph.d. thesis, Dept. of computer science, UCLA, Los Angeles, CA, 1988.Google Scholar - [Red85]Uday S. Reddy. Narrowing as the operational semantics of functional languages. In
*Proceedings of the Second IEEE Symposium on Logic Programming*, pages 138–151, Boston, Massachusetts, July 1985.Google Scholar - [She90]Yeh-Heng Sheng. HIFUNLOG: logic programming with higher-order relational functions. In
*Proceedings of the Seventh International Conference on Logic Programming*, Jerusalem, Israel, June 1990.Google Scholar - [SY85]P.A. Subrahmanyam and Jia-Huai You. FUNLOG: a computational model integrating logic programming and functional programming. In Doug DeGroot and Gary Lindstrom, editors,
*Logic programming: relations, functions, and equations*, pages 157–198. Prentice-Hall, 1985.Google Scholar - [War82]David H.D. Warren. Higher-order extensions to prolog: are they needed? In J.E. Hayes, Donald Michie, and Y-H. Pao, editors,
*Machine Intelligence 10*, pages 441–454. Ellis Horwood Ltd., Chicester, England, 1982.Google Scholar - [War83]David H.D. Warren. An abstract Prolog instruction set. Tecnical Note 309, SRI International, Menlo Park, California, October 1983.Google Scholar