Skip to main content

An interpreter with lazy evaluation for Prolog with functions

  • Conference paper
  • First Online:
CSL '88 (CSL 1988)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 385))

Included in the following conference series:

  • 154 Accesses

Abstract

If Horn clause logic is enriched with functions that are specified via (conditional) equations, the well-known SLD-resolution algorithm has to be extended by a semantic unification. An implementation of such a language has to be designed very carefully to reach the performance of modern functional languages like ML or Miranda. It is also desirable to have a lazy evaluation mechanism, at least for the functional portion of the language.

We define a syntax and informal semantics for logic programs with functions. The evaluation of function calls is lazy. The language is designed to be practically useful (e. g. all predefined predicates of the host Prolog can be used in the definition of functions and predicates) and to have a close co-operation of the logical and functional parts of a program.

A naive interpreter is described to show certain kinds of problems minimizing the number of reduction steps. Then our approach is presented which includes an interpreter and a compiler (both written in Prolog) to transform the clauses into a form suitable for efficient interpretation. A special term representation is essential for an efficient execution of the reduction steps. This term representation may be characterized as delayed unification.

Finally we argue that our term representation is very suitable for implementation within the Prolog interpreter itself, i. e. not on the meta-level. This will lead to a really efficient implementation of the combined logic and functional programming paradigm.

A listing of the interpreter is included in the appendix.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

9 References

  1. Colmerauer, A.: Prolog and Infinite Trees In: Clark, K.L; Tärnlund, S.-A. (eds.): Logic Programming Academic Press, 1982

    Google Scholar 

  2. DeGroot, D.; Lindstrom, G.: Logic Programming: Functions, Relations, and Equations Prentice-Hall, 1986

    Google Scholar 

  3. Laville, Alain: Implementation of Lazy Pattern Matching Algorithmus In: Ganzinger, H. (ed.): 2nd European Symposium on Programming, Nancy, France, March 21–24, pp. 298–316 Lecture Notes in Computer Science 300, Springer Verlag, 1988

    Google Scholar 

  4. Lloyd, J. W.: Foundations of Logic Programming, Springer Verlag, 1984

    Google Scholar 

  5. Reddy, U. S.: Narrowing as the Operational Semantics of Functional Languages In: Symposium on Logic Programming, Boston, 1985

    Google Scholar 

  6. Rety, P.; Kirchner, C.; Kirchner, H.; Lescanne, P.: NARROWER: a new algorithm for unification and its application to Logic Programming In: Rewriting Techniques and Applications, Dijon, 1985

    Google Scholar 

  7. Robinson, J. A.: A Machine-Oriented Logic Based on the Resolution Principle In: Journal of the ACM 12, 1 (Jan. 1965), 23–41

    Article  Google Scholar 

  8. Robinson, G.A.; Wos, L.: Paramodulation and Theorem Proving in First-Order Theories with Equality In: Michie, D. (ed.): Machine Intelligence 4 Edinburgh University Press, Halsted Press, 1969

    Google Scholar 

  9. Sterling, L; Shapiro, E.: The Art of Prolog, The MIT Press, 1986

    Google Scholar 

  10. Subrahmanyam, P. A.; You, J-H.: Pattern Driven Lazy Reduction: A Unifying Evaluation Mechanism for Functional and Logic Programs

    Google Scholar 

  11. Subrahmanyam, P. A.; You, J-H.: FUNLOG: a Computational Model Integrating Logic Programming and Functional Programming In: [DeGroot, Lindstrom 1986]

    Google Scholar 

  12. Turner, D.A.: Miranda: A Non-Strict functional Language with Polymorphic Types In: Jouannaud, J.-P. (ed): Functional Programing Languages and Computer Architecture Lecture Notes in Computer Science 201, Springer Verlag, 1985

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Egon Börger Hans Kleine Büning Michael M. Richter

Rights and permissions

Reprints and permissions

Copyright information

© 1989 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Lüttringhaus, S. (1989). An interpreter with lazy evaluation for Prolog with functions. In: Börger, E., Büning, H.K., Richter, M.M. (eds) CSL '88. CSL 1988. Lecture Notes in Computer Science, vol 385. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0026303

Download citation

  • DOI: https://doi.org/10.1007/BFb0026303

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-51659-0

  • Online ISBN: 978-3-540-46736-6

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics