## Positive Supercompilation for a higher order call-by-value language (2007)

Venue: | In Proc. IFL 2007 |

Citations: | 14 - 1 self |

### BibTeX

@INPROCEEDINGS{Jonsson07positivesupercompilation,

author = {Peter A. Jonsson and Johan Nordl},

title = {Positive Supercompilation for a higher order call-by-value language},

booktitle = {In Proc. IFL 2007},

year = {2007}

}

### OpenURL

### Abstract

Abstract. Previous deforestation and supercompilation algorithms may introduce termination when applied to call-by-value programs. This hides looping bugs from the programmer, and changes the behaviour of a program depending on whether it is optimized or not. We present a supercompilation algorithm for a higher-order call-by-value language that preserves termination properties. This algorithm utilizes strictness information for deciding whether to substitute or not and compares favorably with previous call-by-name transformations. 1

### Citations

400 | Deforestation: Transforming programs to eliminate trees
- Wadler
- 1990
(Show Context)
Citation Context ...ists in functional programs allow the programmer to write clear and concise programs, but carry a cost at run time since list cells need to be both allocated and garbage collected. Both deforestation =-=[19]-=- and supercompilation [14] are automatic program transformations that remove many of these intermediate structures. In a call-by-value context these transformations are unsound, and might hide looping... |

218 |
Unification revisited
- Lassez, Maher, et al.
- 1986
(Show Context)
Citation Context ... θ ′ 2) of e and f it holds that tg is an instance of t ′ g. We refer to tg as the ground term. For background infromation and an algorithm to compute most specific generalizations, see Lassez et. al =-=[5]-=-. An example of the homeomorphic embedding and the msg is: e f tg θ1 θ2 e � Just e x [e/x] [Just e/x] Right e � Right (e, e ′ ) Right x [e/x] [(e, e ′ )/x] fac y � fac (y − 1) fac x [y/x] [(y − 1)/x]s... |

179 | Lambda lifting: transforming programs to recursive equations
- Johnsson
- 1985
(Show Context)
Citation Context ...t-hand sides are all values. Recursion is only allowed at the top level but this restriction is not particularly burdensome – if a local function needs to be recursive, it can always be lambda-lifted =-=[3]-=- to the top level. The language contains integer values n and arithmetic operations ⊕, although these meta-variables can preferably be understood as ranging over primitive values in general and arbitr... |

168 | The concept of a supercompiler
- Turchin
- 1986
(Show Context)
Citation Context ...of it is however in a call-by-name or call-by-need context which makes it a different, yet difficult, problem. 8.1 Transformations for Strict Languages The seminal work by Turchin on Supercompilation =-=[17]-=- is closely related to our work. The supercompiler was originally intended for the strict functional language Refal [18]. The supercompiler could therefore introduce termination in Refal programs, the... |

78 | A Positive Supercompiler
- Sørensen, Glück, et al.
- 1996
(Show Context)
Citation Context ...text is a lazy language, many of their insights apply to our work as well. Secher and Sørensen later refined this work to propagate both negative and positive information in the perfect supercompiler =-=[12]-=-.s9 Conclusion We have presented a positive supercompiler for a higher-order call-by-value language. It is proven correct for all input. The adjustment to the algorithm for preserving call-by-value se... |

73 | The nofib Benchmark Suite of Haskell Programs
- Partain
- 1992
(Show Context)
Citation Context ...and that benefits from this extra information propagation. It turns out that this information is useful for real programs as well. An example collected from Conway’s Life in the nofib benchmark suite =-=[9]-=- is the expression concat (map star xs) with star defined as: star n = case n of {0 → ′′ ′′ ; 1 → ′′ o ′′ } Evaluating D� concat (map star xs)� results in the function h ′ 1 xs: h ′ 1 (x : xs) = case ... |

73 | An algorithm of generalization in positive supercompilation
- Sørensen, Glück
- 1995
(Show Context)
Citation Context ...e e0, e1, . . . there exists i and j such that i < j and ei � ej. This condition is sufficient to ensure termination. We need a definition of uniform terms analogous to the work by Sørensen and Glück =-=[13]-=-, with some small adjustments specific to our language. Definition 1 (Uniform terms). Let s range over a the set G ∪ X ∪ K ∪ {caseof, letin}, and let caseof(e) (letin(e)) denote a case (let) expressio... |

