Results 1  10
of
20
Playing by the rules: rewriting as a practical optimisation technique in GHC
"... We describe a facility for improving optimization of Haskell programs using rewrite rules. Library authors can use rules to express domainspecific optimizations that the compiler cannot discover for itself. The compiler can also generate rules internally to propagate information obtained from aut ..."
Abstract

Cited by 56 (9 self)
 Add to MetaCart
We describe a facility for improving optimization of Haskell programs using rewrite rules. Library authors can use rules to express domainspecific optimizations that the compiler cannot discover for itself. The compiler can also generate rules internally to propagate information obtained from automated analyses. The rewrite mechanism is fully implemented in the released Glasgow Haskell Compiler. Our system is very simple, but can be effective in optimizing real programs. We describe two practical applications involving shortcut deforestation, for lists and for rose trees, and document substantial performance improvements on a range of programs. 1 Introduction Optimising compilers perform program transformations that improve the efficiency of the program. However, a compiler can only use relatively shallow reasoning to guarantee the correctness of its optimisations. In contrast, the programmer has much deeper information about the program and its intended behaviour. For example, a programmer may know that
Algebra of logic programming
 International Conference on Logic Programming
, 1999
"... At present, the field of declarative programming is split into two main areas based on different formalisms; namely, functional programming, which is based on lambda calculus, and logic programming, which is based on firstorder logic. There are currently several language proposals for integrating th ..."
Abstract

Cited by 20 (3 self)
 Add to MetaCart
