Skip to main content
Log in

Totally correct logic program transformations via well-founded annotations

  • Published:
Higher-Order and Symbolic Computation

An Erratum to this article was published on 23 May 2008

An Erratum to this article was published on 23 May 2008

Abstract

We address the problem of proving the total correctness of transformations of definite logic programs. We consider a general transformation rule, called clause replacement, which consists in transforming a program P into a new program Q by replacing a set Γ 1 of clauses occurring in P by a new set Γ 2 of clauses, provided that Γ 1 and Γ 2 are equivalent in the least Herbrand model M(P) of the program P.

We propose a general method for proving that transformations based on clause replacement are totally correct, that is, M(P)=M(Q). Our method consists in showing that the transformation of P into Q can be performed by: (i) adding extra arguments to predicates, thereby deriving from the given program P an annotated program \(\overline{P}\) , (ii) applying a variant of the clause replacement rule and transforming the annotated program \(\overline{P}\) into a terminating annotated program \(\overline{Q}\) , and (iii) erasing the annotations from \(\overline{Q}\) , thereby getting Q.

Our method does not require that either P or Q are terminating and it is parametric with respect to the annotations. By providing different annotations we can easily prove the total correctness of program transformations based on various versions of the popular unfolding, folding, and goal replacement rules, which can all be viewed as particular cases of our clause replacement rule.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Apt, K.R.: Introduction to logic programming. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, pp. 493–576. Elsevier, Amsterdam (1990)

    Google Scholar 

  2. Apt, K.R., Pedreschi, D.: Reasoning about termination of pure logic programs. Inf. Comput. 106, 109–157 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  3. Bezem, M.: Strong termination of logic programs. J. Log. Program. 15, 79–97 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  4. Bossi, A., Etalle, S.: Transforming acyclic programs. ACM Trans. Program. Lang. Syst. 16(4), 1081–1096 (1994)

    Article  Google Scholar 

  5. Bossi, A., Cocco, N., Etalle, S.: On safe folding. In: Proceedings PLILP ’92, Leuven, Belgium. Lecture Notes in Computer Science, vol. 631, pp. 172–186. Springer, Berlin (1992)

    Google Scholar 

  6. Bossi, A., Cocco, N., Etalle, S.: Simultaneous replacement in normal programs. J. Log. Comput. 6(1), 79–120 (1996)

    Article  MATH  MathSciNet  Google Scholar 

  7. Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. J. ACM 24(1), 44–67 (1977)

    MATH  MathSciNet  Google Scholar 

  8. Cook, J., Gallagher, J.P.: A transformation system for definite programs based on termination analysis. In: Fribourg, L., Turini, F. (eds.) Proceedings of LoPSTr’94 and META’94, Pisa, Italy. Lecture Notes in Computer Science, vol. 883, pp. 51–68. Springer, Berlin (1994)

    Google Scholar 

  9. Courcelle, B.: Recursive applicative program schemes. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, vol. B, pp. 459–492. Elsevier, Amsterdam (1990)

    Google Scholar 

  10. Dershowitz, N.: Termination of rewriting. J. Symb. Comput. 3(1–2), 69–116 (1987)

    Article  MATH  MathSciNet  Google Scholar 

  11. Gergatsoulis, M., Katzouraki, M.: Unfold/fold transformations for definite clause programs. In: Hermenegildo, M., Penjam, J. (eds.) Proceedings Sixth International Symposium on Programming Language Implementation and Logic Programming (PLILP ’94). Lecture Notes in Computer Science, vol. 844, pp. 340–354. Springer, Berlin (1994)

    Google Scholar 

  12. Jaffar, J., Maher, M., Marriott, K., Stuckey, P.: The semantics of constraint logic programming. J. Log. Program. 37, 1–46 (1998)

    Article  MATH  MathSciNet  Google Scholar 

  13. Kanamori, T., Fujita, H.: Unfold/fold transformation of logic programs with counters. Technical Report 179, ICOT, Tokyo, Japan (1986)

  14. Lau, K.-K., Ornaghi, M., Pettorossi, A., Proietti, M.: Correctness of logic program transformation based on existential termination. In: Lloyd, J.W. (ed.) Proceedings of the 1995 International Logic Programming Symposium (ILPS ’95), pp. 480–494. MIT Press, Cambridge (1995)

    Google Scholar 

  15. Lloyd, J.W.: Foundations of Logic Programming, 2nd edn. Springer, Berlin (1987)

    MATH  Google Scholar 

  16. Maher, M.J.: Correctness of a logic program transformation system. IBM Research Report RC 13496, T.J. Watson Research Center (1987)

  17. Manna, Z., Pnueli, A.: Axiomatic approach to total correctness of programs. Acta Inform. 3, 243–263 (1974)

    Article  MATH  MathSciNet  Google Scholar 

  18. McCarthy, J.: Towards a mathematical science of computation. In: Popplewell, C.M. (ed.) Information Processing: Proceedings of IFIP 1962, pp. 21–28. North Holland, Amsterdam (1963)

    Google Scholar 

  19. Partsch, H.A.: Specification and Transformation of Programs. Springer, Berlin (1990)

    MATH  Google Scholar 

  20. Pettorossi, A., Proietti, M.: Synthesis and transformation of logic programs using unfold/fold proofs. J. Log. Program. 41(2–3), 197–230 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  21. Plotkin, G.D.: A structural approach to operational semantics. Technical Report DAIMI FN-19, Computer Science Department, Aarhus University, Aarhus, Denmark (1981)

  22. Proietti, M., Pettorossi, A.: Transforming inductive definitions. In: De Schreye, D. (ed.) Proceedings of the 1999 International Conference on Logic Programming, pp. 486–499. MIT Press, Cambridge (1999)

    Google Scholar 

  23. Pugh, W.: A practical algorithm for exact array dependence analysis. Commun. ACM 35(8), 102–114 (1992)

    Article  Google Scholar 

  24. Roychoudhury, A., Narayan Kumar, K., Ramakrishnan, C.R., Ramakrishnan, I.V.: An unfold/fold transformation framework for definite logic programs. ACM Trans. Program. Lang. Syst. 26, 264–509 (2004)

    Article  Google Scholar 

  25. Sands, D.: Total correctness by local improvement in the transformation of functional programs. ACM Toplas 18(2), 175–234 (1996)

    Article  Google Scholar 

  26. Sands, D.: From SOS rules to proof principles: An operational metatheory for functional languages. In: Proceedings of the 24th ACM Symposium on Principles of Programming Languages (POPL’97), pp. 428–441. ACM Press, New York (1997)

    Chapter  Google Scholar 

  27. Seki, H.: Unfold/fold transformation of stratified programs. Theor. Comput. Sci. 86, 107–139 (1991)

    Article  MATH  MathSciNet  Google Scholar 

  28. Tamaki, H., Sato, T.: Unfold/fold transformation of logic programs. In: Proceedings of the Second International Conference on Logic Programming, pp. 127–138. Uppsala University, Uppsala, Sweden (1984)

    Google Scholar 

  29. Tamaki, H., Sato, T.: A generalized correctness proof of the unfold/fold logic program transformation. Technical Report 86-4, Ibaraki University, Japan (1986)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Alberto Pettorossi.

Additional information

A preliminary version of this paper appears as: A Theory of Totally Correct Logic Program Transformations. In: Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, August 24–25, 2004, Verona, Italy, ACM Press, 2004, pp. 159–168.

An erratum to this article can be found at http://dx.doi.org/10.1007/s10990-008-9031-7

Rights and permissions

Reprints and permissions

About this article

Cite this article

Pettorossi, A., Proietti, M. Totally correct logic program transformations via well-founded annotations. Higher-Order Symb Comput 21, 193–234 (2008). https://doi.org/10.1007/s10990-008-9024-6

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10990-008-9024-6

Keywords

Navigation