Abstract
Short cut fusion is a particular program transformation technique which uses a single, local transformation—called the foldr-build rule — to remove certain intermediate lists from modularly constructed functional programs. Arguments that short cut fusion is correct typically appeal either to intuition or to “free theorems” — even though the latter have not been known to hold for the languages supporting higher-order polymorphic functions and fixed point recursion in which short cut fusion is usually applied. In this paper we use Pitts’ recent demonstration that contextual equivalence in such languages is relationally parametric to prove that programs in them which have undergone short cut fusion are contextually equivalent to their unfused counterparts. The same techniques in fact yield a much more general result. For each algebraic data type we define a generalization augment of build which constructs substitution instances of its associated data structures. Together with the well-known generalization cata of foldr to arbitrary algebraic data types, this allows us to formulate and prove correct for each a contextual equivalence-preserving cata-augment fusion rule. These rules optimize compositions of functions that uniformly consume algebraic data structures with functions that uniformly produce substitution instances of them.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Abadi, M. ⊤⊤-closed relations and admissibility. Mathematical Structures in Computer Science 10, pp. 313–320, 2000.
Bainbridge, E., Freyd, P., Scedrov, A., and Scott, P.J. Functorial polymorphism. Theoretical Computer Science 70, pp. 35–64, 1990. Corrigendum in Theoretical Computer Science 71, p. 431, 1990.
Chitil, O. Type inference builds a short cut to deforestation. In Proceedings, International Conference on Functional Programming, pp. 249–260, 1999.
Gill, A. Cheap Deforetation for Non-strict Functional Languages. PhD thesis, Glasgow University, 1996.
Gill, A., Launchbury, J., and Peyton Jones, S. L. A short cut to deforestation. In Proceedings, Conference on Functional Languages and Computer Architecture, pp. 223–232, 1993.
Hu, Z., Iwasaki, H., and Takeichi, M. Deriving structural hylomorphisms from recursive definitions. in Proceedings, International Conference in Functional Programming, pp. 73–82, 1996.
Johann, P. An implementation of warm fusion. Available at ftp://ftp.cse.ogi.edu/pub/pacsoft/wf/, 1997.
Johann, P. and Visser, E. Warm fusion in Stratego: A case study in generation of program transformation systems. Annals of Mathematics and Artifical Intelligence 29 (1-4), pp. 1–34, 2000.
Németh, L. Catamorphism Based Program Transformations for Non-strict Functional Languages. Draft, PhD thesis, Glasgow University, 2000.
Onoue, Y., Hu, Z., Iwasaki, H., and Takeichi, M. A calculational system HYLO. In Proceedings, IFIP TC 2 Working Conference on Algorithmic Languages and Calculi, pp. 76–106, 1997.
Plotkin, G. Call-by-name, call-by-value, and the lambda calculus. Theoretical Computer Science 1, pp. 125–159, 1975.
Pitts, A. Existential types: Logical relations and operational equivalence. In Proceedings, International Colloquium on Automata, Languages, and Programming, LNCS vol. 1443, pp. 309–326, 1998.
Pitts, A. Parametric Polymorphism, Recursive Types, and Operational Equivalence. Unpublished Manuscript.
Pitts, A. Parametric Polymorphism and Operational Equivalence. Mathematical Structures in Computer Science 10, pp. 1–39, 2000.
Takano, A. and Meijer, E. Short cut deforetation in calculational form. In Proceedings, Conference on Functional Programming and Computer Architecture, pp. 324–333, 1995.
Reynolds, J. C. Types, abstraction, and parametric polymorphism. Information Processing 83, pp. 513–523, 1983.
Sheard, T. and Fegaras, L. A fold for all seasons. In Proceedings, Conference on Functional Programming and Computer Architecture, pp. 233–242, 1993.
Wadler, P. Theorems for Free! In Proceedings, Conference on Functional Programming and Computer Architecture, pp. 347–359, 1989.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Johann, P. (2001). Short Cut Fusion: Proved and Improved. In: Taha, W. (eds) Semantics, Applications, and Implementation of Program Generation. SAIG 2001. Lecture Notes in Computer Science, vol 2196. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44806-3_4
Download citation
DOI: https://doi.org/10.1007/3-540-44806-3_4
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42558-8
Online ISBN: 978-3-540-44806-8
eBook Packages: Springer Book Archive