## Tupling Calculation Eliminates Multiple Data Traversals (1997)

Venue: | In ACM SIGPLAN International Conference on Functional Programming |

Citations: | 34 - 19 self |

### BibTeX

@INPROCEEDINGS{Hu97tuplingcalculation,

author = {Zhenjiang Hu and Hideya Iwasaki and Masato Takeichi and Akihiko Takano},

title = {Tupling Calculation Eliminates Multiple Data Traversals},

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

year = {1997},

pages = {164--175},

publisher = {ACM Press}

}

### Years of Citing Articles

### OpenURL

### Abstract

Tupling is a well-known transformation tactic to obtain new efficient recursive functions by grouping some recursive functions into a tuple. It may be applied to eliminate multiple traversals over the common data structure. The major difficulty in tupling transformation is to find what functions are to be tupled and how to transform the tupled function into an efficient one. Previous approaches to tupling transformation are essentially based on fold/unfold transformation. Though general, they suffer from the high cost of keeping track of function calls to avoid infinite unfolding, which prevents them from being used in a compiler. To remedy this situation, we propose a new method to expose recursive structures in recursive definitions and show how this structural information can be explored for calculating out efficient programs by means of tupling. Our new tupling calculation algorithm can eliminate most of multiple data traversals and is easy to be implemented. 1 Introduction Tupli...

### Citations

604 | A Transformation System for Developing Recursive Programs
- Burstall, Darlington
- 1977
(Show Context)
Citation Context ... tupled and how an efficient definition for the tupled function is derived. Traditional approaches [Pet87, PP91, Chi93] to solving this problem are based on the well-known fold/unfold transformations =-=[BD77]-=-, using tupling analysis to discover an eureka tuple and using fold/unfold transformation to derive an efficient program for the tupled function. This is quite general but comes at price. In the fold/... |

560 |
The Implementation of Functional Programming Languages
- Jones
- 1987
(Show Context)
Citation Context ...ur tupling transformation becomes much more faster than the original one, but with about 50% additional allocations. It is worth noting that by the ordinary implementation of the tuple data structure =-=[Pey88]-=- our algorithm do not guarantee spectacular efficiency improvements. This is a common problem among all existing tupling methods. Consider for example the following average function: average x = sumx ... |

308 | Functional programming with bananas, lenses, envelopes and barbed wire - Meijer, Paterson - 1991 |

201 | A short cut to deforestation - Gill, Launchbury, et al. - 1993 |

113 | A fold for all seasons
- Sheard, Fougaras
- 1993
(Show Context)
Citation Context ...ok92], we illustrate by some examples how data types can be captured by endofunctors. In fact, from a common data type definition, an endofunctor can be automatically derived to capture its structure =-=[SF93]-=-. As a concrete example, consider the data type of cons lists with elements of type A, which is usually defined by 1 List A = Nil j Cons (A; List A): 1 Note that for notational convenience, we sometim... |

99 |
and Order in Algorithms
- Law
- 1992
(Show Context)
Citation Context ...functional languages. To remedy this situation, we turn to another transformation technique known as program calculation [MFP91, SF93, MH95], which is based on the theory of Constructive Algorithmicss=-=[Fok92]-=-. Different from the previous fold/unfold transformation whose emphasis is on the generality of transformation process, program calculation deals with programs in some specific recursive forms, such a... |

93 | Memo functions and machine learning - Michie - 1968 |

93 | Shortcut deforestation in calculational form
- Takano, Meijer
- 1995
(Show Context)
Citation Context ...= plus ffi (id 2 sum) That is, sum Nil = 0 sum (Cons(x; xs)) = plus(x; sum xs): 2.2 Mutual Recursions and Tupling Just like that the fusion in calculational forms relies on a single Acid Rain Theorem =-=[TM95]-=-, our tupling algorithm basically depends on the Mutu Tupling Theorem [Fok89, Fok92]. Theorem 1 (Mutu Tupling) f ffi inF = OE ffi F (f 4 g); g ffi inF = / ffi F (f 4 g) f 4 g = ([OE 4 /])F 2 This theo... |

