Skip to main content

Unfolding — definition — folding, in this order, for avoiding unnecessary variables in logic programs

  • Sessvon: Optimization Techniques
  • Conference paper
  • First Online:
Programming Language Implementation and Logic Programming (PLILP 1991)

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

Abstract

We take a syntactically based approach to the automatic improvement of performances of logic programs by using the unfold/fold transformation technique. A cause of program inefficiency is often the presence of variables which are unnecessary, in the sense that they force computations of redundant values or multiple visits of data structures.

We propose a strategy which automatically transforms initial program versions into new efficient versions by avoiding unnecessary variables. Our strategy is an extension of the one which was introduced in an earlier paper [Proietti-Pettorossi 90]. It is based on the syntactical characterization of the unnecessary variables and the introduction of a composite transformation rule made out of unfolding-definition-folding steps, in this order. The strategy consists in the repeated application of this composite rule to each clause with unnecessary variables. It avoids the search for eureka definitions which is often required by other techniques proposed in the literature. We define a class of programs for which our transformation strategy is successful and we propose a variant of that strategy which uses the so-called Generalization Rule. This variant is always terminating, but, in general, not all unnecessary variables are eliminated.

This work has been partially supported by the “Progetto Finalizzato Sistemi Informatici e Calcolo Parallelo” of the CNR and MPI 40% (Italy).

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.

8. References

  1. Burstall, R.M. and Darlington, J.: "A Transformation System for Developing Recursive Programs", JACM, Vol. 24, No. 1, January 1977, pp. 44–67.

    Google Scholar 

  2. CIP Language Group: "The Munich Project CIP" Lecture Notes in Computer Science, 1984.

    Google Scholar 

  3. Debray, S.K.: "Unfold/Fold Transformations and Loop Optimization of Logic Programs", Proc. SIGPLAN 88, Conference on Programming Language Design and Implementation, Altanta, Georgia, 1988.

    Google Scholar 

  4. Debray, S.K. and Warren, D.S.: "Functional Computations in Logic Programs", ACM TOPLAS, 11 (3), 1989, pp. 451–481.

    Google Scholar 

  5. Feather, M.S.: "A Survey and Classification of Some Program Transformation Techniques", Proc. TC2 IFIP Working Conference on Program Specification and Transformation, Bad Tölz, Germany, 1986.

    Google Scholar 

  6. Hogger, C.J.: "Derivation of Logic Programs", JACM, No. 28, 2, 1981, pp. 372–392.

    Google Scholar 

  7. Kawamura, T. and Kanamori, T.: "Preservation of Stronger Equivalence in Unfold/Fold Logic Program Transformation", Proc. Int. Conf. on Fifth Generation Computer Systems, Tokyo, 1988, pp. 413–422.

    Google Scholar 

  8. Lloyd, J.W.: "Foundations of Logic Programming", Springer-Verlag, Berlin, Heidelberg, New York, Tokyo, 2nd edition, 1987.

    Google Scholar 

  9. Paige, R. and Koenig, S.: "Finite Differencing of Computable Expressions" ACM TOPLAS 4 (3) July 1982, pp. 402–454.

    Google Scholar 

  10. Pettorossi, A.: "Transformation of Programs and Use of Tupling Strategy", Proc. Informatica 77, Bled, Yugoslavia, 1977, pp. 3 103, 1–6.

    Google Scholar 

  11. Pettorossi, A. and Proietti, M.: "Importing and Exporting Information in Program Development", Proc. IFIP TC2 Workshop on Partial Evaluation and Mixed Computation, Gammel Avernaes, Denmark, North Holland 1987, pp. 405–425.

    Google Scholar 

  12. Proietti, M. and Pettorossi, A.: "Synthesis of Eureka Predicates for Developing Logic Programs", Proc. ESOP 90, Copenhagen, 1990, Lecture Notes in Computer Science No. 432, pp. 306–325.

    Google Scholar 

  13. Tamaki, H. and Sato, T.: "Unfold/Fold Transformation of Logic Programs", Proc. 2nd International Conference on Logic Programming, Uppsala, Sweden, 1984.

    Google Scholar 

  14. Wadler, P. L.: "Deforestation: Transforming Programs to Eliminate Trees", Proc. ESOP 88, Nancy, France, 1988, Lecture Notes in Computer Science 300, pp. 344–358.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Jan Maluszyński Martin Wirsing

Rights and permissions

Reprints and permissions

Copyright information

© 1991 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Proietti, M., Pettorossi, A. (1991). Unfolding — definition — folding, in this order, for avoiding unnecessary variables in logic programs. In: Maluszyński, J., Wirsing, M. (eds) Programming Language Implementation and Logic Programming. PLILP 1991. Lecture Notes in Computer Science, vol 528. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-54444-5_111

Download citation

  • DOI: https://doi.org/10.1007/3-540-54444-5_111

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

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

  • Online ISBN: 978-3-540-38362-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics