## Algebraic fusion of functions with an accumulating parameter and its improvement (2006)

### Cached

### Download Links

- [www.kurims.kyoto-u.ac.jp]
- [www.kurims.kyoto-u.ac.jp]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proc. ACM International Conference on Functional Programming |

Citations: | 1 - 0 self |

### BibTeX

@INPROCEEDINGS{Katsumata06algebraicfusion,

author = {Shin-ya Katsumata},

title = {Algebraic fusion of functions with an accumulating parameter and its improvement},

booktitle = {In Proc. ACM International Conference on Functional Programming},

year = {2006},

pages = {227--238}

}

### OpenURL

### Abstract

We present a unifying solution to the problem of fusion of functions, where both the producer function and the consumer function have one accumulating parameter. The key idea in this development is to formulate the producer function as a function which computes over a monoid of data contexts. Upon this formulation, we develop a fusion method called algebraic fusion based on the elementary theory of universal algebra and monoids. The producer function is fused with a monoid homomorphism that is derived from the definition of the consumer function, and is turned into a higher-order function f that computes over the monoid of endofunctions. We then introduce a general concept called improvement, in order to reduce the cost of computing over the monoid of endofunctions (i.e., function closures). An improvement of the function f via a monoid homomorphism h is a function g that satisfies f = h ◦ g. This provides a principled way of finding a first-order function representing a solution to the fusion problem. It also presents a clean and unifying account for varying fusion methods that have been proposed so far. Furthermore, we show that our method extends to support partial and infinite data structures, by means of an appropriate monoid structure. Categories and Subject Descriptors D.3.2 [Programming Languages]: Language Classifications—Applicative (functional) languages;

### Citations

570 | A Transformation System for Developing Recursive Programs
- Burstall, Darlington
- 1976
(Show Context)
Citation Context ...in the following equations: rev (Rev []) = rev [−] = id rev (Rev (a :: l)) = rev (Rev l · (a :: [−])) = (rev (Rev l)) ◦ (rev (a :: [−])) = (rev (Rev l)) ◦ (λwx.w (a :: x)) By folding (in the sense of =-=[2]-=-) the function calls of the form rev(Rev −) , we obtain a recursive function revrev: revrev ∈ Tlist → (Tlist → Tlist) → (Tlist → Tlist) revrev [] w = w revrev (a :: l) w = revrev l (λx.w (a :: x)). Th... |

400 | Deforestation: Transforming programs to eliminate trees
- Wadler
- 1990
(Show Context)
Citation Context ...e is another stream of developments of fusion techniques, based on Burstall and Darlington’s unfold-fold transformation [2]. This line of research was initiated by Wadler, who presented deforestation =-=[22]-=- as a fusion transformation for a particular class of list processing programs. It has been recognized that it is difficult to control the deforestation process, when it is applied to functions with a... |

328 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ... shortcut fusion for tree-terms using the combinator build ′ : (∀α.(α → α → α) → α → α → α) → tree → tree defined by build ′ x y = x tree N L y. As an application of Reynolds’ parametricity principle =-=[14, 21]-=-, we have cata τ k z (build ′ x h) = g τ k z (cata τ k z h). From this, we obtain build’/cata fusion: for any producer prod : ρ → tree → tree and consumer cons : tree → τ satisfying (B-prod) ∃g.prod =... |

194 | A short cut to deforestation
- Gill, Launchbury, et al.
- 1993
(Show Context)
Citation Context ... to implement, as the applicability of the laws can be judged locally without a global analysis of programs. Examples of such calculational methods include the promotion theorem [15], shortcut fusion =-=[9]-=- and its derivatives [8, 19, 11, 6]. These techniques, however, do not give a satisfactory result when applied to functions with an extra argument, called accumulating parameter, on which temporary da... |

185 |
Initial Algebra Semantics and Continuous Algebras
- Goguen, Thatcher, et al.
- 1977
(Show Context)
Citation Context ...) and continuous functions. For CPOs D, E, by [D → E] (resp. [D →⊥ E]) we mean the CPO of (resp. strict) continuous functions. The concept of continuous Σ-algebras is fairly standard; see for example =-=[10]-=-. Definition 5.1 A continuous Σ-algebra D is a pair (D, d) of a CPO D and an operator-indexed family of continuous functions {do}o∈Σ such that do ∈ [D n → D] for each o ∈ Σ (n) . A (resp. strict) cont... |

165 |
Traced monoidal categories
- Joyal, Street, et al.
- 1996
(Show Context)
Citation Context ...of boxes in Figure 3 is exactly the pattern which appeared in the definition of the composition of morphisms in Abramsky’s geometry-of-interaction construction [1] and Joyal et al.’s Int-construction =-=[12]-=-.sβ. Since β is a strict monoid homomorphism, the following theorem is an immediate consequence of Proposition 5.2. Theorem 5.7 Let f ∈ [T ∞ Σ →⊥ [[D → D] → [D → D]]] be a result of an algebraic fusio... |

