Skip to main content
Log in

A Generalization of Short-Cut Fusion and its Correctness Proof

  • Published:
Higher-Order and Symbolic Computation

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Abadi, M. TT-closed relations and admissibility. Mathematical Structures in Computer Science, 10 (2000) 313–320.

    Google Scholar 

  2. Bainbridge, E.S., Freyd, P.J., Scedrov, A., and Scott, P.J. Functorial polymorphism. Theoretical Computer Science, 70(1) (1990) 35–64. Corrigendum in 71(3) (1990) 431.

    Google Scholar 

  3. Bierman, G.M., Pitts, A.M., and Russo C.V. Operational semantics of Lily, a polymorphic linear lambda calculus with recursion. Electronic Notes in Theoretical Computer Science, 41(3) (2000).

  4. Chitil, O. Type inference builds a short cut to deforestation. In Proceedings, International Conference on Functional Programming, 1999, pp. 249–260.

  5. Fiore, M. and Plotkin, G. An axiomatization of computationally adequate domain theoretic models of FPC. In Proceedings, 9th Annual Symposium on Logic in Computer Science, 1994, pp. 92–102.

  6. Gill, A. Cheap Deforestation for Non-strict Functional Languages. PhD Thesis, Glasgow University, 1996.

  7. Gill, A., Launchbury, J., and Peyton Jones, S.L. A short cut to deforestation. In Proceedings, Conference on Functional Languages and Computer Architecture, 1993, pp. 223–232.

  8. Hu, Z., Iwasaki, H., and Takeichi, M. Deriving structural hylomorphisms from recursive definitions. In Proceedings, International Conference on Functional Programming, 1996, pp. 73–82.

  9. Johann, P. An implementation of warm fusion. Available at ftp://ftp.cse.ogi.edu/pub/pacsoft/ wf/, 1997.

  10. Johann, P. Short cut fusion is correct. Journal of Functional Programming. To appear.

  11. Johann, P. and Visser, E. Warm fusion in Stratego: A case study in generation of program transformation systems. Annals of Mathematics and Artificial Intelligence, 29(1–4) (2000) 1–34.

    Google Scholar 

  12. Lassen, S.B. Relational Reasoning about Functions and Nondeterminism. PhD Thesis, University of Aarhus, 1998.

  13. Launchbury, J. and Sheard, T. Warm fusion: Deriving build-catas from recursive definitions. In Proceedings, Conference on Functional Programming and Computer Architecture, 1995, pp. 314–323.

  14. Mason, I.A., Smith, S.F., and Talcott, C.L. From operational semantics to domain theory. Information and Computation, 128(1) (1996) 26–47.

    Google Scholar 

  15. Németh, L. Catamorphism Based Program Transformations for Non-Strict Functional Languages. PhD Thesis, Glasgow University, 2000.

  16. 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, 1997, pp. 76–106.

  17. Pitts, A. Existential types: Logical relations and operational equivalence. In Proceedings, International Colloquium on Automata, Languages, and Programming, LNCS, Vol. 1443, 1998, pp. 309–326.

    Google Scholar 

  18. Pitts, A. Parametric polymorphism, recursive types, and operational equivalence. Unpublished Manuscript (1998).

  19. Pitts, A. Parametric polymorphism and operational equivalence. Mathematical Structures in Computer Science, 10 (2000) 1–39.

    Google Scholar 

  20. Reynolds, J.C. Toward a theory of type structure. Paris Colloquium on Programming, LNCS, Vol. 19, 1974, pp. 408–425.

    Google Scholar 

  21. Reynolds, J.C. Types, abstraction, and parametric polymorphism. Information Processing, 83 (1983) 513–523.

    Google Scholar 

  22. Sheard, T. and Fegaras, L. A fold for all seasons. In Proceedings, Conference on Functional Programming and Computer Architecture, 1993, pp. 233–242.

  23. Takano, A. and Meijer, E. Shortcut deforestation in calculational form. In Proceedings, Conference on Functional Programming and Computer Architecture, 1995, pp. 324–333.

  24. Tarski, A. A lattice-theoretical fixpoint theorem and its applications. Pacific Journal of Mathematics, 5 (1955) 285–309.

    Google Scholar 

  25. Wadler, P. Theorems for free! In Proceedings, Conference on Functional Programming and Computer Architecture, 1989, pp. 347–359.

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Johann, P. A Generalization of Short-Cut Fusion and its Correctness Proof. Higher-Order and Symbolic Computation 15, 273–300 (2002). https://doi.org/10.1023/A:1022982420888

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1022982420888

Navigation