## Possibilities and Limitations of Call-by-Need Space Improvement (2001)

### Cached

### Download Links

- [www.cs.chalmers.se]
- [www.cse.chalmers.se]
- [www.cs.chalmers.se]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proceedings of the sixth ACM SIGPLAN International Conference on Functional Programming |

Citations: | 6 - 0 self |

### BibTeX

@INPROCEEDINGS{Gustavsson01possibilitiesand,

author = {Jörgen Gustavsson and David Sands},

title = {Possibilities and Limitations of Call-by-Need Space Improvement},

booktitle = {In Proceedings of the sixth ACM SIGPLAN International Conference on Functional Programming},

year = {2001},

pages = {265--276},

publisher = {ACM Press}

}

### Years of Citing Articles

### OpenURL

### Abstract

Innocent-looking program transformations can easily change the space complexity of lazy functional programs. The theory of space improvement seeks to characterise those local program transformations which are guaranteed never to worsen asymptotic space complexity of any program. Previous work by the authors introduced the space improvement relation and showed that a number of simple local transformation laws are indeed space improvements. This paper seeks an answer to the following questions: is the improvement relation inhabited by interesting program transformations, and, if so, how might they be established? We show that the asymptotic space improvement relation is semantically badly behaved, but that the theory of strong space improvement possesses a xed-point induction theorem which permits the derivation of improvement properties for recursive de nitions. With the help of this tool we explore the landscape of space improvement by considering a range of classical program transformations.

### Citations

400 | Deforestation: Transforming programs to eliminate trees
- Wadler
- 1990
(Show Context)
Citation Context ...onal behaviour of any . A particular code distribution would be free to provide the presumably more ecient definition of any . A clever compiler might even automatically derive it using deforestation =-=[32-=-]. The second kind of reply appealed to the folklore of call-by-need: the list is only an intermediate data structures and the two denitions have the same asymptotic space behaviour. The following res... |

181 | A Natural Semantics for Lazy Evaluation
- Launchbury
- 1993
(Show Context)
Citation Context ...szero M j let f~x = ~ Mg in N j case M of fc i ~x i N i g The syntactic restriction is now rather standard, following its use in core language of the Glasgow Haskell compiler, e.g., [22, 23], and in [=-=14, 28]-=-. In examples we will sometimes use unrestricted application MN as syntactic sugar for let fx = Ng in M x where x is a fresh variable. Similarly for constructor expressions. All constructors have asxe... |

102 |
98: A non-strict, purely functional language. http://www.haskell.org
- Jones, Hughes
- 1999
(Show Context)
Citation Context ...e predicate. The function can be dened in a direct recursive style: any p xs = case xs of nil false y : ys p y jj any p ys where jj is the inx logical or operator. However in the Haskell report [13] any is dened in an elegant combinator style: any 0 p = orsmap p where or is dened as or = foldr (jj) false Apart from the stylistic dierences, there is a key operational dierence between the two ... |

82 | A transformation-based optimiser for Haskell
- Jones, Santos
- 1998
(Show Context)
Citation Context ... M +N j addnM j iszero M j let f~x = ~ Mg in N j case M of fc i ~x i N i g The syntactic restriction is now rather standard, following its use in core language of the Glasgow Haskell compiler, e.g., [=-=22, 23]-=-, and in [14, 28]. In examples we will sometimes use unrestricted application MN as syntactic sugar for let fx = Ng in M x where x is a fresh variable. Similarly for constructor expressions. All const... |

73 |
Towards an automated tupling strategy
- Chin
- 1993
(Show Context)
Citation Context ...erforming program transformation is also noted by Peyton Jones [12]. Case Study 6: Tupling Tupling is the name of a set of program transformations that bring together computations over the same input =-=[21, 6]-=-. Tupling transformations can dramatically reduce the amount of space and time required. Consider for example the naive function to compute the average value of the elements of a list: average xs = su... |