112 | A fold for all seasons
- Sheard, Fegaras
- 1993
(Show Context)
Citation Context ... blex ′ satisfies blex t = β (blex ′ t) 6. Related Work = λwx.letrec (p, q) = blex ′ t (x, w p) in q. In an early study of fusion laws, Sheard and Fegaras presented the second-order promotion theorem =-=[18]-=-. They demonstrated that the identity function can be obtained from the composition of the list reverse function with itself by applying their fusion law and what they call “inverse” transformation. T... |

107 | Macro tree transducers - Engelfriet, Vogler - 1985 |

91 | Shortcut to Deforestation in Calculational Form
- Takano, Meijer
- 1995
(Show Context)
Citation Context ...plicability of the laws can be judged locally without a global analysis of programs. Examples of such calculational methods include the promotion theorem [15], shortcut fusion [9] and its derivatives =-=[8, 19, 11, 6]-=-. These techniques, however, do not give a satisfactory result when applied to functions with an extra argument, called accumulating parameter, on which temporary data is accumulated during recursion.... |

67 |
H.: Syntax-Directed Semantics — Formal Models Based on Tree Transducers
- Fülöp, Vogler
- 1998
(Show Context)
Citation Context ...der has proposed the lazy composition technique [20] that solves the issue by an elegant use of circular let. His techniqueswas derived from the corresponding technique developed for tree transducers =-=[4]-=-, which are a close cousin of the attribute grammar formalism. However, he has only informally discussed the correctness of his method resorting to an intuitive account of the laziness. It may be valu... |

