Skip to main content

Short Cut Fusion: Proved and Improved

  • Conference paper
  • First Online:
Semantics, Applications, and Implementation of Program Generation (SAIG 2001)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2196))

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.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

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

    Google Scholar 

  2. 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.

    Article  MATH  MathSciNet  Google Scholar 

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

    Google Scholar 

  4. Gill, A. Cheap Deforetation for Non-strict Functional Languages. PhD thesis, Glasgow University, 1996.

    Google Scholar 

  5. 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.

    Google Scholar 

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

    Google Scholar 

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

  8. 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.

    Google Scholar 

  9. Németh, L. Catamorphism Based Program Transformations for Non-strict Functional Languages. Draft, PhD thesis, Glasgow University, 2000.

    Google Scholar 

  10. 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.

    Google Scholar 

  11. Plotkin, G. Call-by-name, call-by-value, and the lambda calculus. Theoretical Computer Science 1, pp. 125–159, 1975.

    Google Scholar 

  12. 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.

    Chapter  Google Scholar 

  13. Pitts, A. Parametric Polymorphism, Recursive Types, and Operational Equivalence. Unpublished Manuscript.

    Google Scholar 

  14. Pitts, A. Parametric Polymorphism and Operational Equivalence. Mathematical Structures in Computer Science 10, pp. 1–39, 2000.

    Google Scholar 

  15. Takano, A. and Meijer, E. Short cut deforetation in calculational form. In Proceedings, Conference on Functional Programming and Computer Architecture, pp. 324–333, 1995.

    Google Scholar 

  16. Reynolds, J. C. Types, abstraction, and parametric polymorphism. Information Processing 83, pp. 513–523, 1983.

    Google Scholar 

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

    Google Scholar 

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

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics