On safe folding

  • Annalisa Bossi
  • Nicoletta Cocco
  • Sandro Etalle
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 631)


In [3] a general fold operation has been introduced for definite programs wrt computed answer substitution semantics. It differs from the fold operation defined by Tamaki and Sato in [26,25] because its application does not depend on the transformation history. This paper extends the results in [3] by giving a more powerful sufficient condition for the preservation of computed answer substitutions. Such a condition is meant to deal with the critical case when the atom introduced by folding depends on the clause to which the fold applies. The condition compares the ”dependency degree” between the fonding atom and the folded clause, with the ”semantic delay” between the folding atom and the ones to be folded. The result is also extended to a more general replacement operation, by showing that it can be decomposed into a sequence of definition, general folding and unfolding operations.


Program transformation folding computed answer substitution semantics 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    K. Apt. Introduction to logic programming. In Handbook of Theoretical Computer Science, pages 493–574. Elsevier Science Publishers B.V., 1990.Google Scholar
  2. 2.
    D. BjØrner, A. Ershov, and N. Jones, editors. Partial Evaluation and Mixed Computation. Proceedings of the IFIP TC2 Workshop, Gammel AvernÆs, Denmark, October 1987. North-Holland, 1988. 625 pages.Google Scholar
  3. 3.
    A. Bossi and N. Cocco. Basic transformation operations for logic programs which preserve computed answer substitutions. Technical Report 16, Dip. Matematica Pura e Applicata, Università di Padova, Italy, April 1990. to appear in Special Issue on Partial Deduction of the Journal of Logic Programming.Google Scholar
  4. 4.
    A. Bossi, N. Cocco, and S. Dulli. A method for specializing logic programs. ACM Transactions on Programming Languages and Systems, 12(2):253–302, April 1990.Google Scholar
  5. 5.
    A. Bossi, N. Cocco, and S. Etalle. Transforming normal program by replacement. In Third Workshop on Metaprogramming in Logic, META92: Uppsala, Sweden, June 1992.Google Scholar
  6. 6.
    R. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of the ACM, 24(1):44–67, January 1977.Google Scholar
  7. 7.
    Y. Deville. Logic Programming. Systematic Program Development. Addison-Wesley, 1990.Google Scholar
  8. 8.
    S. Etalle. Transformazione dei programmi logici con negazione, Tesi di Laurea, Dip. Matematica Pura e Applicata, Università di Padova, Padova, Italy, July 1991.Google Scholar
  9. 9.
    M. Falaschi, G. Levi, M. Martelli, and C. Palamidessi. Declarative modelling of the operational behavior of logic languages. Theoretical Computer Science, 69(3):289–318, 1989.Google Scholar
  10. 10.
    M. Falaschi, G. Levi, M. Martelli, and C. Palamidessi. A model-theoretic reconstruction of the operational semantics of logic programs. Technical Report 32/89, Dipartimento di Informatica, Universitá di Pisa, Italy, September 1989. to appear in Information and Computation.Google Scholar
  11. 11.
    J. Gallagher. Transforming logic programs by specialising interpreters. In ECAI-86. 7th European Conference on Artificial Intelligence, Brighton Centre, United Kingdom, pages 109–122, 1986.Google Scholar
  12. 12.
    P. Gardner and J. Shepherdson. Unfold/fold transformations of logic programs. In J.-L. Lassez and e. G. Plotkin, editors, Computational Logic: Essays in Honor of Alan Robinson. 1991.Google Scholar
  13. 13.
    C. Hogger. Derivation of logic programs. Journal of the ACM, 28(2):372–392, April 1981.Google Scholar
  14. 14.
    T. Kawamura and T. Kanamori. Preservation of stronger equivalence in unfold/fold logic program transformation. In International Conference on Fifth Generation Computer Systems, Tokyo, Japan, November 1988, pages 413–421. ICOT, 1988.Google Scholar
  15. 15.
    H. Komorowski. Partial evaluation as a means for inferencing data structures in an applicative language: A theory and implementation in the case of Prolog. In Ninth ACM Symposium on Principles of Programming Languages, Albuquerque, New Mexico, pages 255–267, 1982.Google Scholar
  16. 16.
    G. Levi and P. Mancarella. The unfolding semantics of logic programs. Technical Report 13/88, Dipartimento di Informatica, Universitá di Pisa, Italy, September 1988.Google Scholar
  17. 17.
    J. Lloyd. Foundations of Logic Programming. Springer-Verlag, 1987.Google Scholar
  18. 18.
    J. Lloyd and J. Shepherdson. Partial evaluation in logic programming. Technical Report CS-87-09, Department of Computer Science, University of Bristol, England, 1987. to appear in Journal of Logic Programming.Google Scholar
  19. 19.
    M. Maher. Correctness of a logic program transformation system. IBM Research Report RC13496, T.J. Watson Research Center, 1987.Google Scholar
  20. 20.
    M. Maher. A transformation system for deductive databases with perfect model semantics. Theoretical Computer Science, to appear.Google Scholar
  21. 21.
    M. Proietti and A. Pettorossi. The synthesis of eureka predicates for developing logic programs. In N. Jones, editor, ESOP'90, (Lecture Notes in Computer Science, Vol. 432), pages 306–325. Springer-Verlag, 1990.Google Scholar
  22. 22.
    T. Sato. An equivalence preserving first order unfold/fold transformation system. In Second Int. Conference on Algebraic and Logic Programming, Nancy, France, October 1990, (Lecture Notes in Computer Science, Vol. 463), pages 175–188. Springer-Verlag, 1990.Google Scholar
  23. 23.
    H. Seki. A comparative study of the well-founded and stable model semantics: Transformation's viewpoint. In D. P. W. Marek, A. Nerode and V. Subrahmanian, editors, Workshop on Logic Programming and Non-Monotonic Logic, Austin, Texas, October 1990, pages 115–123, 1990.Google Scholar
  24. 24.
    H. Seki. Unfold/fold transformation of stratified programs. Journal of Theoretical Computer Science, 86:107–139, 1991.Google Scholar
  25. 25.
    H. Tamaki and T. Sato. A transformation system for logic programs which preserves equivalence. Technical Report ICOT TR-018, ICOT, Tokyo, Japan, August 1983.Google Scholar
  26. 26.
    H. Tamaki and T. Sato. Unfold/fold transformation ol logic programs. In S. Tarnlund, editor, 2nd International Logic Programming Conference, Uppsala, Sweden, July 1984, pages 127–138, 1984.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  • Annalisa Bossi
    • 1
  • Nicoletta Cocco
    • 1
  • Sandro Etalle
    • 1
  1. 1.Dipartimento di Matematica Pura ed ApplicataUniversità di PadovaPadovaItaly

Personalised recommendations