66 | Retracing Some Paths in Process Algebra
- Abramsky
(Show Context)
Citation Context ...esting to point out that the connection of boxes in Figure 3 is exactly the pattern which appeared in the definition of the composition of morphisms in Abramsky’s geometry-of-interaction construction =-=[1]-=- and Joyal et al.’s Int-construction [12].sβ. Since β is a strict monoid homomorphism, the following theorem is an immediate consequence of Proposition 5.2. Theorem 5.7 Let f ∈ [T ∞ Σ →⊥ [[D → D] → [D... |

62 | Cheap Deforestation for Non-strict Functional Languages
- Gill
- 1996
(Show Context)
Citation Context ...plicability of the laws can be judged locally without a global analysis of programs. Examples of such calculational methods include the promotion theorem [15], shortcut fusion [9] and its derivatives =-=[8, 19, 11, 6]-=-. These techniques, however, do not give a satisfactory result when applied to functions with an extra argument, called accumulating parameter, on which temporary data is accumulated during recursion.... |

53 | Types, Abstraction and Parametric Polymorphism, Part 2
- Ma, Reynolds
- 1992
(Show Context)
Citation Context ... shortcut fusion for tree-terms using the combinator build ′ : (∀α.(α → α → α) → α → α → α) → tree → tree defined by build ′ x y = x tree N L y. As an application of Reynolds’ parametricity principle =-=[14, 21]-=-, we have cata τ k z (build ′ x h) = g τ k z (cata τ k z h). From this, we obtain build’/cata fusion: for any producer prod : ρ → tree → tree and consumer cons : tree → τ satisfying (B-prod) ∃g.prod =... |

50 | Composition and evaluation of attribute coupled grammars - Giegerich - 1988 |

49 |
Attribute coupled grammars
- Ganzinger, Giegerich
- 1984
(Show Context)
Citation Context ... rather simple monoid homomorphism. The second author, Nishimura, proposed a powerful fusion method [16, 17], whose transformation principle was originally drawn from a technique of attribute grammar =-=[5]-=-. His fusion method, however, crucially relies on a transformation called higherorder removal, whose transformation rules have a broken locality. This adds an extra complexity and makes it difficult t... |

42 | Shortcut fusion for accumulating parameters & zip-like functions - Svenningsson - 2002 |

35 |
Safe fusion of functional expressions II: Further improvements
- Chin
- 1994
(Show Context)
Citation Context ...cognized that it is difficult to control the deforestation process, when it is applied to functions with accumulating parameters, because some obstructing function calls may incur infinite unfoldings =-=[3]-=-. Voigtländer has proposed the lazy composition technique [20] that solves the issue by an elegant use of circular let. His techniqueswas derived from the corresponding technique developed for tree tr... |

35 |
Homomorphisms and promotability
- Malcolm
- 1989
(Show Context)
Citation Context ...nal methods are easier to implement, as the applicability of the laws can be judged locally without a global analysis of programs. Examples of such calculational methods include the promotion theorem =-=[15]-=-, shortcut fusion [9] and its derivatives [8, 19, 11, 6]. These techniques, however, do not give a satisfactory result when applied to functions with an extra argument, called accumulating parameter, ... |

31 | Benefits of tree transducers for optimizing functional programs - Kühnemann - 1998 |

20 | Composition of Functions with Accumulating Parameters - Voigtlander, Kuhnemann |

17 |
A generalization of short-cut fusion and its correctness proof
- Johann
(Show Context)
Citation Context ...plicability of the laws can be judged locally without a global analysis of programs. Examples of such calculational methods include the promotion theorem [15], shortcut fusion [9] and its derivatives =-=[8, 19, 11, 6]-=-. These techniques, however, do not give a satisfactory result when applied to functions with an extra argument, called accumulating parameter, on which temporary data is accumulated during recursion.... |

15 | Monadic augment and generalised short cut fusion
- Ghani, Johann
(Show Context)
Citation Context |

15 | Using circular programs to deforest in accumulating parameters
- Voigtländer
- 2002
(Show Context)
Citation Context ...e fusion methods that generate firstorder programs when they are applied to functions with an accumulating parameter, including fusion law for the dmap combinator [13], the lazy composition technique =-=[20]-=-, and a higher-order removal method applied to the result of shortcut fusion [17]. In this paper, we propose a new fusion technique called algebraic fusion. The merits of algebraic fusion over these e... |

6 | Lightweight fusion by fixed point promotion - Ohori, Sasano - 2007 |

6 | Formal Efficiency Analysis for Tree Transducer Composition - Voigtländer - 2007 |

5 | On deforesting parameters of accumulating maps
- Kakehi, Gluck, et al.
- 2001
(Show Context)
Citation Context ...lopments have seen several alternative fusion methods that generate firstorder programs when they are applied to functions with an accumulating parameter, including fusion law for the dmap combinator =-=[13]-=-, the lazy composition technique [20], and a higher-order removal method applied to the result of shortcut fusion [17]. In this paper, we propose a new fusion technique called algebraic fusion. The me... |

5 |
Fusion with stacks and accumulating parameters
- Nishimura
- 2004
(Show Context)
Citation Context ...ions with an accumulating parameter, including fusion law for the dmap combinator [13], the lazy composition technique [20], and a higher-order removal method applied to the result of shortcut fusion =-=[17]-=-. In this paper, we propose a new fusion technique called algebraic fusion. The merits of algebraic fusion over these existing methods are addressed below.s• Algebraic fusion is based on the theory of... |

3 |
V.: Generalizing the augment combinator
- Ghani, Uustalu, et al.
- 2006
(Show Context)
Citation Context ... algebraic data types [11] and proved its correctness. Ghani et al. analyzed the underlying mathematical structure of the augment combinator, and proposed a more general scheme called monadic augment =-=[7, 6]-=-. The present paper offers an alternative solution in an algebraic setting, where the elementary theory of monoids and universal algebra give a principled way of devising fusion laws. Built on differe... |

3 |
Correctness of a higher-order removal transformation through a relational reasoning. Pages 358–375 of: Programming language and systems
- Nishimura
- 2003
(Show Context)
Citation Context ...usion (hence, shortcut fusion) yields a higher-order function. This is the motivation for introducing the concept of improvement in Section 4. This problem has already been recognized by Nishimura in =-=[16, 17]-=-, and he introduced a program transformation technique called higher-order removal to reduce the order of computation. His transformation process is designed for a call-by-name language, and it takes ... |

2 | A logic for parametric polymorphism. Pages 361–375 of: International conference on typed lambda calculi and applications - Plotkin, Abadi - 1993 |

1 | Retracting some paths in process algebra. Pages 1–17 of - Abramsky - 1996 |

1 | Attribute coupled grammars. Pages 157– 170 of - Ganzinger, Giegerich - 1984 |

1 | Generalizing the augment combinator. Pages 65–78 of: Trends in functional programming 5. Intellect - Ghani, Uustalu, et al. - 2006 |

1 | A short cut to deforestation. Pages 223–232 of - Gill, Launchbury, et al. - 1993 |

1 | Calculating accumulations. New generation comput - Hu, Iwasaki, et al. - 1999 |

1 | Traced monoidal categories. Mathematical proceedings of the cambridge philosophical society - Joyal, Street, et al. - 1996 |

1 | On deforesting parameters of accumulating maps. Pages 46–56 of: Logic based program synthesis and transformation - Kakehi, Glück, et al. - 2001 |

1 | Homomorphisms and promotability. Pages 335–347 of: Mathematics of program construction - Malcolm - 1989 |

1 | Fusion with stacks and accumulating parameters. Pages 101–112 of - Nishimura - 2004 |

1 | A fold for all seasons. Pages 233–242 of: International conference on functional programming languages and computer architecture (FPCA’93 - Sheard, Fegaras - 1993 |

1 | Shortcut deforestation in calculational form. Pages 306– 313 of: Proc. of international conference on functional programming languages and computer architecture (FPCA’95 - Takano, Meijer - 1995 |

1 | Theorems for free! Pages 347–359 of: International conference on functional programming and computer architecture (FPCA’89 - Wadler - 1989 |