65 | P.: Deriving a Lazy Abstract Machine
- Sestoft
- 1997
(Show Context)
Citation Context ...szero M j let f~x = ~ Mg in N j case M of fc i ~x i N i g The syntactic restriction is now rather standard, following its use in core language of the Glasgow Haskell compiler, e.g., [22, 23], and in [=-=14, 28]-=-. In examples we will sometimes use unrestricted application MN as syntactic sugar for let fx = Ng in M x where x is a fresh variable. Similarly for constructor expressions. All constructors have asxe... |

61 | Total correctness by local improvement in the transformation of functional programs
- Sands
- 1996
(Show Context)
Citation Context ...verage 0 xs because the functions (due to the evaluation order of =) require the sum before the length. 7. RELATED WORK AND CONCLUSIONS Improvement theory wassrst developed in the call-byname setting =-=[26, 25, 27]-=- for the purpose of reasoning about running-times of programs. Moran and Sands [19] developed a call-by-need time-improvement theory, together with a variety of induction principles. This present work... |

59 |
The Design and Implementation of Programming Languages
- Hughes
- 1984
(Show Context)
Citation Context ...ly, this problem appears to be linked to the intensional expressiveness of the language. Hughes has argued that it is impossible to dene split in a space ecient way using a particular lazy evaluator [=-=11-=-]. He proposed a solution involving combinators for explicit parallelism and synchronisation. With these language primitives the original denition of split can be made ecient by having just the right ... |

55 | Compiling haskell by program transformation: a report from the trenches
- Jones
- 1996
(Show Context)
Citation Context ...the language. This allows the proof and the required basic laws to be moresne-grained. The usefulness of these language constructs when performing program transformation is also noted by Peyton Jones =-=[12]-=-. Case Study 6: Tupling Tupling is the name of a set of program transformations that bring together computations over the same input [21, 6]. Tupling transformations can dramatically reduce the amount... |

51 | Let-floating: moving bindings to give faster programs
- Jones, Partain, et al.
- 1996
(Show Context)
Citation Context ... M +N j addnM j iszero M j let f~x = ~ Mg in N j case M of fc i ~x i N i g The syntactic restriction is now rather standard, following its use in core language of the Glasgow Haskell compiler, e.g., [=-=22, 23]-=-, and in [14, 28]. In examples we will sometimes use unrestricted application MN as syntactic sugar for let fx = Ng in M x where x is a fresh variable. Similarly for constructor expressions. All const... |

42 |
Compiling Lazy Functional Languages, Part II
- Augustsson
- 1987
(Show Context)
Citation Context ...ns specially. A pattern binding in a let expression takes the form let fc ~x = Mg in N: Prior to Sparud's proposal, these kind of bindings were thought of as mere syntactic sugar and a compiler (e.g. =-=[1]) w-=-ould typically translate it into the following let fp = M;x1 = c 1 p; : : : ; xn = cn pg in N which reintroduces the \dangerous" projections. Sparud's proposal was to have pattern bindings as asr... |

42 | Semantics of memory management for polymorphic languages
- Morrisett, Harper
- 1997
(Show Context)
Citation Context ...ined from h ; M; S i by removing zero or more bindings and update markers from the heap and the stack respectively. This is an accessibility-based denition as found in e.g., the gc-reduction rule of [=-=20-=-]. The removal of update-markers from the stack is not surprising given that they are viewed as the binding occurrences of the variables in question. We are now ready to dene what it means for a compu... |

39 | Improvement in a lazy context: an operational theory for call-by-need
- Moran, Sands
- 1999
(Show Context)
Citation Context ... the length. 7. RELATED WORK AND CONCLUSIONS Improvement theory wassrst developed in the call-byname setting [26, 25, 27] for the purpose of reasoning about running-times of programs. Moran and Sands =-=[19]-=- developed a call-by-need time-improvement theory, together with a variety of induction principles. This present work, and its predecessor [10] are the only attempts (of which we are aware) which form... |

39 | A Naïve Time Analysis and its Theory of Cost Equivalence
- Sands
- 1995
(Show Context)
Citation Context ...verage 0 xs because the functions (due to the evaluation order of =) require the sum before the length. 7. RELATED WORK AND CONCLUSIONS Improvement theory wassrst developed in the call-byname setting =-=[26, 25, 27]-=- for the purpose of reasoning about running-times of programs. Moran and Sands [19] developed a call-by-need time-improvement theory, together with a variety of induction principles. This present work... |

