Replacement can preserve termination

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


We consider the replacement transformation operation, a very general and powerful transformation, and study under which conditions it preserves universal termination besides computed answer substitutions. With this safe replacement we can significantly extend the safe unfold/fold transformation sequence presented in [11]. By exploiting typing information, more useful conditions can be defined and we may deal with some special cases of replacement very common in practice, namely switching two atoms in the body of a clause and the associativity of a predicate. This is a first step in the direction of exploiting a Pre/Post specification on the intended use of the program to be transformed. Such specification can restrict the instances of queries and clauses to be considered and then relax the applicability conditions on the transformation operations.

Keywords and Phrases

program transformations universal termination replacement typing 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    K. R. Apt. Introduction to Logic Programming. In J. van Leeuwen, editor, Handbook of Theoretical Computer Science, volume B: Formal Models and Semantics. Elsevier, Amsterdam and The MIT Press, Cambridge, 1990.Google Scholar
  2. 2.
    K. R. Apt. Declarative programming in Prolog. In D. Miller, editor, Proceedings of the 1993 International Symposium on Logic Programming, pages 12-35. The MIT Press, 1993.Google Scholar
  3. 3.
    K. R. Apt and B. Marchiori. Reasoning about Prolog programs: from modes through types to assertions. Formal Aspects of Computing, 6(6A):743–765, 1994.Google Scholar
  4. 4.
    K. R. Apt and D. Pedreschi. Studies in Pure Prolog: termination. In J.W. Lloyd, editor, Proceedings of the Simposium in Computational Logic, pages 150–176, Berlin, 1990. Springer-Verlag.Google Scholar
  5. 5.
    K. R. Apt and D. Pedreschi. Proving termination of general Prolog programs. In T. Ito and A. Meyer, editors, Proceedings of the International Conference on Theoretical Aspects of Computer Software, Lecture Notes in Computer Science 526, pages 265–289, Berlin, 1991. Springer-Verlag.Google Scholar
  6. 6.
    K. R. Apt and Pellegrini. On the occur-check free Prolog programs. Technical Report TRCS-R9238, CWI, Amsterdam, The Netherlands, 1992.Google Scholar
  7. 7.
    M. Baudinet. Logic Programming Semantics: Techniques and Applications. PhD thesis, Stanford University, Stanford, California, 1989.Google Scholar
  8. 8.
    R.S. Bird. The Promotion and Accumulation Strategies in Transformational Programming. TOPLAS ACM, 6 4):487–504, 1984.CrossRefGoogle Scholar
  9. 9.
    A. Bossi and N. Cocco. Verifying correctness of logic programs. In J. Diaz and F. Orejas, editors, TAPSOFT '89, Barcelona, Spain, March 1989, (Lecture Notes in Computer Science, vol. 352), pages 96–110. Springer-Verlag, 1989.Google Scholar
  10. 10.
    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
  11. 11.
    A. Bossi and N. Cocco. Preserving universal termination through unfold/fold. In G. Levi and M Rodriguez-Artalejo, editors, Proceedings ALP'94, Madrid, Spain, September 1994.Google Scholar
  12. 12.
    A. Bossi, N. Cocco, and S. Etalle. Transforming Normal Programs by Replacement. In A. Pettorossi, editor, Meta Programming in Logic — Proceedings META '92, volume 649 of Lecture Notes in Computer Science, pages 265–279. Springer-Verlag, Berlin, 1992.Google Scholar
  13. 13.
    A. Bossi, N. Cocco, and S. Etalle. Simultaneous Replacement in Normal Programs. Journal of Logic and Computation, 6(1):79–120, 1996.Google Scholar
  14. 14.
    A. Bossi, N. Cocco, and S. Etalle. Transformation of Left Terminating Programs: The Reordering Problem. In M. Proietti, editor, Proceedings LOPSTR'95, volume 1048 of Lecture Notes in Computer Science, pages 33–45. Springer-Verlag, Berlin, 1996.Google Scholar
  15. 15.
    A. Bossi, N. Cocco, and M. Fabris. Norms on terms and their use in proving universal termination of a logic program. Theoretical Computer Science, 124:297–328, 1994.Google Scholar
  16. 16.
    D.R. Brough and C.J. Hogger. Compiling Associativity into Logic Programs. Journal of Logic Programming, 4:345–359, 1987.MathSciNetGoogle Scholar
  17. 17.
    L. Colussi and E. Marchiori. Proving correctness of logic programs using axiomatic semantics. In Proceedings ICLP'91, pages 629–644. MIT Press, 1991.Google Scholar
  18. 18.
    J. Cook and J.P. Gallagher. A transformation system for definite programs based on termination analysis. In G. Levi and M. Rodriguez-Artalejo, editors, LOPSTR'94. Springer-Verlag, 1994.Google Scholar
  19. 19.
    W. Drabent and J. Maluszynski. Inductive assertion method for logic programs. Theoretical Computer Science, 59:133–155, 1988.Google Scholar
  20. 20.
    U. S. Reddy F. Bronsard, T. K. Lakshman. A framework of directionalities for proving termination of logic programs. In K. R. Apt, editor, Proceedings of the Joint International Conference and Symposium on Logic Programming, pages 321–335. The MIT Press, 1992.Google Scholar
  21. 21.
    P.A. Gardner and J.C. Shepherdson. Unfold/fold transformations of logic programs. In J-L Lassez and editor G. Plotkin, editors, Computational Logic: Essays in Honor of Alan Robinson. MIT Press, 1991.Google Scholar
  22. 22.
    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. Institute for New Generation Computer Technology, Tokyo, 1988.Google Scholar
  23. 23.
    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. ACM, 1982.Google Scholar
  24. 24.
    J. W. Lloyd. Foundations of Logic Programming. Springer-Verlag, Berlin, 1987. Second edition.Google Scholar
  25. 25.
    J. W. Lloyd and J. C. Shepherdson. Partial Evaluation in Logic Programming. Journal of Logic Programming, 11:217–242, 1991.Google Scholar
  26. 26.
    M.J. Maher. Correctness of a logic program transformation system. IBM Research Report RC13496, T.J. Watson Research Center, 1987.Google Scholar
  27. 27.
    K. Marriot and H. Sondergaard. Difference-list Transformation for Prolog. New Generation Computing, 11:125–177, 1993.Google Scholar
  28. 28.
    N.Jones and A. Mycroft. Stepwise development of operational and denotational semantics for Prolog. In International Symposium on Logic Programming, Atlantic City, NJ, (U.S.A.), pages 289–298, 1984.Google Scholar
  29. 29.
    A. Pettorossi and M. Proietti. Transformation of Logic Programs: Foundations and Techniques. Journal of Logic Programming, 19(20):261–320, 1994.Google Scholar
  30. 30.
    A. Pettorossi and M. Proietti. Transformation of Logic Programs. In J.A. Robinson editors D.M. Gabbay, C.J. Hogger, editor, Handbook of Logic and Artificial Intelligence. Oxford University Press, 1995.Google Scholar
  31. 31.
    L. Pluemer. Termination proofs for logic programs, volume 446 of Lecture Notes in Artificial Intelligence. Springer-Verlag, Berlin, 1990.Google Scholar
  32. 32.
    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
  33. 33.
    M. Proietti and A. Pettorossi. Unfolding, definition, folding, in this order for avoiding unnesessary variables in logic programs. In Maluszynski and M. Wirsing, editors, PLILP 91, Passau, Germany (Lecture Notes in Computer Science, Vol.528), pages 347–358. Springer-Verlag, 1991.Google Scholar
  34. 34.
    M. Proietti and A. Pettorossi. Synthesis of Programs from Unfold/Fold Proofs. In Y. Deville, editor, LOPSTR'93, pages 141–158, 1994.Google Scholar
  35. 35.
    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
  36. 36.
    H. Seki. Unfold/fold transformation of stratified programs. Journal of Theoretical Computer Science, 86:107–139, 1991.Google Scholar
  37. 37.
    H. Tamaki and T. Sato. Unfold/Fold Transformations of Logic Programs. In StenÅke Tärnlund, editor, Proc. Second Int'l Conf. on Logic Programming, pages 127–139, 1984.Google Scholar
  38. 38.
    K. Verschaetse. Static termination analysis for definite Horn clause programs. PhD thesis, Dept. Computer Science, K. U. Leuven, 1992.Google Scholar
  39. 39.
    K. Verschaetse and D. De Schreye. Deriving termination proofs for logic programs, using abstract procedures. In Proc. Eighth Int'l Conf. on Logic Programming, pages 301–315, 1991.Google Scholar
  40. 40.
    J. Zhang and P. W. Grant. An Automatic Difference-list Transformation Algorithm for Prolog. In Proceedings of the European Conference on Artificial Intelligence,ECAI'88, pages 320–325. Pitman, 1988.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Annalisa Bossi
    • 1
  • Nicoletta Cocco
    • 1
  1. 1.Dip. di Matematica Appl. e InformaticaUniversità di Venezia-Ca' FoscariMestre-VeneziaItaly

Personalised recommendations