162 research outputs found
Foundations for structured programming with GADTs
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 well-known and widely-used 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 higher-order functor so that GADTs can be seen as carriers of initial algebras of higher-order functors, and (ii) to use left Kan extensions to trade arbitrary GADTs for simpler-but-equivalent ones for which initial algebra semantics can be derive
Indexed Induction and Coinduction, Fibrationally
This paper extends the fibrational approach to induction and coinduction
pioneered by Hermida and Jacobs, and developed by the current authors, in two
key directions. First, we present a dual to the sound induction rule for
inductive types that we developed previously. That is, we present a sound
coinduction rule for any data type arising as the carrier of the final
coalgebra of a functor, thus relaxing Hermida and Jacobs' restriction to
polynomial functors. To achieve this we introduce the notion of a quotient
category with equality (QCE) that i) abstracts the standard notion of a
fibration of relations constructed from a given fibration; and ii) plays a role
in the theory of coinduction dual to that played by a comprehension category
with unit (CCU) in the theory of induction. Secondly, we show that inductive
and coinductive indexed types also admit sound induction and coinduction rules.
Indexed data types often arise as carriers of initial algebras and final
coalgebras of functors on slice categories, so we give sufficient conditions
under which we can construct, from a CCU (QCE) U:E \rightarrow B, a fibration
with base B/I that models indexing by I and is also a CCU (resp., QCE). We
finish the paper by considering the more general case of sound induction and
coinduction rules for indexed data types when the indexing is itself given by a
fibration
String rewriting for Double Coset Systems
In this paper we show how string rewriting methods can be applied to give a
new method of computing double cosets. Previous methods for double cosets were
enumerative and thus restricted to finite examples. Our rewriting methods do
not suffer this restriction and we present some examples of infinite double
coset systems which can now easily be solved using our approach. Even when both
enumerative and rewriting techniques are present, our rewriting methods will be
competitive because they i) do not require the preliminary calculation of
cosets; and ii) as with single coset problems, there are many examples for
which rewriting is more effective than enumeration.
Automata provide the means for identifying expressions for normal forms in
infinite situations and we show how they may be constructed in this setting.
Further, related results on logged string rewriting for monoid presentations
are exploited to show how witnesses for the computations can be provided and
how information about the subgroups and the relations between them can be
extracted. Finally, we discuss how the double coset problem is a special case
of the problem of computing induced actions of categories which demonstrates
that our rewriting methods are applicable to a much wider class of problems
than just the double coset problem.Comment: accepted for publication by the Journal of Symbolic Computatio
Representations of stream processors using nested fixed points
We define representations of continuous functions on infinite streams of discrete values, both in the case of discrete-valued functions, and in the case of stream-valued functions. We define also an operation on the representations of two continuous functions between streams that yields a representation of their composite. In the case of discrete-valued functions, the representatives are well-founded (finite-path) trees of a certain kind. The underlying idea can be traced back to Brouwer's justification of bar-induction, or to Kreisel and Troelstra's elimination of choice-sequences. In the case of stream-valued functions, the representatives are non-wellfounded trees pieced together in a coinductive fashion from well-founded trees. The definition requires an alternating fixpoint construction of some ubiquity
Comprehensive parametric polymorphism : categorical models and type theory
This paper combines reflexive-graph-category structure for relational parametricity with fibrational models of impredicative polymorphism. To achieve this, we modify the definition of fibrational model of impredicative polymorphism by adding one further ingredient to the structure: comprehension in the sense of Lawvere. Our main result is that such comprehensive models, once further endowed with reflexive-graph-category structure, enjoy the expected consequences of parametricity. This is proved using a type-theoretic presentation of the category-theoretic structure, within which the desired consequences of parametricity are derived. The formalisation requires new techniques because equality relations are not available, and standard arguments that exploit equality need to be reworked
Proof-relevant parametricity
Parametricity is one of the foundational principles which underpin our understanding of modern programming languages. Roughly speaking, parametricity expresses the hidden invariants that programs satisfy by formalising the intuition that programs map related inputs to related outputs. Traditionally parametricity is formulated with proofirrelevant relations but programming in Type Theory requires an extension to proof-relevant relations. But then one might ask: can our proofs that polymorphic functions are parametric be parametric themselves? This paper shows how this can be done and, excitingly, our answer requires a trip into the world of higher dimensional parametricity
Modularity and implementation of mathematical operational semantics
Structural operational semantics is a popular technique for specifying the meaning of programs by means of inductive clauses. One seeks syntactic restrictions on those clauses so that the resulting operational semantics is well-behaved. This approach is simple and concrete but it has some drawbacks. Turi pioneered a more abstract categorical treatment based upon the idea that operational semantics is essentially a distribution of syntax over behaviour. In this article we take Turi's approach in two new directions. Firstly, we show how to write operational semantics as modular components and how to combine such components to specify complete languages. Secondly, we show how the categorical nature of Turi's operational semantics makes it ideal for implementation in a functional programming language such as Haskell
Variations on Inductive-Recursive Definitions
Dybjer and Setzer introduced the definitional principle of inductive-recursively defined families - i.e. of families (U : Set, T : U -> D) such that the inductive definition of U may depend on the recursively defined T --- by defining a type DS D E of codes. Each c : DS D E defines a functor [c] : Fam D -> Fam E, and
(U, T) = mu [c] : Fam D is exhibited as the initial algebra of [c].
This paper considers the composition of DS-definable functors: Given F : Fam C -> Fam D and G : Fam D -> Fam E, is G circ F : Fam C -> Fam E DS-definable, if F and G are? We show that this is the case if and only if powers of families are DS-definable, which seems unlikely. To construct composition, we present two new systems UF and PN of codes for inductive-recursive definitions, with UF a subsytem of DS a subsystem of PN. Both UF and PN are closed under composition. Since PN defines a potentially larger class of functors, we show that there is a model where initial algebras of PN-functors exist by adapting Dybjer-Setzer\u27s proof for DS
Generic Fibrational Induction
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.Comment: For Special Issue from CSL 201
Bifibrational functorial semantics of parametric polymorphism
Reynolds' theory of parametric polymorphism captures the invariance of polymorphically typed programs under change of data representation. Semantically, reflexive graph categories and fibrations are both known to give a categorical understanding of parametric polymorphism. This paper contributes further to this categorical perspective by showing the relevance of bifibrations. We develop a bifibrational framework for models of System F that are parametric, in that they verify the Identity Extension Lemma and Reynolds' Abstraction Theorem. We also prove that our models satisfy expected properties, such as the existence of initial algebras and final coalgebras, and that parametricity implies dinaturality
- …