13 research outputs found
Programación estructurada matemáticamente
Los lenguajes de programación modernos poseen características que aumentan considerablemente su poder expresivo. Este poder expresivo permite la internalización de las estructuras matemáticas que sustentan la semántica de los lenguajes. Dichas estructuras proveen abstracciones que facilitan distintos aspectos del desarrollo de software, como ser modularidad, optimización, seguridad y verificación. Nos proponemos investigar las propiedades y aplicaciones de estructuras tales como mónadas, arrows, y functores aplicativos.Eje: Aspectos teóricos de Ciencias de la ComputaciónRed de Universidades con Carreras en Informática (RedUNCI
Bases as Coalgebras
The free algebra adjunction, between the category of algebras of a monad and
the underlying category, induces a comonad on the category of algebras. The
coalgebras of this comonad are the topic of study in this paper (following
earlier work). It is illustrated how such coalgebras-on-algebras can be
understood as bases, decomposing each element x into primitives elements from
which x can be reconstructed via the operations of the algebra. This holds in
particular for the free vector space monad, but also for other monads, like
powerset or distribution. For instance, continuous dcpos or stably continuous
frames, where each element is the join of the elements way below it, can be
described as such coalgebras. Further, it is shown how these
coalgebras-on-algebras give rise to a comonoid structure for copy and delete,
and thus to diagonalisation of endomaps like in linear algebra
Delimited continuations in Prolog: semantics, use, and implementation in the WAM
An implementation of a delimited continuations, known in the functional programming world, is shown in the context of the WAM, and more particular in hProlog. Three new predicates become available to the user: reset/3 and shift/1 for delimiting and capturing the continuation, and call continuation/1 for calling it. The underlying low-level built-ins and modifications to the system are described in detail. While these do not turn continuations into first-class Prolog citizens, their usefulness is shown in a series of examples. The idea behind this implementation can be adapted to other Prolog implementations. The constructs are compared with similar ones in BinProlog and Haskell. Their interaction with other parts of Prolog is discussed
Extending Equational Monadic Reasoning with Monad Transformers
There is a recent interest for the verification of monadic programs using proof assistants. This line of research raises the question of the integration of monad transformers, a standard technique to combine monads. In this paper, we extend Monae, a Coq library for monadic equational reasoning, with monad transformers and we explain the benefits of this extension. Our starting point is the existing theory of modular monad transformers, which provides a uniform treatment of operations. Using this theory, we simplify the formalization of models in Monae and we propose an approach to support monadic equational reasoning in the presence of monad transformers. We also use Monae to revisit the lifting theorems of modular monad transformers by providing equational proofs and explaining how to patch a known bug using a non-standard use of Coq that combines impredicative polymorphism and parametricity
Robustness in Metric Spaces over Continuous Quantales and the Hausdorff-Smyth Monad
Generalized metric spaces are obtained by weakening the requirements (e.g.,
symmetry) on the distance function and by allowing it to take values in
structures (e.g., quantales) that are more general than the set of non-negative
real numbers. Quantale-valued metric spaces have gained prominence due to their
use in quantitative reasoning on programs/systems, and for defining various
notions of behavioral metrics.
We investigate imprecision and robustness in the framework of quantale-valued
metric spaces, when the quantale is continuous. In particular, we study the
relation between the robust topology, which captures robustness of analyses,
and the Hausdorff-Smyth hemi-metric. To this end, we define a preorder-enriched
monad , called the Hausdorff-Smyth monad, and when is a
continuous quantale and is a -metric space, we relate the topology
induced by the metric on with the robust topology on the
powerset defined in terms of the metric on .Comment: 19 pages, 1 figur
Interaction laws of monads and comonads
We introduce and study functor-functor and monad-comonad interaction laws as
mathematical objects to describe interaction of effectful computations with
behaviors of effect-performing machines. Monad-comonad interaction laws are
monoid objects of the monoidal category of functor-functor interaction laws. We
show that, for suitable generalizations of the concepts of dual and Sweedler
dual, the greatest functor resp. monad interacting with a given functor or
comonad is its dual while the greatest comonad interacting with a given monad
is its Sweedler dual. We relate monad-comonad interaction laws to stateful
runners. We show that functor-functor interaction laws are Chu spaces over the
category of endofunctors taken with the Day convolution monoidal structure.
Hasegawa's glueing endows the category of these Chu spaces with a monoidal
structure whose monoid objects are monad-comonad interaction laws
Algebras for weighted search
Weighted search is an essential component of many fundamental and useful algorithms. Despite this, it is relatively under explored as a computational effect, receiving not nearly as much attention as either depth- or breadth-first search. This paper explores the algebraic underpinning of weighted search, and demonstrates how to implement it as a monad transformer. The development first explores breadth-first search, which can be expressed as a polynomial over semirings. These polynomials are generalised to the free semi module monad to capture a wide range of applications, including probability monads, polynomial monads, and monads for weighted search. Finally, a monad trans-former based on the free semi module monad is introduced. Applying optimisations to this type yields an implementation of pairing heaps, which is then used to implement Dijkstra’s algorithm and efficient probabilistic sampling. The construction is formalised in Cubical Agda and implemented in Haskell
Dijkstra monads for all
This paper proposes a general semantic framework for verifying programs with arbitrary monadic side-effects using Dijkstra monads, which we define as monad-like structures indexed by a specification monad. We prove that any monad morphism between a computational monad and a specification monad gives rise to a Dijkstra monad, which provides great flexibility for obtaining Dijkstra monads tailored to the verification task at hand. We moreover show that a large variety of specification monads can be obtained by applying monad transformers to various base specification monads, including predicate transformers and Hoare-style pre- and postconditions. For defining correct monad transformers, we propose a language inspired by Moggi's monadic metalanguage that is parameterized by a dependent type theory. We also develop a notion of algebraic operations for Dijkstra monads, and start to investigate two ways of also accommodating effect handlers. We implement our framework in both Coq and F*, and illustrate that it supports a wide variety of verification styles for effects such as exceptions, nondeterminism, state, input-output, and general recursion