Skip to main content

Optimizing almost-tail-recursive prolog programs

  • Conference paper
  • First Online:
Book cover Functional Programming Languages and Computer Architecture (FPCA 1985)

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

Abstract

There is a wide class of problems for which the natural Prolog specification, as a top-down, recursive computation, is significantly less efficient than an iterative bottom-up version. However, the transformation from the top-down specification to the bottom-up implementation is not always obvious, principally due to problems with nondeterminism and the order in which variables get bound — problems which do not arise in comparable situations in functional languages. This paper illustrates how these problems can be handled in certain cases, and the transformation mechanized, using algebraic properties of operators such as associativity and distributivity. The resulting programs are tail-recursive, and hence significantly more efficient in space usage, with no deterioration in execution speed.

This work was supported in part by the National Science Foundation under grant number DCR-8407688.

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.

7. References

  1. J. Arsac and Y. Kodratoff, “Some Techniques for Recursion Removal from Recursive Functions”, ACM Trans. Prog. Lang. and Systems, 4, 2 (Apr. 1982), 295–322.

    Google Scholar 

  2. R. S. Bird, “The Promotion and Accumulation Strategies in Transformational Programming”, ACM Trans. Prog. Lang. and Systems, 6, 4 (Oct. 1984), 487–504.

    Google Scholar 

  3. M. Bruynooghe, “The Memory Management of PROLOG Implementations”, in Logic Programming, K. L. Clark and S. Tarnlund, (eds.), Academic Press, London, 1982. A.P.I.C. Studies in Data Processing No. 16.

    Google Scholar 

  4. R. M. Burstall and J. Darlington, “A Transformation System for Developing Recursive Programs”, J. ACM, 24, 1 (January 1977), 44–67.

    Google Scholar 

  5. K. L. Clark and S. Sickel, “Predicate Logic: a calculus for deriving programs”, in Proc. IJCAI-77, Boston, 1977.

    Google Scholar 

  6. N. H. Cohen, “Source-to-Source Improvement of Recursive Programs”, Ph.D. Thesis, Harvard University, Cambridge, MA, May 1980.

    Google Scholar 

  7. J. Darlington and R. M. Burstall, “A System which Automatically Improves Programs”, Acta Informatica, 6, (1976), 41–60.

    Google Scholar 

  8. C. J. Hogger, “Derivation of Logic Programs”, J. ACM, 23, 4 (1976),.

    Google Scholar 

  9. R. B. Kieburtz and J. Schultis, “Transformations of FP Program Schemes”, in Proc. 1981 Conf. Func. Prog. Langs. and Comp. Arch., ACM, Portsmouth, New Hampshire, Oct. 1981.

    Google Scholar 

  10. M. K. Srivas, personal communication, Nov. 1984.

    Google Scholar 

  11. E. St.-James, “Recursion is More Efficient than Iteration”, in Proc. 1984 ACM Symp. on LISP and Functional Programming, Austin, Texas, Aug. 1984.

    Google Scholar 

  12. H. Tamaki and T. Sato, “Unfold/Fold Transformations of Logic Programs”, in Proc. 2nd. Logic Programming Conference, Uppsala, Sweden, 1984.

    Google Scholar 

  13. D. H. D. Warren, “An improved Prolog implementation which optimises tail recursion”, Research Paper 156, Dept. of Artificial Intelligence, University of Edinburgh, Scotland, 1980. Presented at the 1980 Logic Programming Workshop, Debrecen, Hungary.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Jean-Pierre Jouannaud

Rights and permissions

Reprints and permissions

Copyright information

© 1985 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Debray, S.K. (1985). Optimizing almost-tail-recursive prolog programs. In: Jouannaud, JP. (eds) Functional Programming Languages and Computer Architecture. FPCA 1985. Lecture Notes in Computer Science, vol 201. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-15975-4_38

Download citation

  • DOI: https://doi.org/10.1007/3-540-15975-4_38

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-15975-9

  • Online ISBN: 978-3-540-39677-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics