Hostname: page-component-78c5997874-mlc7c Total loading time: 0 Render date: 2024-11-16T04:59:14.309Z Has data issue: false hasContentIssue false

Algebraic fusion of functions with an accumulating parameter and its improvement

Published online by Cambridge University Press:  08 September 2008

SHIN-YA KATSUMATA
Affiliation:
Research Institute for Mathematical Sciences, Kyoto University, Kyoto 606-8502, Japan (e-mail: sinya@kurims.kyoto-u.ac.jp)
SUSUMU NISHIMURA
Affiliation:
Department of Mathematics, Faculty of Science, Kyoto University, Kyoto 606-8502, Japan (e-mail: susumu@math.kyoto-u.ac.jp)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

This paper develops a new framework for fusion that is designed for eliminating the intermediate data structures involved in the composition of functions that have one accumulating parameter. The new fusion framework comprises two steps: algebraic fusion and its subsequent improvement process. The key idea in our development is to regard functions with an accumulating parameter as functions that operate over the monoid of data contexts. Algebraic fusion composes each such function with a monoid homomorphism that is derived from the definition of the consumer function to obtain a higher-order function that computes over the monoid of endofunctions. The transformation result may be further refined by an improvement process, which replaces the operation over the monoid of endofunctions (i.e., function closures) with another monoid operation over a monoid structure other than function closures.

Using our framework, one can formulate a particular solution to the fusion problem by devising appropriate monoids and monoid homomorphisms. This provides a unified exposition of a variety of fusion methods that have been developed so far in different formalisms. Furthermore, the cleaner formulation makes it possible to argue about some delicate issues on a firm mathematical basis. We demonstrate that algebraic fusion and improvement in the world of complete pointed partial orders (CPOs) and continuous functions can correctly fuse functions that operate on partial and infinite data structures. We also show that subtle differences in termination behaviours of transformed programmes caused by certain different fusion methods can be cleanly explained by corresponding improvement processes that have different underlying monoid structures.

Type
Articles
Copyright
Copyright © Cambridge University Press 2008

References

