38 research outputs found

    When is a container a comonad?

    Full text link
    Abbott, Altenkirch, Ghani and others have taught us that many parameterized datatypes (set functors) can be usefully analyzed via container representations in terms of a set of shapes and a set of positions in each shape. This paper builds on the observation that datatypes often carry additional structure that containers alone do not account for. We introduce directed containers to capture the common situation where every position in a data-structure determines another data-structure, informally, the sub-data-structure rooted by that position. Some natural examples are non-empty lists and node-labelled trees, and data-structures with a designated position (zippers). While containers denote set functors via a fully-faithful functor, directed containers interpret fully-faithfully into comonads. But more is true: every comonad whose underlying functor is a container is represented by a directed container. In fact, directed containers are the same as containers that are comonads. We also describe some constructions of directed containers. We have formalized our development in the dependently typed programming language Agda

    When is a container a comonad?

    Full text link

    Directed Containers as Categories

    Get PDF
    Directed containers make explicit the additional structure of those containers whose set functor interpretation carries a comonad structure. The data and laws of a directed container resemble those of a monoid, while the data and laws of a directed container morphism those of a monoid morphism in the reverse direction. With some reorganization, a directed container is the same as a small category, but a directed container morphism is opcleavage-like. We draw some conclusions for comonads from this observation, considering in particular basic constructions and concepts like the opposite category and a groupoid.Comment: In Proceedings MSFP 2016, arXiv:1604.0038

    Decomposing Comonad Morphisms

    Get PDF
    The analysis of set comonads whose underlying functor is a container functor in terms of directed containers makes it a simple observation that any morphism between two such comonads factors through a third one by two comonad morphisms, whereof the first is identity on shapes and the second is identity on positions in every shape. This observation turns out to generalize into a much more involved result about comonad morphisms to comonads whose underlying functor preserves Cartesian natural transformations to itself on any category with finite limits. The bijection between comonad coalgebras and comonad morphisms from costate comonads thus also yields a decomposition of comonad coalgebras

    A Representation Theorem for Second-Order Functionals

    Get PDF
    Representation theorems relate seemingly complex objects to concrete, more tractable ones. In this paper, we take advantage of the abstraction power of category theory and provide a general representation theorem for a wide class of second-order functionals which are polymorphic over a class of functors. Types polymorphic over a class of functors are easily representable in languages such as Haskell, but are difficult to analyse and reason about. The concrete representation provided by the theorem is easier to analyse, but it might not be as convenient to implement. Therefore, depending on the task at hand, the change of representation may prove valuable in one direction or the other. We showcase the usefulness of the representation theorem with a range of examples. Concretely, we show how the representation theorem can be used to show that traversable functors are finitary containers, how parameterised coalgebras relate to very well-behaved lenses, and how algebraic effects might be implemented in a functional language

    A categorical framework for the quantum harmonic oscillator

    Full text link
    This paper describes how the structure of the state space of the quantum harmonic oscillator can be described by an adjunction of categories, that encodes the raising and lowering operators into a commutative comonoid. The formulation is an entirely general one in which Hilbert spaces play no special role. Generalised coherent states arise through the hom-set isomorphisms defining the adjunction, and we prove that they are eigenstates of the lowering operators. Surprisingly, generalised exponentials also emerge naturally in this setting, and we demonstrate that coherent states are produced by the exponential of a raising morphism acting on the zero-particle state. Finally, we examine all of these constructions in a suitable category of Hilbert spaces, and find that they reproduce the conventional mathematical structures.Comment: 44 pages, many figure

    Coalgebraic Update Lenses

    Get PDF
    AbstractLenses are mathematical structures used in the context of bidirectional transformations.In this paper, we introduce update lenses as a refinement of ordinary (asymmetric) lenses in which we distinguish between views and updates. In addition to the set of views, there is a monoid of updates and an action of the monoid on the set of views. Decoupling updates from views allows for other ways of changing the source than just merging a view into the source. We also consider a yet finer dependently typed version of update lenses.We give a number of characterizations of update lenses in terms of bialgebras and coalgebras, including analogs to O'Connor's coalgebraic and Johnson, Rosebrugh and Wood's algebraic characterizations of ordinary lenses. We consider conversion of views and updates, a tensor product of update lenses and composition of update lenses

    A coalgebraic view of bar recursion and bar induction

    Get PDF
    We reformulate the bar recursion and induction principles in terms of recursive and wellfounded coalgebras. Bar induction was originally proposed by Brouwer as an axiom to recover certain classically valid theorems in a constructive setting. It is a form of induction on non- wellfounded trees satisfying certain properties. Bar recursion, introduced later by Spector, is the corresponding function defnition principle. We give a generalization of these principles, by introducing the notion of barred coalgebra: a process with a branching behaviour given by a functor, such that all possible computations terminate. Coalgebraic bar recursion is the statement that every barred coalgebra is recursive; a recursive coalgebra is one that allows defnition of functions by a coalgebra-to-algebra morphism. It is a framework to characterize valid forms of recursion for terminating functional programs. One application of the principle is the tabulation of continuous functions: Ghani, Hancock and Pattinson defned a type of wellfounded trees that represent continuous functions on streams. Bar recursion allows us to prove that every stably continuous function can be tabulated to such a tree where by stability we mean that the modulus of continuity is also continuous. Coalgebraic bar induction states that every barred coalgebra is well-founded; a wellfounded coalgebra is one that admits proof by induction
    corecore