Unfolding — definition — folding, in this order, for avoiding unnecessary variables in logic programs
We take a syntactically based approach to the automatic improvement of performances of logic programs by using the unfold/fold transformation technique. A cause of program inefficiency is often the presence of variables which are unnecessary, in the sense that they force computations of redundant values or multiple visits of data structures.
We propose a strategy which automatically transforms initial program versions into new efficient versions by avoiding unnecessary variables. Our strategy is an extension of the one which was introduced in an earlier paper [Proietti-Pettorossi 90]. It is based on the syntactical characterization of the unnecessary variables and the introduction of a composite transformation rule made out of unfolding-definition-folding steps, in this order. The strategy consists in the repeated application of this composite rule to each clause with unnecessary variables. It avoids the search for eureka definitions which is often required by other techniques proposed in the literature. We define a class of programs for which our transformation strategy is successful and we propose a variant of that strategy which uses the so-called Generalization Rule. This variant is always terminating, but, in general, not all unnecessary variables are eliminated.
KeywordsLogic Program Transformation Technique Predicate Symbol Elimination Procedure Relevant Portion
Unable to display preview. Download preview PDF.
- [Burstall-Darlington 77]Burstall, R.M. and Darlington, J.: "A Transformation System for Developing Recursive Programs", JACM, Vol. 24, No. 1, January 1977, pp. 44–67.Google Scholar
- [CIP 84]CIP Language Group: "The Munich Project CIP" Lecture Notes in Computer Science, 1984.Google Scholar
- [Debray 88]Debray, S.K.: "Unfold/Fold Transformations and Loop Optimization of Logic Programs", Proc. SIGPLAN 88, Conference on Programming Language Design and Implementation, Altanta, Georgia, 1988.Google Scholar
- [Debray-Warren 89]Debray, S.K. and Warren, D.S.: "Functional Computations in Logic Programs", ACM TOPLAS, 11 (3), 1989, pp. 451–481.Google Scholar
- [Feather 86]Feather, M.S.: "A Survey and Classification of Some Program Transformation Techniques", Proc. TC2 IFIP Working Conference on Program Specification and Transformation, Bad Tölz, Germany, 1986.Google Scholar
- [Hogger 81]Hogger, C.J.: "Derivation of Logic Programs", JACM, No. 28, 2, 1981, pp. 372–392.Google Scholar
- [Kawamura-Kanamori 88]Kawamura, T. and Kanamori, T.: "Preservation of Stronger Equivalence in Unfold/Fold Logic Program Transformation", Proc. Int. Conf. on Fifth Generation Computer Systems, Tokyo, 1988, pp. 413–422.Google Scholar
- [Lloyd 87]Lloyd, J.W.: "Foundations of Logic Programming", Springer-Verlag, Berlin, Heidelberg, New York, Tokyo, 2nd edition, 1987.Google Scholar
- [Paige-Koenig 82]Paige, R. and Koenig, S.: "Finite Differencing of Computable Expressions" ACM TOPLAS 4 (3) July 1982, pp. 402–454.Google Scholar
- [Pettorossi 77]Pettorossi, A.: "Transformation of Programs and Use of Tupling Strategy", Proc. Informatica 77, Bled, Yugoslavia, 1977, pp. 3 103, 1–6.Google Scholar
- [Pettorossi-Proietti 87]Pettorossi, A. and Proietti, M.: "Importing and Exporting Information in Program Development", Proc. IFIP TC2 Workshop on Partial Evaluation and Mixed Computation, Gammel Avernaes, Denmark, North Holland 1987, pp. 405–425.Google Scholar
- [Proietti-Pettorossi 90]Proietti, M. and Pettorossi, A.: "Synthesis of Eureka Predicates for Developing Logic Programs", Proc. ESOP 90, Copenhagen, 1990, Lecture Notes in Computer Science No. 432, pp. 306–325.Google Scholar
- [Tamaki-Sato 84]Tamaki, H. and Sato, T.: "Unfold/Fold Transformation of Logic Programs", Proc. 2nd International Conference on Logic Programming, Uppsala, Sweden, 1984.Google Scholar
- [Wadler 88]Wadler, P. L.: "Deforestation: Transforming Programs to Eliminate Trees", Proc. ESOP 88, Nancy, France, 1988, Lecture Notes in Computer Science 300, pp. 344–358.Google Scholar