Higher-Order and Symbolic Computation

, Volume 21, Issue 1–2, pp 193–234 | Cite as

Totally correct logic program transformations via well-founded annotations

Article

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.

Keywords

Program transformation rules Logic programming Partial and total correctness Well-founded orderings 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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. 2.
    Apt, K.R., Pedreschi, D.: Reasoning about termination of pure logic programs. Inf. Comput. 106, 109–157 (1993) MATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Bezem, M.: Strong termination of logic programs. J. Log. Program. 15, 79–97 (1993) MATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Bossi, A., Etalle, S.: Transforming acyclic programs. ACM Trans. Program. Lang. Syst. 16(4), 1081–1096 (1994) CrossRefGoogle Scholar
  5. 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. 6.
    Bossi, A., Cocco, N., Etalle, S.: Simultaneous replacement in normal programs. J. Log. Comput. 6(1), 79–120 (1996) MATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. J. ACM 24(1), 44–67 (1977) MATHMathSciNetGoogle Scholar
  8. 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. 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. 10.
    Dershowitz, N.: Termination of rewriting. J. Symb. Comput. 3(1–2), 69–116 (1987) MATHCrossRefMathSciNetGoogle Scholar
  11. 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. 12.
    Jaffar, J., Maher, M., Marriott, K., Stuckey, P.: The semantics of constraint logic programming. J. Log. Program. 37, 1–46 (1998) MATHCrossRefMathSciNetGoogle Scholar
  13. 13.
    Kanamori, T., Fujita, H.: Unfold/fold transformation of logic programs with counters. Technical Report 179, ICOT, Tokyo, Japan (1986) Google Scholar
  14. 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. 15.
    Lloyd, J.W.: Foundations of Logic Programming, 2nd edn. Springer, Berlin (1987) MATHGoogle Scholar
  16. 16.
    Maher, M.J.: Correctness of a logic program transformation system. IBM Research Report RC 13496, T.J. Watson Research Center (1987) Google Scholar
  17. 17.
    Manna, Z., Pnueli, A.: Axiomatic approach to total correctness of programs. Acta Inform. 3, 243–263 (1974) MATHCrossRefMathSciNetGoogle Scholar
  18. 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. 19.
    Partsch, H.A.: Specification and Transformation of Programs. Springer, Berlin (1990) MATHGoogle Scholar
  20. 20.
    Pettorossi, A., Proietti, M.: Synthesis and transformation of logic programs using unfold/fold proofs. J. Log. Program. 41(2–3), 197–230 (1999) MATHCrossRefMathSciNetGoogle Scholar
  21. 21.
    Plotkin, G.D.: A structural approach to operational semantics. Technical Report DAIMI FN-19, Computer Science Department, Aarhus University, Aarhus, Denmark (1981) Google Scholar
  22. 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. 23.
    Pugh, W.: A practical algorithm for exact array dependence analysis. Commun. ACM 35(8), 102–114 (1992) CrossRefGoogle Scholar
  24. 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) CrossRefGoogle Scholar
  25. 25.
    Sands, D.: Total correctness by local improvement in the transformation of functional programs. ACM Toplas 18(2), 175–234 (1996) CrossRefGoogle Scholar
  26. 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) CrossRefGoogle Scholar
  27. 27.
    Seki, H.: Unfold/fold transformation of stratified programs. Theor. Comput. Sci. 86, 107–139 (1991) MATHCrossRefMathSciNetGoogle Scholar
  28. 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. 29.
    Tamaki, H., Sato, T.: A generalized correctness proof of the unfold/fold logic program transformation. Technical Report 86-4, Ibaraki University, Japan (1986) Google Scholar

Copyright information

© Springer Science+Business Media, LLC 2008

Authors and Affiliations

  1. 1.DISPUniversity of Roma Tor VergataRomaItaly
  2. 2.IASI-CNRRomaItaly

Personalised recommendations