36 | From operational semantics to domain theory
- Mason, Smith, et al.
- 1996
(Show Context)
Citation Context ... the Scott-style denotational semantics approach where recursion is modelled by a leastsxed point construction. The essence of this approach can be expressed in a purely operational setting. See e.g. =-=[29, 15]-=-. The natural formulation of the leastsxed-point property also fails to hold for weak improvement (a precise formulation can be found in [9]). Intuitively the reason for this failure is that once wesx... |

27 | Modeling Sharing and Recursion for Weak Reduction Strategies using Explicit Substitution
- Benaissa, Lescanne, et al.
- 1996
(Show Context)
Citation Context ... transformations. More details of this work can be found in thesrst author's PhD thesis [9]. Other related work includes the development of \spaceaware " operational models for call-by-need langu=-=ages [28, 24, 4, -=-3], studies of space-safety properties of global transformations [17, 18] and of the relative eciency of dierent abstract machines [5, 7, 2, 18]. Minamide [18] suggests an alternative to our denition ... |

24 | Operational Reduction Models for Functional Programming Languages
- Rose
- 1996
(Show Context)
Citation Context ... transformations. More details of this work can be found in thesrst author's PhD thesis [9]. Other related work includes the development of \spaceaware " operational models for call-by-need langu=-=ages [28, 24, 4, -=-3], studies of space-safety properties of global transformations [17, 18] and of the relative eciency of dierent abstract machines [5, 7, 2, 18]. Minamide [18] suggests an alternative to our denition ... |

21 | Operational theories of improvement in functional languages
- Sands
- 1991
(Show Context)
Citation Context ...verage 0 xs because the functions (due to the evaluation order of =) require the sum before the length. 7. RELATED WORK AND CONCLUSIONS Improvement theory wassrst developed in the call-byname setting =-=[26, 25, 27]-=- for the purpose of reasoning about running-times of programs. Moran and Sands [19] developed a call-by-need time-improvement theory, together with a variety of induction principles. This present work... |

20 | Fixing Some Space Leaks with a Garbage Collector
- Wadler
- 1987
(Show Context)
Citation Context ...icit parallelism and synchronisation. With these language primitives the original denition of split can be made ecient by having just the right degree of parallelism. Another proposal, due to Wadler [=-=31]-=-, is to solve the problem by extending the garbage collector. Whenever the garbage collector encounters a term of the form fst p where p is bound to an evaluated pair, it may perform the reduction of ... |

18 | A foundation for space-safe transformations of call-by-need programs
- Gustavsson, Sands
- 1999
(Show Context)
Citation Context ...asoning about running-times of programs. Moran and Sands [19] developed a call-by-need time-improvement theory, together with a variety of induction principles. This present work, and its predecessor =-=[10]-=- are the only attempts (of which we are aware) which formalise space safety properties of local (non-wholeprogram) transformations. More details of this work can be found in thesrst author's PhD thesi... |

18 | From operational to denotational semantics
- Smith
- 1992
(Show Context)
Citation Context ... the Scott-style denotational semantics approach where recursion is modelled by a leastsxed point construction. The essence of this approach can be expressed in a purely operational setting. See e.g. =-=[29, 15]-=-. The natural formulation of the leastsxed-point property also fails to hold for weak improvement (a precise formulation can be found in [9]). Intuitively the reason for this failure is that once wesx... |

18 | Fixing some space leaks without a garbage collector. Pages 117-- 122 of
- Sparud
- 1993
(Show Context)
Citation Context ...ctor. Whenever the garbage collector encounters a term of the form fst p where p is bound to an evaluated pair, it may perform the reduction of the projection. A more recent proposal is due to Sparud =-=[30]-=-. He proposes to treat pattern bindings in let expressions specially. A pattern binding in a let expression takes the form let fc ~x = Mg in N: Prior to Sparud's proposal, these kind of bindings were ... |

