Skip to main content

Safe folding/unfolding with conditional narrowing

  • Functional and Logic Programming
  • Conference paper
  • First Online:
Algebraic and Logic Programming (ALP 1997, HOA 1997)

Abstract

Functional logic languages with a complete operational semantics are based on narrowing, a generalization of term rewriting where unification replaces matching. In this paper, we study the semantic properties of a general transformation technique called unfolding in the context of functional logic languages. Unfolding a program is defined as the application of narrowing steps to the calls in the program rules in some appropriate form. We show that, unlike the case of pure logic or pure functional programs, where unfolding is correct w.r.t. practically all available semantics, unrestricted unfolding using narrowing does not preserve program meaning, even when we consider the weakest notion of semantics the program can be given. We single out the conditions which guarantee that an equivalent program w.r.t. the semantics of computed answers is produced. Then, we study the combination of this technique with a folding transformation rule in the case of innermost conditional narrowing, and prove that the resulting transformation still preserves the computed answer semantics of the initial program, under the usual conditions for the completeness of innermost conditional narrowing. We also discuss a relationship between unfold/fold transformations and partial evaluation of functional logic programs.

This work has been partially supported by CICYT under grant TIC 95-0433-C03-03 and by HCM project CONSOLE.

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.

References

  1. M. Alpuente, M. Falaschi, G. Moreno, and G. Vidal. Safe Folding/Unfolding with Conditional Narrowing. Technical Report DSIC-II/3/97, DSIC, UPV, 1997.

    Google Scholar 

  2. M. Alpuente, M. Falaschi, M.J. Ramis, and G. Vidal. A Compositional Semantics for Conditional Term Rewriting Systems. In H.E. Bal, editor, Proc. of 6th Int'l Conf. on Computer Languages, ICCL'94, pages 171–182. IEEE, New York, 1994.

    Google Scholar 

  3. M. Alpuente, M. Falaschi, and G. Vidai. A Compositional Semantic Basis for the Analysis of Equational Horn Programs. Theoretical Computer Science, 165(1):97–131, 1996.

    Google Scholar 

  4. M. Alpuente, M. Falaschi, and G. Vidal. Partial Evaluation of Functional Logic Programs. Technical Report DSIC-II/33/96, DSIC, UPV, 1996. Short version in Proc. of ESOP'96, Springer LNCS 1058, pages 45–61. Also available from URL: http://www.dsic.upv.es/users/elp/papers.html.

    Google Scholar 

  5. P. Bosco, E. Giovannetti, and C. Moiso. Narrowing vs. SLD-resolution. Theoretical Computer Science, 59:3–23, 1988.

    Google Scholar 

  6. A. Bossi and N. Cocco. Basic Transformation Operations which preserve Computed Answer Substitutions of Logic Programs. Journal of Logic Programming, 16:47–87, 1993.

    Google Scholar 

  7. R.M. Burstall and J. Darlington. A Transformation System for Developing Recursive Programs. Journal of the ACM, 24(1):44–67, 1977.

    Google Scholar 

  8. J. Darlington and H. Pull. A Program Development Methodology Based on a Unified Approach to Execution and Transformation. In D. Bjørner, A.P. Ershov, and N.D. Jones, editors, Proc. of the Int'l Workshop on Partial Evaluation and Mixed Computation, pages 117–131. North-Holland, Amsterdam, 1988.

    Google Scholar 

  9. N. Dershowitz. Termination of Rewriting. Journal of Symbolic Computation, 3(1&2):69–115, 1987.

    Google Scholar 

  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.

    Google Scholar 

  11. N. Dershowitz and U. Reddy. Deductive and Inductive Synthesis of Equational Programs. Journal of Symbolic Computation, 15:467–494, 1993.

    Google Scholar 

  12. S. Etalle and M. Gabbrielli. Modular Transformations of CLP Programs. In Proc. of 12th Int'l Conf. on Logic Programming. The MIT Press, 1995.

    Google Scholar 

  13. L. Fribourg. SLOG: a logic programming language interpreter based on clausal superposition and rewriting. In Proc. of Second IEEE Int'l Symp. on Logic Programming, pages 172–185. IEEE, New York, 1985.

    Google Scholar 

  14. M. Hanus. Efficient Implementation of Narrowing and Rewriting. In Proc. Int'l Workshop on Processing Declarative Knowledge, pages 344–365. Springer LNAI 567, 1991.

    Google Scholar 

  15. M. Hanus. The Integration of Functions into Logic Programming: From Theory to Practice. Journal of Logic Programming, 19&20:583–628, 1994.

    Google Scholar 

  16. M. Hanus. On Extra Variables in (Equational) Logic Programming. In Proc. of 20th Int'l Conf. on Logic Programming, pages 665–678. The MIT Press, 1995.

    Google Scholar 

  17. S. Hölldobler. Foundations of Equational Logic Programming. Springer LNAI 353, 1989.

    Google Scholar 

  18. T. Kawamura and T. Kanamori. Preservation of Stronger Equivalence in Unfold/Fold Logic Programming Transformation. In Proc. Int'l Conf. on Fifth Generation Computer Systems, pages 413–422. ICOT, 1988.

    Google Scholar 

  19. J.W. Klop.Term Rewriting Systems. In S. Abramsky, D. Gabbay, and T. Maibaum, editors, Handbook of Logic in Computer Science, volume I, pages 1–112. Oxford University Press, 1992.

    Google Scholar 

  20. L. Kott. Unfold/fold program transformation. In M. Nivat and J.C. Reynolds, editors, Algebraic methods in semantics, chapter 12, pages 411–434. Cambridge University Press, 1985.

    Google Scholar 

  21. M. Leuschel, D. De Schreye, and A. de Waal. A Conceptual Embedding of Folding into Partial Deduction: Towards a Maximal Integration. In M. Maher, editor, Proc. of the Joint International Conference and Symposium on Logic Programming JICSLP'96, pages 319–332. The MIT Press, Cambridge, MA, 1996.

    Google Scholar 

  22. J.W. Lloyd and J.C. Shepherdson. Partial Evaluation in Logic Programming. Journal of Logic Programming, 11:217–242, 1991.

    Google Scholar 

  23. A. Middeldorp and E. Hamoen. Completeness Results for Basic Narrowing. Applicable Algebra in Engineering, Communication and Computing, 5:213–253, 1994.

    Google Scholar 

  24. A. Middeldorp, S. Okui, and T. Ida. Lazy Narrowing: Strong Completeness and Eager Variable Elimination. Theoretical Computer Science, 167(1,2):95–130, 1996.

    Google Scholar 

  25. A. Pettorossi and M. Proietti. Transformation of Logic Programs: Foundations and Techniques. Journal of Logic Programming, 19,20:261–320, 1994.

    Google Scholar 

  26. U.S. Reddy. Narrowing as the Operational Semantics of Functional Languages. In Proc. of 2nd Int'l Symp. on Logic Programming, pages 138–151. IEEE, 1985.

    Google Scholar 

  27. H. Seki. Unfold/fold Transformation of General Logic Programs for the Well-Founded Semantics. Journal of Logic Programming, 16(1&2):5–23, 1993.

    Google Scholar 

  28. H. Tamaki and T. Sato. Unfold/Fold Transformations of Logic Programs. In Proc. of 2nd Int'l Conf. on Logic Programming, pages 127–139, 1984.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Michael Hanus Jan Heering Karl Meinke

Rights and permissions

Reprints and permissions

Copyright information

© 1997 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Alpuente, M., Falaschi, M., Moreno, G., Vidal, G. (1997). Safe folding/unfolding with conditional narrowing. In: Hanus, M., Heering, J., Meinke, K. (eds) Algebraic and Logic Programming. ALP HOA 1997 1997. Lecture Notes in Computer Science, vol 1298. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0026999

Download citation

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

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-63459-1

  • Online ISBN: 978-3-540-69555-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics