4,047 research outputs found

    Foundations for structured programming with GADTs

    Get PDF
    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

    A principled approach to programming with nested types in Haskell

    Get PDF
    Initial algebra semantics is one of the cornerstones of the theory of modern functional programming languages. For each inductive data type, it provides a Church encoding for that type, a build combinator which constructs data of that type, a fold combinator which encapsulates structured recursion over data of that type, and a fold/build rule which optimises modular programs by eliminating from them data constructed using the buildcombinator, and immediately consumed using the foldcombinator, for that type. It has long been thought that initial algebra semantics is not expressive enough to provide a similar foundation for programming with nested types in Haskell. Specifically, the standard folds derived from initial algebra semantics have been considered too weak to capture commonly occurring patterns of recursion over data of nested types in Haskell, and no build combinators or fold/build rules have until now been defined for nested types. This paper shows that standard folds are, in fact, sufficiently expressive for programming with nested types in Haskell. It also defines buildcombinators and fold/build fusion rules for nested types. It thus shows how initial algebra semantics provides a principled, expressive, and elegant foundation for programming with nested types in Haskell

    Dependent Inductive and Coinductive Types are Fibrational Dialgebras

    Get PDF
    In this paper, I establish the categorical structure necessary to interpret dependent inductive and coinductive types. It is well-known that dependent type theories \`a la Martin-L\"of can be interpreted using fibrations. Modern theorem provers, however, are based on more sophisticated type systems that allow the definition of powerful inductive dependent types (known as inductive families) and, somewhat limited, coinductive dependent types. I define a class of functors on fibrations and show how data type definitions correspond to initial and final dialgebras for these functors. This description is also a proposal of how coinductive types should be treated in type theories, as they appear here simply as dual of inductive types. Finally, I show how dependent data types correspond to algebras and coalgebras, and give the correspondence to dependent polynomial functors.Comment: In Proceedings FICS 2015, arXiv:1509.0282

    Classical Control, Quantum Circuits and Linear Logic in Enriched Category Theory

    Full text link
    We describe categorical models of a circuit-based (quantum) functional programming language. We show that enriched categories play a crucial role. Following earlier work on QWire by Paykin et al., we consider both a simple first-order linear language for circuits, and a more powerful host language, such that the circuit language is embedded inside the host language. Our categorical semantics for the host language is standard, and involves cartesian closed categories and monads. We interpret the circuit language not in an ordinary category, but in a category that is enriched in the host category. We show that this structure is also related to linear/non-linear models. As an extended example, we recall an earlier result that the category of W*-algebras is dcpo-enriched, and we use this model to extend the circuit language with some recursive types

    Functorial Coalgebraic Logic: The Case of Many-Sorted Varieties

    Get PDF
    Following earlier work, a modal logic for T-coalgebras is a functor L on a suitable variety. Syntax and proof system of the logic are given by presentations of the functor. This paper makes two contributions. First, a previous result characterizing those functors that have presentations is generalized from endofunctors on one-sorted varieties to functors between many-sorted varieties. This yields an equational logic for the presheaf semantics of higher-order abstract syntax. As another application, we show how the move to functors between many-sorted varieties allows to modularly combine syntax and proof systems of different logics. Second, we show how to associate to any set-functor T a complete (finitary) logic L consisting of modal operators and Boolean connectives

    Semantic values in higher-order semantics

    Get PDF
    Recently, some philosophers have argued that we should take quantification of any (finite) order to be a legitimate and irreducible, sui generis kind of quantification. In particular, they hold that a semantic theory for higher-order quantification must itself be couched in higher-order terms. Øystein Linnebo has criticized such views on the grounds that they are committed to general claims about the semantic values of expressions that are by their own lights inexpressible. I show that Linnebo's objection rests on the assumption of a notion of semantic value or contribution which both applies to expressions of any order, and picks out, for each expression, an extra-linguistic correlate of that expression. I go on to argue that higher-orderists can plausibly reject this assumption, by means of a hierarchy of notions they can use to describe the extra-lingustic correlates of expressions of different orders

    The Syntax of Coherence

    Full text link
    This article tackles categorical coherence within a two-dimensional generalization of Lawvere's functorial semantics. 2-theories, a syntactical way of describing categories with structure, are presented. From the perspective here afforded, many coherence results become simple statements about the quasi-Yoneda lemma and 2-theory-morphisms. Given two 2-theories and a 2-theory-morphism between them, we explore the induced relationship between the corresponding 2-categories of algebras. The strength of the induced quasi-adjoints are classified by the strength of the 2-theory-morphism. These quasi-adjoints reflect the extent to which one structure can be replaced by another. A two-dimensional analogue of the Kronecker product is defined and constructed. This operation allows one to generate new coherence laws from old ones.Comment: 44 pages, LaTeX; XY-Pic (with 2-cells). Corrected typos and small change
    corecore