12 |
Transformation of Programs and Use of Tupling Strategy
- Pettorossi
- 1977
(Show Context)
Citation Context ...erforming program transformation is also noted by Peyton Jones [12]. Case Study 6: Tupling Tupling is the name of a set of program transformations that bring together computations over the same input =-=[21, 6]-=-. Tupling transformations can dramatically reduce the amount of space and time required. Consider for example the naive function to compute the average value of the elements of a list: average xs = su... |

9 |
Fully abstract models of the typed - calculus
- Milner
- 1977
(Show Context)
Citation Context ...hey can have an effect on the space usage of a program even when they are semantically \dead code". 4.1 Limitations of Weak Improvement A standard result for any operational theory is a context l=-=emma [16]-=-. A context lemma in this case would establish that to prove that M is weakly improved by N , one only needs to compare their behaviour with respect to a much smaller set of contexts, namely the conte... |

8 | Space-profiling semantics of the call-by-value lambda calculus and the cps transformation
- Minamide
- 1999
(Show Context)
Citation Context ...PhD thesis [9]. Other related work includes the development of \spaceaware " operational models for call-by-need languages [28, 24, 4, 3], studies of space-safety properties of global transformat=-=ions [17, 1-=-8] and of the relative eciency of dierent abstract machines [5, 7, 2, 18]. Minamide [18] suggests an alternative to our denition of improvement based on additive constant factors. Its properties are n... |

6 | A model for comparing the space usage of lazy evaluators
- Bakewell, Runciman
- 2000
(Show Context)
Citation Context ...sonable model. In [9] we discuss some of the subtle ways in which dierent abstract machines and implementations described in the literature dier from our model and each other. Bakewell and Runciman [2=-=-=-] focus on techniques for comparing dierent evaluators. Another point of dispute is whether to distinguish between heap and stack space. Many implementations allocate separate memory for the heap and ... |

6 |
A provably time and space e#cient implementation of NESL
- Blelloch, Greiner
- 1996
(Show Context)
Citation Context ...ceaware " operational models for call-by-need languages [28, 24, 4, 3], studies of space-safety properties of global transformations [17, 18] and of the relative eciency of dierent abstract machi=-=nes [5, 7, 2, 18-=-]. Minamide [18] suggests an alternative to our denition of improvement based on additive constant factors. Its properties are not studied for any particular language, although we suspect that it woul... |

5 | A space semantics for core Haskell
- Bakewell, Runciman
- 2000
(Show Context)
Citation Context ... transformations. More details of this work can be found in thesrst author's PhD thesis [9]. Other related work includes the development of \spaceaware " operational models for call-by-need langu=-=ages [28, 24, 4, -=-3], studies of space-safety properties of global transformations [17, 18] and of the relative eciency of dierent abstract machines [5, 7, 2, 18]. Minamide [18] suggests an alternative to our denition ... |

4 |
Proper tail recursion and space eciency
- Clinger
- 1998
(Show Context)
Citation Context ...ceaware " operational models for call-by-need languages [28, 24, 4, 3], studies of space-safety properties of global transformations [17, 18] and of the relative eciency of dierent abstract machi=-=nes [5, 7, 2, 18-=-]. Minamide [18] suggests an alternative to our denition of improvement based on additive constant factors. Its properties are not studied for any particular language, although we suspect that it woul... |

4 | A new criterion for safe program transformations
- Minamide
- 2000
(Show Context)
Citation Context ...PhD thesis [9]. Other related work includes the development of \spaceaware " operational models for call-by-need languages [28, 24, 4, 3], studies of space-safety properties of global transformat=-=ions [17, 1-=-8] and of the relative eciency of dierent abstract machines [5, 7, 2, 18]. Minamide [18] suggests an alternative to our denition of improvement based on additive constant factors. Its properties are n... |

2 |
Space-Safe Transformations and Usage Analysis for Call-by-Need Languages
- Gustavsson
- 2001
(Show Context)
Citation Context ...s to all implementations. Although we will choose a particular model of space use we believe that most of the results and techniques developed in this paper can be adapted to any reasonable model. In =-=[-=-9] we discuss some of the subtle ways in which dierent abstract machines and implementations described in the literature dier from our model and each other. Bakewell and Runciman [2] focus on techniqu... |