Abramsky, S. (1996) Retracting some paths in process algebra. In Proceeding of CONCUR '96, Concurrency Theory, 7th International Conference. Lecture Notes in Computer Science, vol. 1119. Berlin/Heidelberg, Springer Verlag, pp. 117.Google Scholar
Burstall, R. M. & Darlington, J. (1977) A transformation system for developing recursive programs. J. ACM, 24 (1), 4467.CrossRefGoogle Scholar
Chin, W.-N. (1994) Safe fusion of functional expressions II: Further improvements. J. Functional Programming, 4 (4), 515555.CrossRefGoogle Scholar
Engelfriet, J. & Vogler, H. (1985) Macro tree transducers. J. Computer System Sciences, 31, 71146.CrossRefGoogle Scholar
Fülöp, Z. & Vogler, H. (1998) Syntax-Directed Semantics: Formal Models Based on Tree Transducers. Monographs in Theoretical Computer Science. New York, Springer Verlag.CrossRefGoogle Scholar
Ganzinger, H. & Giegerich, R. 1984 (June) Attribute coupled grammars. In Proceedings of the ACM SIGPLAN '84 Symposium on Compiler Construction. SIGPLAN Notices, vol. 19 (6), pp. 157170.Google Scholar
Ghani, N., Johann, P., Uustalu, T., & Vene, V. (2005) Monadic augment and generalised short cut fusion. In Preceeding of International Conference on Functional Programming (ICFP '05), Pittsburgh: ACM, pp. 294305.Google Scholar
Ghani, N., Uustalu, T., & Vene, V. (2006) Generalizing the augment combinator. In Proceedings of Trends in Functional Programming 5, Bristol/Portland: Intellect, pp. 6578.Google Scholar
Giegerich, R. (1988) Composition and evaluation of attribute coupled grammars. Acta Informatica, 25 (4), 355423.CrossRefGoogle Scholar
Gill, A. (1996) Cheap Deforestation for Non-Strict Functional Languages. Ph.D. thesis, Glasgow, UK: University of Glasgow.Google Scholar
Gill, A., Launchbury, J., & Peyton Jones, S. (1993) A short cut to deforestation. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture. Pittsburgh: ACM, pp. 223232.Google Scholar
Goguen, J. A., Thatcher, J. W., Wagner, E. G., & Wright, J. B. (1977) Initial Algebra Semantics and Continuous Algebras. J. ACM, 24 (1), 6895.CrossRefGoogle Scholar
Hu, Z., Iwasaki, H., & Takeichi, M. (1999) Calculating accumulations. New Generation Comput., 17 (2), 153173.CrossRefGoogle Scholar
Johann, P. (2002) A generalization of short-cut fusion and its correctness proof. Higher-Order Symbolic Comput., 15 (4), 273300.CrossRefGoogle Scholar
Joyal, A., Street, R., & Verity, D. (1996) Traced monoidal categories. Mathematical Proc. Cambridge Philosophical Society, 119 (3), 447468.CrossRefGoogle Scholar
Kakehi, K., Glück, R., & Futamura, Y. (2001) On deforesting parameters of accumulating maps. In Proceedings of Logic Based Program Synthesis and Transformation, 11th International Workshop, LOPSTR 2001. Lecture Notes in Computer Science, vol. 2372. Berlin/Heidelberg, Springer Verlag, pp. 4656.Google Scholar
Kühnemann, A. (1998) Benefits of tree transducers for optimizing functional programs. In Preceedings of Foundations of Software Technology and Theoretical Computer Science 18th Conference. Lecture Notes in Computer Science, vol. 1530. Berlin/Heidelberg, Springer Verlag, pp. 146157.CrossRefGoogle Scholar
Ma, Q. & Reynolds, J. C. (1991) Types, abstractions, and parametric polymorphism, part 2. In Proceedings of Mathematical Foundations of Programming Semantics (MFPS 1991). Lecture Notes in Computer Science, vol. 598. Berlin/Heidelberg, Springer Verlag, pp. 140.Google Scholar
Malcolm, G. (1989) Homomorphisms and promotability. In Proceedings of Mathematics of Program Construction. Lecture Notes in Computer Science, vol. 375. Berlin/Heidelberg, Springer Verlag, pp. 335347.CrossRefGoogle Scholar
Nishimura, S. (2003) Correctness of a higher-order removal transformation through a relational reasoning. In Proceedings of Programming Language and Systems, First Asian Symposium, APLAS 2003. Lecture Notes in Computer Science, vol. 2895. Berlin/Heidelberg, Springer Verlag, pp. 358375.Google Scholar
Nishimura, S. (2004) Fusion with stacks and accumulating parameters. In Proceedings of the 2004 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation. Pittsburgh: ACM, pp. 101112.CrossRefGoogle Scholar
Ohori, A. & Sasano, I. (2007) Lightweight fusion by fixed point promotion. In Proceedings of the 34th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. Pittsburgh: ACM, pp. 143154.CrossRefGoogle Scholar
Plotkin, G. & Abadi, M. (1993) A logic for parametric polymorphism. In Proceedings of International Conference on Typed Lambda Calculi and Applications, TLCA '93. Lecture Notes in Computer Science, vol. 664. Berlin/Heidelberg, Springer Verlag, pp. 361375.CrossRefGoogle Scholar
Sheard, T. & Fegaras, L. (1993) A fold for all seasons. In Proceedings of International Conference on Functional Programming Languages and Computer Architecture (FPCA'93). Pittsburgh: ACM, pp. 233242.CrossRefGoogle Scholar
Svenningsson, J. (2002) Shortcut fusion for accumulating parameters & zip-like functions. In Proceedings of the 2002 International Conference on Functional Programming. Pittsburgh: ACM, pp. 124132.Google Scholar
Takano, A. & Meijer, E. (1995) Shortcut deforestation in calculational form. In Proceedings of International Conference on Functional Programming Languages and Computer Architecture (FPCA'95). Pittsburgh: ACM, pp. 306313.Google Scholar
Voigtländer, J. (2004) Using circular programs to deforest in accumulating parameters. Higher-Order Symbolic Comput., 17 (1), 129163.CrossRefGoogle Scholar
Voigtländer, J. (2007) Formal efficiency analysis for tree transducer composition. Theory Computing Systems, 41 (4), 619689.CrossRefGoogle Scholar
Voigtländer, J. & Kühnemann, A. (2004) Composition of functions with accumulating parameters. J. Functional Programming, 14 (3), 317363.CrossRefGoogle Scholar
Wadler, P. (1989) Theorems for free! In Proceedings of International Conference on Functional Programming and Computer Architecture (FPCA'89). Pittsburgh: ACM, pp. 347359.Google Scholar
Wadler, P. (1990) Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73 (2), 231248.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.