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.
Similar content being viewed by others
References
Apt, K.R.: Introduction to logic programming. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, pp. 493–576. Elsevier, Amsterdam (1990)
Apt, K.R., Pedreschi, D.: Reasoning about termination of pure logic programs. Inf. Comput. 106, 109–157 (1993)
Bezem, M.: Strong termination of logic programs. J. Log. Program. 15, 79–97 (1993)
Bossi, A., Etalle, S.: Transforming acyclic programs. ACM Trans. Program. Lang. Syst. 16(4), 1081–1096 (1994)
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)
Bossi, A., Cocco, N., Etalle, S.: Simultaneous replacement in normal programs. J. Log. Comput. 6(1), 79–120 (1996)
Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. J. ACM 24(1), 44–67 (1977)
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)
Courcelle, B.: Recursive applicative program schemes. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, vol. B, pp. 459–492. Elsevier, Amsterdam (1990)
Dershowitz, N.: Termination of rewriting. J. Symb. Comput. 3(1–2), 69–116 (1987)
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)
Jaffar, J., Maher, M., Marriott, K., Stuckey, P.: The semantics of constraint logic programming. J. Log. Program. 37, 1–46 (1998)
Kanamori, T., Fujita, H.: Unfold/fold transformation of logic programs with counters. Technical Report 179, ICOT, Tokyo, Japan (1986)
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)
Lloyd, J.W.: Foundations of Logic Programming, 2nd edn. Springer, Berlin (1987)
Maher, M.J.: Correctness of a logic program transformation system. IBM Research Report RC 13496, T.J. Watson Research Center (1987)
Manna, Z., Pnueli, A.: Axiomatic approach to total correctness of programs. Acta Inform. 3, 243–263 (1974)
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)
Partsch, H.A.: Specification and Transformation of Programs. Springer, Berlin (1990)
Pettorossi, A., Proietti, M.: Synthesis and transformation of logic programs using unfold/fold proofs. J. Log. Program. 41(2–3), 197–230 (1999)
Plotkin, G.D.: A structural approach to operational semantics. Technical Report DAIMI FN-19, Computer Science Department, Aarhus University, Aarhus, Denmark (1981)
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)
Pugh, W.: A practical algorithm for exact array dependence analysis. Commun. ACM 35(8), 102–114 (1992)
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)
Sands, D.: Total correctness by local improvement in the transformation of functional programs. ACM Toplas 18(2), 175–234 (1996)
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)
Seki, H.: Unfold/fold transformation of stratified programs. Theor. Comput. Sci. 86, 107–139 (1991)
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)
Tamaki, H., Sato, T.: A generalized correctness proof of the unfold/fold logic program transformation. Technical Report 86-4, Ibaraki University, Japan (1986)
Author information
Authors and Affiliations
Corresponding author
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
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
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10990-008-9024-6