18 research outputs found
An exercise in transformational programming: Backtracking and Branch-and-Bound
We present a formal derivation of program schemes that are usually called Backtracking programs and Branch-and-Bound programs. The derivation consists of a series of transformation steps, specifically algebraic manipulations, on the initial specification until the desired programs are obtained. The well-known notions of linear recursion and tail recursion are extended, for structures, to elementwise linear recursion and elementwise tail recursion; and a transformation between them is derived too
A BMF FOR SEMANTICS
We show how the Bird-Meertens formalism (BMF) can be based on continuous algebras
such that finite and infinite datatypes may peacefully coexist. Until recently the theory
could only deal with either finite datatypes (= initial algebra) or infinite datatypes (=
final co-algebra). In the context of continuous algebras the initial algebra coincides with
the final co-algebra. Elements of this algebra can be finite, infinite or partial. We intend
to use EBMF for semantics directed compiler generation by combining initial algebra
semantics with the calculational power of BMF
Program Calculation Properties of Continuous Algebras
Defining data types as initial algebras, or dually as final co-algebras, is beneficial, if not indispensible, for an algebraic calculus for program construction, in view of the nice equational properties that then become available. It is not hard to render finite lists as an initial algebra and, dually, infinite lists as a final co-algebra. However, this would mean that there are two distinct data types for lists, and then a program that is applicable to both finite and infinite lists is not possible, and arbitrary recursive definitions are not allowed. We prove the existence of algebras that are both initial in one category of algebras and final in the closely related category of co-algebras, and for which arbitrary (continuous) fixed point definitions ("recursion") do have a solution. Thus there is a single data type that comprises both the finite and the infinite lists. The price to be paid, however, is that partiality (of functions and values) is unavoidable. \ud
We derive, for any such data type, various laws that are useful for an algebraic calculus of programs
Cheap deforestation for non-strict functional languages
In functional languages intermediate data structures are often used as glue to
connect separate parts of a program together. Deforestation is the process
of automatically removing intermediate data structures. In this thesis we
present and analyse a new approach to deforestation. This new approach is
both practical and general.
We analyse in detail the problem of list removal rather than the more general
problem of arbitrary data structure removal. This more limited scope allows
a complete evaluation of the pragmatic aspects of using our deforestation
technology.
We have implemented our list deforestation algorithm in the Glasgow Haskell
compiler. Our implementation has allowed practical feedback. One important
conclusion is that a new analysis is required to infer function arities
and the linearity of lambda abstractions. This analysis renders the basic
deforestation algorithm far more effective.
We give a detailed assessment of our implementation of deforestation. We
measure the effectiveness of our deforestation on a suite of real application
programs. We also observe the costs of our deforestation algorithm