Total correctness by local improvement in the transformation of functional programs
- 1 March 1996
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Programming Languages and Systems
- Vol. 18 (2) , 175-234
- https://doi.org/10.1145/227699.227716
Abstract
The goal of program transformation is to improve efficiency while preserving meaning. One of the best-known transformation techniques is Burstall and Darlington's unfold-fold method. Unfortunately the unfold-fold method itself guarantees neither improvement in efficiency nor total correctness. The correctness problem for unfold-fold is an instance of a strictly more general problem: transformation by locally equivalence-preserving steps does not necessarily preserve (global) equivalence. This article presents a condition for the total correctness of transformations on recursive programs, which, for the first time, deals with higher-order functional languages (both strict and nonstrict) including lazy data structures. The main technical result is an improvement theorem which says that if the local transformation steps are guided by certain optimization concerns (a fairly natural condition for a transformation), then correctness of the transformation follows. The improvement theorem makes essential use of a formalized improvement theory; as a rather pleasing corollary it also guarantees that the transformed program is a formal improvement over the original. The theorem has immediate practical consequences: it is a powerful tool for proving the correctness of existing transformation methods for higher-order functional programs, without having to ignore crucial factors such as memoization or folding , and it yields a simple syntactic method for guiding and constraining the unfold-fold method in the general case so that total correctness (and improvement) is always guaranteed.Keywords
This publication has 27 references indexed in Scilit:
- How powerful are folding/unfolding transformations?Journal of Functional Programming, 1994
- Specifying the correctness of binding-time analysisJournal of Functional Programming, 1993
- Correctness of binding-time analysisJournal of Functional Programming, 1993
- Unfold⧸fold transformation of general logic programs for the well-founded semanticsThe Journal of Logic Programming, 1993
- A self-applicable partial evaluator for the lambda calculusACM Transactions on Programming Languages and Systems, 1992
- Semantics preserving transformation rules for PrologACM SIGPLAN Notices, 1991
- Deforestation: transforming programs to eliminate treesTheoretical Computer Science, 1990
- The concept of a supercompilerACM Transactions on Programming Languages and Systems, 1986
- Program Transformation SystemsACM Computing Surveys, 1983
- A Transformation System for Developing Recursive ProgramsJournal of the ACM, 1977