A Generalization of Short-Cut Fusion and its Correctness Proof

Short-cut fusion is a program transformation technique that 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. For each algebraic data type we then define a generalization of build which constructs substitution instances of its associated data structures, and use Pitts' techniques to prove the correctness of a contextual equivalence-preserving fusion rule which generalizes short-cut fusion. These rules optimize compositions of functions that uniformly consume algebraic data structures with functions that uniformly produce substitution instances of those data sructures.

[1]  László Németh,et al.  Catamorphism-based program transformations for non-strict functional languages , 2000 .

[2]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[3]  Olaf Chitil,et al.  Typer inference builds a short cut to deforestation , 1999, ICFP '99.

[4]  Claudio V. Russo,et al.  Operational Properties of Lily, a Polymorphic Linear Lambda Calculus with Recursion , 2001, HOOTS.

[5]  Martín Abadi Top-top-closed Relations and Admissibility , 2000, Math. Struct. Comput. Sci..

[6]  Masato Takeichi,et al.  Deriving structural hylomorphisms from recursive definitions , 1996, ICFP '96.

[7]  Andrew John Gill,et al.  Cheap deforestation for non-strict functional languages , 1996 .

[8]  Akihiko Takano,et al.  Shortcut deforestation in calculational form , 1995, FPCA '95.

[9]  Gordon D. Plotkin,et al.  An axiomatisation of computationally adequate domain theoretic models of FPC , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[10]  A. Tarski A LATTICE-THEORETICAL FIXPOINT THEOREM AND ITS APPLICATIONS , 1955 .

[11]  Carolyn L. Talcott,et al.  From Operational Semantics to Domain Theory , 1996, Inf. Comput..

[12]  Glynn Winskel,et al.  Relational Reasoning about Functions and Nondeterminism , 1999 .

[13]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[14]  Andrew M. Pitts Existential Types: Logical Relations and Operational Equivalence , 1998, ICALP.

[15]  Tim Sheard,et al.  A fold for all seasons , 1993, FPCA '93.

[16]  Patricia Johann Short cut fusion is correct , 2003, J. Funct. Program..

[17]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[18]  Andre Scedrov,et al.  Functorial Polymorphism , 1990, Theor. Comput. Sci..

[19]  Jean Goubault-Larrecq,et al.  Sequent combinators: a Hilbert system for the lambda calculus , 2000, Mathematical Structures in Computer Science.

[20]  Eelco Visser,et al.  Warm fusion in Stratego: A case study in generation of program transformation systems , 2004, Annals of Mathematics and Artificial Intelligence.

[21]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[22]  Masato Takeichi,et al.  A calculational fusion system HYLO , 1997, Algorithmic Languages and Calculi.

[23]  Andrew M. Pitts,et al.  Parametric polymorphism and operational equivalence , 2000, Mathematical Structures in Computer Science.

[24]  John Launchbury,et al.  Warm fusion: deriving build-catas from recursive definitions , 1995, FPCA '95.