Results 1  10
of
13
Foundations for structured programming with GADTs
 Conference record of the ACM SIGPLANSIGACT Symposium on Principles of Programming Languages
, 2008
"... GADTs are at the cutting edge of functional programming and become more widely used every day. Nevertheless, the semantic foundations underlying GADTs are not well understood. In this paper we solve this problem by showing that the standard theory of data types as carriers of initial algebras of fun ..."
Abstract

Cited by 39 (5 self)
 Add to MetaCart
GADTs are at the cutting edge of functional programming and become more widely used every day. Nevertheless, the semantic foundations underlying GADTs are not well understood. In this paper we solve this problem by showing that the standard theory of data types as carriers of initial algebras of functors can be extended from algebraic and nested data types to GADTs. We then use this observation to derive an initial algebra semantics for GADTs, thus ensuring that all of the accumulated knowledge about initial algebras can be brought to bear on them. Next, we use our initial algebra semantics for GADTs to derive expressive and principled tools — analogous to the wellknown and widelyused ones for algebraic and nested data types — for reasoning about, programming with, and improving the performance of programs involving, GADTs; we christen such a collection of tools for a GADT an initial algebra package. Along the way, we give a constructive demonstration that every GADT can be reduced to one which uses only the equality GADT and existential quantification. Although other such reductions exist in the literature, ours is entirely local, is independent of any particular syntactic presentation of GADTs, and can be implemented in the host language, rather than existing solely as a metatheoretical artifact. The main technical ideas underlying our approach are (i) to modify the notion of a higherorder functor so that GADTs can be seen as carriers of initial algebras of higherorder functors, and (ii) to use left Kan extensions to trade arbitrary GADTs for simplerbutequivalent ones for which initial algebra semantics can be derived.
Fibrational Induction Rules for Initial Algebras ⋆
"... Abstract. This paper provides an induction rule that can be used to prove properties of data structures whose types are inductive, i.e., are carriers of initial algebras of functors. Our results are semantic in nature and are inspired by Hermida and Jacobs ’ elegant algebraic formulation of inductio ..."
Abstract

Cited by 6 (1 self)
 Add to MetaCart
Abstract. This paper provides an induction rule that can be used to prove properties of data structures whose types are inductive, i.e., are carriers of initial algebras of functors. Our results are semantic in nature and are inspired by Hermida and Jacobs ’ elegant algebraic formulation of induction for polynomial data types. Our contribution is to derive, under slightly different assumptions, an induction rule that is generic over all inductive types, polynomial or not. Our induction rule is generic over the kinds of properties to be proved as well: like Hermida and Jacobs, we work in a general fibrational setting and so can accommodate very general notions of properties on inductive types rather than just those of particular syntactic forms. We establish the correctness of our generic induction rule by reducing induction to iteration. We show how our rule can be instantiated to give induction rules for the data types of rose trees, finite hereditary sets, and hyperfunctions. The former lies outside the scope of Hermida and Jacobs ’ work because it is not polynomial; as far as we are aware, no induction rules have been known to exist for the latter two in a general fibrational framework. Our instantiation for hyperfunctions underscores the value of working in the general fibrational setting since this data type cannot be interpreted as a set. 1
Initial Algebra Semantics for Cyclic Sharing Structures
"... Abstract. Terms are a concise representation of tree structures. Since they can be naturally defined by an inductive type, they offer data structures in functional programming and mechanised reasoning with useful principles such as structural induction and structural recursion. In the case of graphs ..."
Abstract

Cited by 4 (1 self)
 Add to MetaCart
(Show Context)
Abstract. Terms are a concise representation of tree structures. Since they can be naturally defined by an inductive type, they offer data structures in functional programming and mechanised reasoning with useful principles such as structural induction and structural recursion. In the case of graphs or ”treelike ” structures – trees involving cycles and sharing – however, it is not clear what kind of inductive structures exists and how we can faithfully assign a term representation of them. In this paper we propose a simple term syntax for cyclic sharing structures that admits structural induction and recursion principles. We show that the obtained syntax is directly usable in the functional language Haskell, as well as ordinary data structures such as lists and trees. To achieve this goal, we use categorical approach to initial algebra semantics in a presheaf category. That approach follows the line of Fiore, Plotkin and Turi’s models of abstract syntax with variable binding. 1
C.: Generic fibrational induction
 Log. Meth. Comput. Sci