80 |
Using circular programs to eliminate multiple traversals of data
- Bird
- 1984
(Show Context)
Citation Context ... we assume that the renaming has been done whenever there is any danger of name-conflicts. As an example, consider the following program in our language naively solving the well-known repsort problem =-=[Bir84]-=-: transforming a binary tree into one of the same shape in which the leaf values have to be replaced with those of the original tree but arranged in increasing order. repsort t = rep t (sort (leaves t... |

75 | Warm fusion: Deriving build-catas from recursive definitions - Launchbury, Sheard - 1995 |

74 |
Towards an Automated Tupling Strategy
- Chin
- 1993
(Show Context)
Citation Context ...lgorithm in Section 5. Related work and discussion are given in Section 6. 2 Mutu Tupling Theorem Generally, tupling transformation is very complicated while its termination is far from being trivial =-=[Chi93]-=-. The calculational approach that will be taken here is less general, but should be more practical. We don't guarantee to remove multiple traversals over the same data structures by all functions (ind... |

69 | Tabulation Techniques for Recursive Programs - Bird - 1980 |

54 | Lazy memo-functions - Hughes - 1985 |

49 | Deriving structural hylomorphisms from recursive definitions - Hu, Iwasaki, et al. - 1996 |

38 | Unfolding-definition-folding, in this order, for avoiding unnecessary variables in logic programs - Proietti, Pettorossi - 1995 |

33 | A Calculational Fusion System HYLO
- Onoue, Hu, et al.
- 1997
(Show Context)
Citation Context ... approach to tupling transformation makes a good progress in code optimization of functional programs. In addition, our tupling calculational transformation is expected to be added to the HYLO system =-=[OHIT97]-=-, a calculational system for improving functional programs, which is now under development in the University of Tokyo. Acknowledgement This paper owes much to the thoughtful and helpful discussions wi... |

32 |
Category theoretic approach to data types
- Hagino
- 1987
(Show Context)
Citation Context ...nding to () 2 . Besides, we use inFL A to denote the data constructor in List A: inFL A = Nil 5 Cons: In fact, the List A is the least solution of X to the equation X = inFL A (FLA X) as discussed in =-=[Hag87]-=-. The inFL A has its inverse, denoted by outFL A : List A ! FLA (List A), which captures the data destructor of List A, i.e., out FL A = xs: case xs of Nil ! (1; ()); Cons (a; as) ! (2; (a; as)): Anot... |

25 | Eliminating redundant recursive calls - Cohen - 1983 |

16 |
Tupling and mutumorphisms
- Fokkinga
- 1990
(Show Context)
Citation Context ...ow all legal programs as input and the transformed program will be expected to be made more efficient. Basically, our tupling transformation is based on a single simple rule, the Mutu Tupling Theorem =-=[Fok89]-=-, which is well-known in the community of Constructive Algorithmics. 2.1 Constructive Algorithmics To understand the Mutu Tupling Theorem, the basis of our tupling algorithm, we should briefly review ... |

11 | Incremental Computation: A SemanticsBased Systematic Transformation Approach
- Liu
- 1996
(Show Context)
Citation Context ...evious work require more or less humaninsights, which are hard to be made automatic. Other related work includes memoization [Mic68, Hug85], tabulation [Bir80, Coh83, CH95] and incremental algorithms =-=[Liu96]-=-. All transformation algorithms introduced in this paper have been implemented in a rapid prototyped way. It is completely mechanical and does not rely on heuristics. Although we have to wait for the ... |

9 | A transformational method for dynamic-sized tabulation - Chin, Hagiya - 1995 |

9 |
Partial parametrization eliminates multiple traversals of data structures
- Takeichi
- 1987
(Show Context)
Citation Context ...end lists). Elimination of multiple traversals over data structures has been studied for a long time. Our work is related to these works. Bird [Bir84] suggested the use of circular programs. Takeichi =-=[Tak87]-=- used a different technique called lambda hoisting with introduction of common higher order functions. In particular, we are much influenced by Pettorossi 's work [Pet87] of using lambda abstraction i... |

7 |
Program development using lambda abstraction
- Pettorossi
- 1987
(Show Context)
Citation Context ...f circular programs. Takeichi [Tak87] used a different technique called lambda hoisting with introduction of common higher order functions. In particular, we are much influenced by Pettorossi 's work =-=[Pet87]-=- of using lambda abstraction in conjunction with the tupling tactic. However, the transformations in the previous work require more or less humaninsights, which are hard to be made automatic. Other re... |

5 |
Fusion and Tupling Transformations: Synergies and Conflicts (Invited Paper
- Chin
- 1995
(Show Context)
Citation Context ...n for two reasons. First, we believe that tupling transformation tactic should be more practical to be used in a compiler. Second, since tupling and fusion are two most related transformation tactics =-=[Chi95]-=-, it is quite natural to study tupling transformation in the framework where fusion transformation is studied. In this paper, we demonstrate how to proceed tupling transformation by means of program c... |

4 | Bananas in space: Exteding fold and unfold to exponential types - Meijer, Hutton - 1995 |

3 |
Construction of list homomorphisms via tupling and fusion
- Hu, Iwasaki, et al.
- 1996
(Show Context)
Citation Context ... transformation in calculational form. Our tupling algorithm improves the recursion by constructing a catamorphism (Theorem 4), making ease for fusion transformation. A relevant study can be found in =-=[HIT96a]-=- where tupling and fusion are used together to derive list homomorphisms (i.e., catamorphisms over append lists). Elimination of multiple traversals over data structures has been studied for a long ti... |