At present, the field of declarative programming is split into two main areas based on different formalisms; namely, functional programming, which is based on lambda calculus, and logic programming, which is based on firstorder logic. There are currently several language proposals for integrating the expressiveness of these two models of computation. In this thesis we work towards an integration of the methodology from the two research areas. To this end, we propose an algebraic approach to reasoning about logic programs, corresponding to the approach taken in functional programming. In the first half of the thesis we develop and discuss a framework which forms the basis for our algebraic analysis and transformation methods. The framework is based on an embedding of definite logic programs into lazy functional programs in Haskell, such that both the declarative and the operational semantics of the logic programs are preserved. In spite of its conciseness and apparent simplicity, the embedding proves to have many interesting properties and it gives rise to an algebraic semantics of logic programming. It also allows us to reason about logic programs in a simple calculational style, using rewriting and the algebraic laws of combinators. In the embedding, the meaning of a logic program arises compositionally from the meaning of its constituent subprograms and the combinators that connect them. In the second half of the thesis we explore applications of the embedding to the algebraic transformation of logic programs. A series of examples covers simple program derivations, where our techniques simplify some of the current techniques. Another set of examples explores applications of the more advanced program development techniques from the Algebra of Programming by Bird and de Moor [18], where we expand the techniques currently available for logic program derivation and optimisation. To my parents, Sandor and Erzsebet. And the end of all our exploring Will be to arrive where we started And know the place for the first time.
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 14 (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 ...
Strongly typed rewriting for coupled software transformation
 Proc. 7th Int. Workshop on RuleBased Programming (RULE 2006), ENTCS
, 2006
"... Coupled transformations occur in software evolution when multiple artifacts must be modified in such a way that they remain consistent with each other. An important example involves the coupled transformation of a data type, its instances, and the programs that consume or produce it. Previously, we ..."
Abstract

Cited by 12 (4 self)
 Add to MetaCart
Coupled transformations occur in software evolution when multiple artifacts must be modified in such a way that they remain consistent with each other. An important example involves the coupled transformation of a data type, its instances, and the programs that consume or produce it. Previously, we have provided a formal treatment of transformation of the first two: data types and instances. The treatment involved the construction of typesafe, typechanging strategic rewrite systems. In this paper, we extend our treatment to the transformation of corresponding data processing programs. The key insight underlying the extension is that both data migration functions and data processors can be represented typesafely by a generalized abstract data type (GADT). These representations are then subjected to program calculation rules, harnessed in typesafe, typepreserving strategic rewrite systems. For ease of calculation, we use pointfree representations and corresponding calculation rules. Thus, coupled transformations are carried out in two steps. First, a typechanging rewrite system is applied to a source type to obtain a target type together with (representations of) migration functions between source and target. Then, a typepreserving rewrite system is applied to the composition of a migration function and a data processor on the source (or target) type to obtain a data processor on the target (or source) type. All rewrites are typesafe. Key words: Program transformation, term rewriting, strategic programming, generalized abstract datatypes, data refinement.
T.: Tool support for the interactive derivation of formally correct functional programs
 In: Journal of Universal Computer Science. Volume
, 2003
"... Abstract: This paper describes the program transformation system Ultra. Theintended use of Ultra is to assist programmers in the formal derivation of correct and efficient programs from highlevel descriptive or operational specifications. We illustrate its utility by deriving a version of the Heaps ..."
Abstract

Cited by 5 (0 self)
 Add to MetaCart
Abstract: This paper describes the program transformation system Ultra. Theintended use of Ultra is to assist programmers in the formal derivation of correct and efficient programs from highlevel descriptive or operational specifications. We illustrate its utility by deriving a version of the Heapsort algorithm from a nondeterministic specification. Ultra supports equational reasoning about functional programs using defining equations, algebraic laws of underlying data structures, and transformation rules. The system does not only support modifying terms, but is also useful for bookkeeping and developmentnavigating tasks. The most salient features of Ultra are its sound theoretical foundation, its extendability, its flexible and convenient way to express transformation tasks, its comfortable user interface, and its lean and portable implementation. Ultra itself is written in the functional language Gofer.
HigherOrder Transformation of Logic Programs
 In Proceedings of the Tenth International Workshop on Logicbased Program Synthesis and Transformation (LOPSTR 2000
, 2000
"... It has earlier been assumed that a compositional approach to algorithm design and program transformation is somehow unique to functional programming. Elegant theoretical results codify the basic laws of algorithmics within the functional paradigm and with this paper we hope to demonstrate that s ..."
Abstract

Cited by 5 (1 self)
 Add to MetaCart
It has earlier been assumed that a compositional approach to algorithm design and program transformation is somehow unique to functional programming. Elegant theoretical results codify the basic laws of algorithmics within the functional paradigm and with this paper we hope to demonstrate that some of the same techniques and results are applicable to logic programming as well.
Program transformation by templates based on term rewriting
 In Proceedings of the 7th ACMSIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2005
, 2005
"... Huet and Lang (1978) presented a framework of automated program transformation based on lambda calculus in which programs are transformed according to a given program transformation template. They introduced a secondorder matching algorithm of simplytyped lambda calculus to verify whether the inpu ..."
Abstract

Cited by 4 (3 self)
 Add to MetaCart
Huet and Lang (1978) presented a framework of automated program transformation based on lambda calculus in which programs are transformed according to a given program transformation template. They introduced a secondorder matching algorithm of simplytyped lambda calculus to verify whether the input program matches the template. They also showed how to validate the correctness of the program transformation using the denotational semantics. We propose in this paper a framework of program transformation by templates based on term rewriting. In our new framework, programs are given by term rewriting systems. To automate our program transformation, we introduce a term pattern matching problem and present a sound and complete algorithm that solves this problem. We also discuss how to validate the correctness of program transformation in our framework. We introduce a notion of developed templates and a simple method to construct such templates without explicit use of induction. We then show that in any program transformation by developed templates the correctness of the transformation can be verified automatically. In our framework the correctness of the program transformation is discussed based on the operational semantics. This is a sharp contrast to Huet and Langâ€™s framework.
Calculation Carrying Programs  How to Code Program Transformations 
 In International Sumposium on Principles of Software Evolution (ISPSE 2000
, 2000
"... In this paper, we propose a new mechanism called calculation carrying programs that can relax the tension between efficiency and clarity in programming. The idea is to accompany clear programs with some calculation specifying the intention of how to manipulate the programs to be efficient. This calc ..."
Abstract

Cited by 2 (1 self)
 Add to MetaCart
In this paper, we propose a new mechanism called calculation carrying programs that can relax the tension between efficiency and clarity in programming. The idea is to accompany clear programs with some calculation specifying the intention of how to manipulate the programs to be efficient. This calculation specification can be executed automatically by our compiler to derive efficient programs. As a result, each calculation carrying program makes itself be a complete document including a concise specification of given problem as well as an effective way to derive both efficient and correct code. 1 Introduction Consider to write a program to check whether a list of numbers is steep. A list is said to be steep if each element of the list is greater than the average of the elements that follow it; a similar problem was discussed in [12]. A straightforward program to solve the problem is steep :: [Int] ! Bool steep [ ] = T rue steep (a : x) = (a ? average x) steep x average :: [Int]...
Deterministic Secondorder Patterns
, 2004
"... Secondorder patterns, together with secondorder matching, enable concise speci cation of program transformation, and have been implemented in several program transformation systems. However, secondorder matching in general is nondeterministic, and the matching algorithm is so expensive that the ..."
Abstract

Cited by 2 (0 self)
 Add to MetaCart
Secondorder patterns, together with secondorder matching, enable concise speci cation of program transformation, and have been implemented in several program transformation systems. However, secondorder matching in general is nondeterministic, and the matching algorithm is so expensive that the matching is NPcomplete. It is orthodox to impose constraints on the form of higherorder patterns so as to obtain the desirable matches satisfying certain properties such as decidability and niteness. In the context of uni cation, Miller's higherorder patterns have a single most general uni er. In this paper, we relax the restriction of his patterns without changing determinism in the context of matching instead of uni cation. As a consequence, our deterministic secondorder patterns cover a wide class of useful patterns for program transformation. The time complexity of our deterministic matching algorithm is linear in the size of a term for a xed pattern.