Advertisement

An Automatic Composition Algorithm for Functional Logic Programs

  • María Alpuente
  • Moreno Falaschi
  • Ginés Moreno
  • Germán Vidal
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1963)

Abstract

Functional logic languages with a complete operational semantics are based on narrowing, which combines the instantiation of variables with the reduction of expressions. In this paper, we investigate the relationship between partial evaluation and more general transformations based on folding/unfolding. First, we show that the transformations obtained by partial evaluators can be also achieved by folding/unfolding using a particular kind of eurekas which can be mechanically attained. Then, we propose an algorithm (based on folding/unfolding) which starts with the automatic eureka generation and is able to perform program composition, i. e. it is able to produce a single function definition for some nested functions of the original program. This avoids the construction of intermediate data structures that are produced by the inner function and consumed as inputs by the outer function. As opposed to both partial evaluation and (general) fold/unfold transformations, strong correctness of the transformed programs holds w. r. t. goals which contain calls to the old function symbols—i. e. from the original program—as well as to the new ones—i. e. introduced during the transformation.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    E. Albert, M. Alpuente, M. Falaschi, P. Julián, and G. Vidal. Improving Control in Functional Logic Program Specialization. In G. Levi, editor, Proc. of Static Analysis Symposium, SAS’98, pages 262–277. Springer LNCS 1503, 1998. 292Google Scholar
  2. 2.
    M. Alpuente, M. Falaschi, G. Moreno, and G. Vidal. A Transformation System for Lazy Functional Logic Programs. In A. Middeldorp and T. Sato, editors, Proc. of the 4th Fuji International Symposyum on Functional and Logic Programming, FLOPS’99, Tsukuba (Japan), pages 147–162. Springer LNCS 1722, 1999. 290, 293, 296Google Scholar
  3. 3.
    M. Alpuente, M. Falaschi, and G. Vidal. Partial Evaluation of Functional Logic Programs. ACM Transactions on Programming Languages and Systems, 20(4):768–844, 1998. 290, 292CrossRefGoogle Scholar
  4. 4.
    M. Alpuente, M. Hanus, S. Lucas, and G. Vidal. Specialization of Inductively Sequential Functional Logic Programs. In P. Lee, editor, Proc. of 1999 International Conference on Functional Programming, ICFP’99, Paris (France). ACM, New York, 1999. 291, 292Google Scholar
  5. 5.
    S. Antoy, R. Echahed, and M. Hanus. A Needed Narrowing Strategy. In Proc. 21st ACM Symp. on Principles of Programming Languages, Portland, pages 268–279, New York, 1994. ACM Press. 289Google Scholar
  6. 6.
    R. M. Burstall and J. Darlington. A Transformation System for Developing Recursive Programs. Journal of the ACM, 24(1):44–67, 1977. 290, 293, 294, 295, 296zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    W. Chin. Towards an Automated Tupling Strategy. In Proc. of Partial Evaluation and Semantics-Based Program Manipulation, 1993, pages 119–132. ACM, New York, 1993. 296Google Scholar
  8. 8.
    C. Consel and O. Danvy. Tutorial notes on Partial Evaluation. In Proc. of 20th Annual ACM Symp. on Principles of Programming Languages, pages 493–501. ACM, New York, 1993. 290Google Scholar
  9. 9.
    J. Darlington. Program transformation. In J. Darlington, P. Henderson, and D. A. Turner, editors, Functional Programming and its Applications, pages 193–215. Cambridge UniversityPress, 1982. 294Google Scholar
  10. 10.
    N. Dershowitz and J.-P. Jouannaud. Rewrite Systems. In J. van Leeuwen, editor, Handbook of Theoretical Computer Science, volume B: Formal Models and Semantics, pages 243–320. Elsevier, Amsterdam, 1990. 291Google Scholar
  11. 11.
    J. Gallagher. Tutorial on Specialisation of Logic Programs. In Proc. of Partial Evaluation and Semantics-Based Program Manipulation, Copenhagen, Denmark, June 1993, pages 88–98. ACM, New York, 1993. 290Google Scholar
  12. 12.
    M. Hanus. The Integration of Functions into Logic Programming: From Theory to Practice. Journal of Logic Programming, 19&20:583–628, 1994. 291CrossRefMathSciNetGoogle Scholar
  13. 13.
    N. D. Jones, C. K. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Englewood Cliffs, NJ, 1993. 290zbMATHGoogle Scholar
  14. 14.
    J. W. Lloyd and J. C. Shepherdson. Partial Evaluation in Logic Programming. Journal of Logic Programming, 11:217–242, 1991. 290zbMATHCrossRefMathSciNetGoogle Scholar
  15. 15.
    A. Pettorossi and M. Proietti. A Comparative Revisitation of Some Program Transformation Techniques. In O. Danvy, R. Glück, and P. Thiemann, editors, Partial Evaluation, Int’l Seminar, Dagstuhl Castle, Germany, pages 355–385. Springer LNCS 1110, 1996. 290, 295Google Scholar
  16. 16.
    W. L. Scherlis. Program Improvement byI nternal Specialization. In Proc. of 8th Annual ACM Symp. on Principles of Programming Languages, pages 41–49. ACM Press, New York, 1981. 294Google Scholar
  17. 17.
    H. Tamaki and T. Sato. Unfold/Fold Transformations of Logic Programs. In S. Tärnlund, editor, Proc. of Second Int’l Conf. on Logic Programming, Uppsala, Sweden, pages 127–139, 1984. 290, 295Google Scholar
  18. 18.
    P. L. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73:231–248, 1990. 294zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • María Alpuente
    • 1
  • Moreno Falaschi
    • 2
  • Ginés Moreno
    • 3
  • Germán Vidal
    • 1
  1. 1.DSIC, UPVValenciaSpain
  2. 2.Dip. Mat. e InformaticaU. UdineUdineItaly
  3. 3.Dep. InformáticaUCLMAlbaceteSpain

Personalised recommendations