31 | Proving the correctness of recursion-based automatic program transformations
- Sands
- 1996
(Show Context)
Citation Context ...so does evaluation of C[e’]. – e is operationally equivalent to e’, e ∼ = e ′ , if e⊏ � e ′ and e ′ ⊏ � e The correctness of deforestation in a call-by-name setting has previously been shown by Sands =-=[10]-=- using his improvement theory. Notice that improvement � below is not the same as the homeomorphic embedding � defined previuosly. We use Sands’s definitions for improvement and strong improvement:sDe... |

19 | P.: Deforestation for higher-order functions
- Marlow, Wadler
- 1992
(Show Context)
Citation Context ...orithm will bring out Wadler’s deforestation algorithm [19] for a first order language as the start for deforestation research. This was later extended to a higher-order language by Marlow and Wadler =-=[6]-=-. Refinements to this was made by Marlow [7] and Hamilton [1, 2]. Work by Sørensen et. al. on the positive supercompiler [14] deserves a special mention. Their work clearly explains the difference bet... |

17 | Higher order deforestation
- Hamilton
- 1996
(Show Context)
Citation Context ...or a first order language as the start for deforestation research. This was later extended to a higher-order language by Marlow and Wadler [6]. Refinements to this was made by Marlow [7] and Hamilton =-=[1, 2]-=-. Work by Sørensen et. al. on the positive supercompiler [14] deserves a special mention. Their work clearly explains the difference between deforestation and supercompilation, giving lots of illustra... |

17 | Deforestation for Higher-Order Functional Programs
- Marlow
- 1996
(Show Context)
Citation Context ... algorithm [19] for a first order language as the start for deforestation research. This was later extended to a higher-order language by Marlow and Wadler [6]. Refinements to this was made by Marlow =-=[7]-=- and Hamilton [1, 2]. Work by Sørensen et. al. on the positive supercompiler [14] deserves a special mention. Their work clearly explains the difference between deforestation and supercompilation, giv... |

17 | From SOS rules to proof principles: An operational metatheory for functional languages
- Sands
- 1997
(Show Context)
Citation Context ...orem 1 (Sands). If e �s e ′ , a transformation that replaces e by e’ is totally correct. Improvement theory in a call-by-value setting requires Sands’s operational metatheory for functional languages =-=[11]-=-, where the improvement theory is a simple corollary of improvement induction over the well fonded resource structure 〈N, 0, +, ≥〉. Our set G corresponds to Sands’s global recursive constants. We ther... |

11 | Convergence of Program Transformers in the Metric Space of Trees. Lecture
- Sørensen
(Show Context)
Citation Context ... termination. When the whistle blows, we split our expression into several strictly smaller expressions that are driven in the empty context. Termination can be proved using the framework by Sørensen =-=[16]-=-. Our proof is similar in structure to Sørensen’s termination proof for supercompilation [16]. It is however simpler since we avoid partitioning nodes into trivial and non-trivial nodes and use a sing... |

6 |
Lightweight fusion by fixed point promotion
- Ohori, Sasano
- 2007
(Show Context)
Citation Context ...reated. If the expression sum (map square xs) or a renaming thereof is detected elsewhere in the input, a call to h0 will be inserted there instead. The following examples are due to Ohori and Sasano =-=[8]-=-. We need the following new function definitions:smapsq xs = case xs of { [] → []; (x ′ : xs ′ ) → (x ′ ∗ x ′ ) : (mapsq xs ′ ) } f xs = case xs of { [] → []; (x ′ : xs ′ ) → (2 ∗ x ′ ) : (g xs ′ ) g ... |

5 |
Programming Guide & Reference Manual
- Turchin
- 1989
(Show Context)
Citation Context ...formations for Strict Languages The seminal work by Turchin on Supercompilation [17] is closely related to our work. The supercompiler was originally intended for the strict functional language Refal =-=[18]-=-. The supercompiler could therefore introduce termination in Refal programs, the problem we set out to solve with our work. More recently Ohori and Sasano presented a lightweight fusion algorihtm [8],... |

4 |
Deforestation of a raytracer
- Kort
- 1996
(Show Context)
Citation Context ...when reaching it. Adding it all together gives a new function h2: h2 xs = case xs of [] → 0 (x ′ : xs ′ ) → case xs ′ of [] → (2 ∗ x ′ ) + 0 (x ′′ : xs ′′ ) → (2 ∗ x ′ ) + (3 ∗ x ′′ ) + h2 xs ′′ Kort =-=[4]-=- studied a ray-tracer written in Haskell, and identified a critical function in the innermost loop of a matrix multiplication, called vecDot: vecDot xs ys = sum (zipWith (∗) xs ys) This is simplified ... |