, 2012
"... Abstract. This paper provides an induction rule that can be used to prove properties of data structures whose types are inductive, i.e., are carriers of initial algebras of functors. Our results are semantic in nature and are inspired by Hermida and Jacobs ’ elegant algebraic formulation of inducti ..."
Abstract

Cited by 4 (2 self)
 Add to MetaCart
Abstract. This paper provides an induction rule that can be used to prove properties of data structures whose types are inductive, i.e., are carriers of initial algebras of functors. Our results are semantic in nature and are inspired by Hermida and Jacobs ’ elegant algebraic formulation of induction for polynomial data types. Our contribution is to derive, under slightly different assumptions, a sound induction rule that is generic over all inductive types, polynomial or not. Our induction rule is generic over the kinds of properties to be proved as well: like Hermida and Jacobs, we work in a general fibrational setting and so can accommodate very general notions of properties on inductive types rather than just those of a particular syntactic form. We establish the soundness of our generic induction rule by reducing induction to iteration. We then show how our generic induction rule can be instantiated to give induction rules for the data types of rose trees, finite hereditary sets, and hyperfunctions. The first of these lies outside the scope of Hermida and Jacobs’ work because it is not polynomial, and as far as we are aware, no induction rules have been known to exist for the second and third in a general fibrational framework. Our instantiation for hyperfunctions underscores the value of working in the general fibrational setting since this data type cannot be interpreted as a set. 1.
Algebraic Specialization of Generic Functions for Recursive Types
"... Defining functions over large, possibly recursive, data structures usually involves a lot of boilerplate. This code simply traverses noninteresting parts of the data, and rapidly becomes a maintainability problem. Many generic programming libraries have been proposed to address this issue. Most of ..."
Abstract

Cited by 3 (3 self)
 Add to MetaCart
Defining functions over large, possibly recursive, data structures usually involves a lot of boilerplate. This code simply traverses noninteresting parts of the data, and rapidly becomes a maintainability problem. Many generic programming libraries have been proposed to address this issue. Most of them allow the user to specify the behavior just for the interesting bits of the structure, and provide traversal combinators to “scrap the boilerplate”. The expressive power of these libraries usually comes at the cost of efficiency, since runtime checks are used to detect where to apply the typespecific behavior. In previous work we have developed an effective rewrite system for specialization and optimization of generic programs. In this paper we extend it to also cover recursive data types. The key idea is to specialize traversal combinators using wellknown recursion patterns, such as folds or paramorphisms. These are ruled by a rich set of algebraic laws that enable aggressive optimizations. We present a typesafe encoding of this rewrite system in Haskell, based on recent language extensions such as typeindexed type families. Keywords:
Recursion on nested datatypes in dependent type theory
 Logic and Theory of Algorithms. Volume 5028 of Lecture Notes in Computer Science
, 2008
"... Abstract. Nested datatypes are families of datatypes that are indexed over all types and where the datatype constructors relate different members of the family. This may be used to represent variable binding or to maintain certain invariants through typing. In dependent type theory, a major concern ..."
Abstract

Cited by 3 (1 self)
 Add to MetaCart
(Show Context)
Abstract. Nested datatypes are families of datatypes that are indexed over all types and where the datatype constructors relate different members of the family. This may be used to represent variable binding or to maintain certain invariants through typing. In dependent type theory, a major concern is the termination of all expressible programs, so that types that depend on object terms can still be typechecked mechanically. Therefore, we study iteration and recursion schemes that have this termination guarantee throughout. This is not based on syntactic criteria (recursive calls with “smaller ” arguments) but just on types (“typebased termination”). An important concern are reasoning principles that are compatible with the ambient type theory, in our case induction principles. In previous work, the author has proposed an abstract description of nested datatypes together with a mapping operation (like map for lists) and an iterator on the term side and an induction principle on the logical side that could all be implemented within the Coq system (with impredicative Set that is just needed for the justification, not for the definition and the examples). For verification purposes, it is important to have naturality theorems for the obtained iterative functions. Although intensional type theory does not provide naturality in general, criteria for naturality could be established that are met in case studies on “bushes” and representations of lambda terms (also with explicit flattening). The new contribution is an extension of this abstract description to full primitive recursion and its illustration by way of examples that have been carried out in Coq. Unlike the iterative system, we do not yet have a justification within Coq. 1
Monadic Fold, Monadic Build, Monadic Short Cut Fusion
"... Short cut fusion improves the efficiency of modularly constructed programs by eliminating intermediate data structures produced by one program component and immediately consumed by another. We define a combinator which expresses uniform production of data structures in monadic contexts, and is the n ..."
Abstract

