Results 1 
5 of
5
Generic Program Transformation
 Proc. 3rd International Summer School on Advanced Functional Programming, LNCS 1608
, 1998
"... ion versus efficiency For concreteness, let us first examine a number of examples of the type of optimisation that we wish to capture, and the kind of programs on which they operate. This will give us a specific aim when developing the machinery for automating the process, and a yardstick for evalu ..."
Abstract

Cited by 32 (5 self)
 Add to MetaCart
(Show Context)
ion versus efficiency For concreteness, let us first examine a number of examples of the type of optimisation that we wish to capture, and the kind of programs on which they operate. This will give us a specific aim when developing the machinery for automating the process, and a yardstick for evaluating our results. 2.1 Minimum depth of a tree Consider the data type of leaf labelled binary trees: dataBtreea = Leaf a j Bin (Btree a)(Btree a) The minimum depth of such a tree is returned by the function mindepth :: Btree a ! Int : mindepth (Leaf a) = 0 mindepth (Bin s t) = min (mindepth s)(mindepth t) + 1 This program is clear, but rather inefficient. It traverses the whole tree, regardless of leaves that may occur at a small depth. A better program would keep track of the `minimum depth so far', and never explore subtrees beyond that current best solution. One possible implementation of that idea is mindepth t = md t 01 md (Leaf a)d m = mindm md (Bin s t)d m = if d 0 m then m...
Higherorder Matching for Program Transformation
, 1999
"... We present a simple, practical algorithm for higher order matching in the context of automatic program transformation. Our algorithm finds more matches than the standard second order matching algorithm of Huet and Lang, but it has an equally simple specification, and it is better suited to the tr ..."
Abstract

Cited by 17 (1 self)
 Add to MetaCart
We present a simple, practical algorithm for higher order matching in the context of automatic program transformation. Our algorithm finds more matches than the standard second order matching algorithm of Huet and Lang, but it has an equally simple specification, and it is better suited to the transformation of programs in modern programming languages such as Haskell or ML. The algorithm has been implemented as part of the MAG system for transforming functional programs. 1 Background and motivation 1.1 Program transformation Many program transformations are conveniently expressed as higher order rewrite rules. For example, consider the wellknown transformation that turns a tail recursive function into an imperative loop. The pattern f x = if p x then g x else f (h x ) is rewritten to the term f x = j[ var r ; r := x ; while :(p r) do r := h r ; r := g r ; return r ]j Carefully consider the pattern in this rule: it involves two bound variables, namely f and x , and ...
An Exercise in Polytypic Program Derivation: repmin
, 1996
"... A program derivation is said to be polytypic if some of its parameters are data types. The repmin problem is to replace all elements of a tree of numbers by the minimum element, making only a single pass over the original tree. Here we present a polytypic derivation for that problem. The derivation ..."
Abstract

Cited by 3 (0 self)
 Add to MetaCart
A program derivation is said to be polytypic if some of its parameters are data types. The repmin problem is to replace all elements of a tree of numbers by the minimum element, making only a single pass over the original tree. Here we present a polytypic derivation for that problem. The derivation has an unusual feature: when interpreted in the category of relations, the resulting program is the wellknown cyclic logic program, and when interpreted in the category of functions, it is the wellknown higherorder functional solution. 1 Motivation Suppose I were to show you a derivation of a shortest path algorithm, and my whole presentation was in terms of numbers, addition and minimum. Undoubtedly some of you would get up and point out that by abstracting over the operations and recording their algebraic properties, I could have derived a whole class of algorithms instead of one particular program. Indeed, such abstraction over operations is now commonly accepted as one of the hallmar...
HigherOrder Pattern Matching for Automatically Applying Fusion Transformations
, 2001
"... . We give an algorithm for higherorder pattern matching in the context of automatic program transformation. In particular, we show how accumulating parameter optimisations of functional programs can be automatically derived with the aid of some programmer annotations. 1 Background and motivation Co ..."
Abstract

Cited by 2 (0 self)
 Add to MetaCart
. We give an algorithm for higherorder pattern matching in the context of automatic program transformation. In particular, we show how accumulating parameter optimisations of functional programs can be automatically derived with the aid of some programmer annotations. 1 Background and motivation Consider the following program for calculating the minimum depth of a leaflabelled binary tree. The language we use is Haskell [2] but it could easily be rewritten in another functional language. data T ree = Leaf j Bin (T ree ) (T ree ) mindepth (Leaf x) = 0 mindepth (Bin s t) = 1 min (mindepth s) (mindepth t) The program is short, clearly stated, and it is easy to see that it will do what we intend. However, it is also not very ecient. Imagine a rightleaning tree
Higher Order Pattern Matching for Program Transformation
, 1999
"... Higher order matching allows program transformation systems to recognise complex patterns in programs and to use these patterns to apply useful transformations to these programs. We review existing algorithms, and in the attached paper "Higher order matching for program transformation" pre ..."
Abstract
 Add to MetaCart
Higher order matching allows program transformation systems to recognise complex patterns in programs and to use these patterns to apply useful transformations to these programs. We review existing algorithms, and in the attached paper "Higher order matching for program transformation" present a new algorithm known as "one step matching" which we believe offers significant benefits over existing algorithms. Practical use of this algorithm is made in the MAG system for transforming Haskell programs, described in the paper "Generic Program Transformation" which is also attached. Finally, we discuss possible future work to develop the use of pattern matching techniques in program transformation systems.