Cited by 1 (0 self)
 Add to MetaCart
(Show Context)
Short cut fusion improves the efficiency of modularly constructed programs by eliminating intermediate data structures produced by one program component and immediately consumed by another. We define a combinator which expresses uniform production of data structures in monadic contexts, and is the natural counterpart to the wellknown monadic fold which consumes them. Like the monadic fold, our new combinator quantifies over monadic algebras rather than standard ones. Together with the monadic fold, it gives rise to a new short cut fusion rule for eliminating intermediate data structures in monadic contexts. This new rule differs significantly from previous short cut fusion rules, all of which are based on combinators which quantify over standard, rather than monadic, algebras. We give examples illustrating the benefits of quantifying over monadic algebras, prove our new fusion rule correct, and show how it can improve programs. We also consider its coalgebraic dual. 1 THE PROBLEM Consider the following variation on the wellknown problem of fusing modular
Theoretical Foundations for Practical ‘Totally Functional Programming’
, 2007
"... Interpretation is an implicit part of today’s programming; it has great power but is overused and has
significant costs. For example, interpreters are typically significantly hard to understand and hard
to reason about. The methodology of “Totally Functional Programming” (TFP) is a reasoned
attempt ..."
Abstract
 Add to MetaCart
Interpretation is an implicit part of today’s programming; it has great power but is overused and has
significant costs. For example, interpreters are typically significantly hard to understand and hard
to reason about. The methodology of “Totally Functional Programming” (TFP) is a reasoned
attempt to redress the problem of interpretation. It incorporates an awareness of the undesirability
of interpretation with observations that definitions and a certain style of programming appear to
offer alternatives to it. Application of TFP is expected to lead to a number of significant outcomes,
theoretical as well as practical. Primary among these are novel programming languages to lessen or
eliminate the use of interpretation in programming, leading to betterquality software. However,
TFP contains a number of lacunae in its current formulation, which hinder development of these
outcomes. Among others, formal semantics and typesystems for TFP languages are yet to be
discovered, the means to reduce interpretation in programs is to be determined, and a detailed
explication is needed of interpretation, definition, and the differences between the two. Most
important of all however is the need to develop a complete understanding of the nature of
interpretation. In this work, suitable typesystems for TFP languages are identified, and guidance
given regarding the construction of appropriate formal semantics. Techniques, based around the
‘fold’ operator, are identified and developed for modifying programs so as to reduce the amount of
interpretation they contain. Interpretation as a means of languageextension is also investigated.
v
Finally, the nature of interpretation is considered. Numerous hypotheses relating to it considered in
detail. Combining the results of those analyses with discoveries from elsewhere in this work leads
to the proposal that interpretation is not, in fact, symbolbased computation, but is in fact something
more fundamental: computation that varies with input. We discuss in detail various implications of
this characterisation, including its practical application. An often moreuseful property, ‘inherent
interpretiveness’, is also motivated and discussed in depth. Overall, our inquiries act to give
conceptual and theoretical foundations for practical TFP.
Theory and Applications of Induction Recursion Case for Support
"... at the University of Strathclyde and asked to form the Mathematically Structured Programming research group there. Research Summary: Prof. Ghani’s research tries to understand the nature and structure of computation. This is quite a bold statement and inevitably, only partial answers will be forthco ..."
Abstract
 Add to MetaCart
at the University of Strathclyde and asked to form the Mathematically Structured Programming research group there. Research Summary: Prof. Ghani’s research tries to understand the nature and structure of computation. This is quite a bold statement and inevitably, only partial answers will be forthcoming. Nevertheless, this statement shows his commitment to ask deep and fundamental questions so as to produce research which is of the highest calibre and which will stand the test of time rather than become obsolete within a few years. In particular, he has worked extensively in the following areas which form the pillars upon which this proposal is built. – Category Theory: Category theory is a relatively new mathematical discipline which provides an abstract theory of structure and hence is key to Prof. Ghani’s work. He has applied various categorical structures such as monads, comonads, coalgebras, enriched categories and Kan extensions to problems in computation. Of closest relevance to this proposal is his work on containers which provides a theory of concrete data types. – Type Theory: Prof. Ghani uses type theory as an intermediate abstraction between functional programming and its categorical underpinnings. He has worked on features such as type systems, pattern matching and explicit substitutions which make the lambdacalculus closer to “real ” functional languages. He also developed the subject of etaexpansions and showed it to be better behaved than the more traditional theory of etacontractions. He solved the long standing open problem of the decidability of betaetaequality for sum types which had attracted