135 research outputs found

    Terminal semantics for codata types in intensional Martin-L\"of type theory

    Full text link
    In this work, we study the notions of relative comonad and comodule over a relative comonad, and use these notions to give a terminal coalgebra semantics for the coinductive type families of streams and of infinite triangular matrices, respectively, in intensional Martin-L\"of type theory. Our results are mechanized in the proof assistant Coq.Comment: 14 pages, ancillary files contain formalized proof in the proof assistant Coq; v2: 20 pages, title and abstract changed, give a terminal semantics for streams as well as for matrices, Coq proof files updated accordingl

    Non-wellfounded trees in Homotopy Type Theory

    Full text link
    We prove a conjecture about the constructibility of coinductive types - in the principled form of indexed M-types - in Homotopy Type Theory. The conjecture says that in the presence of inductive types, coinductive types are derivable. Indeed, in this work, we construct coinductive types in a subsystem of Homotopy Type Theory; this subsystem is given by Intensional Martin-L\"of type theory with natural numbers and Voevodsky's Univalence Axiom. Our results are mechanized in the computer proof assistant Agda.Comment: 14 pages, to be published in proceedings of TLCA 2015; ancillary files contain Agda files with formalized proof

    Guarded Cubical Type Theory: Path Equality for Guarded Recursion

    Get PDF
    This paper improves the treatment of equality in guarded dependent type theory (GDTT), by combining it with cubical type theory (CTT). GDTT is an extensional type theory with guarded recursive types, which are useful for building models of program logics, and for programming and reasoning with coinductive types. We wish to implement GDTT with decidable type-checking, while still supporting non-trivial equality proofs that reason about the extensions of guarded recursive constructions. CTT is a variation of Martin-L\"of type theory in which the identity type is replaced by abstract paths between terms. CTT provides a computational interpretation of functional extensionality, is conjectured to have decidable type checking, and has an implemented type-checker. Our new type theory, called guarded cubical type theory, provides a computational interpretation of extensionality for guarded recursive types. This further expands the foundations of CTT as a basis for formalisation in mathematics and computer science. We present examples to demonstrate the expressivity of our type theory, all of which have been checked using a prototype type-checker implementation, and present semantics in a presheaf category.Comment: 17 pages, to be published in proceedings of CSL 201

    On the Formalization of Imperative Object-based Calculiin (Co)Inductive Type Theories

    Get PDF
    In this paper, we study the formalization of Abadi and Cardelli's impsigma, a representative object-based calculus with types and side effects, in interactive proof assistants based on (Co)Inductive Type Theories, Like Coq. In order to make the formal development of the theory of impsigma easier, we reformulate its static and dynamic semantics taking most advantage of the features provided by CC^(Co)Ind, the coinductive type theory underlying Coq. The new presentation is thus in the style of Natural Deduction Semantics (the counterpart in Natural Deduction style of Kahn's Natural semantics), using higher-order abstract syntax and hypothetical-general premises à la Martin-Löf. Interestingly, for a significant fragment of impsigma we can even use coinductive typing systems, thus avoiding "store types" and leading to a substantial simplification of the proofs of key metaproperties, such as Subject Reduction. The solutions we have devised in the encoding of and metareasoning on can be readily applied to other imperative calculi featuring similar issues

    Non-Wellfounded Trees in Homotopy Type Theory

    Get PDF
    Coinductive data types are used in functional programming to represent infinite data struc-tures. Examples include the ubiquitous data type of streams over a given base type, but also more sophisticated types. From a categorical perspective, coinductive types are characterized by a universal property, which specifies the object with that property uniquely in a suitable sense. More precisely, a coinductive type is specified as the terminal coalgebra of a suitable endofunctor. In this category-theoretic viewpoint, coinductive types are dual to inductive types, which are defined as initial algebras. Inductive, resp. coinductive, types are usually considered in the principled form of the family of W-types, resp. M-types, parametrized by a type A and a dependent type family B over A, that is, a family of types (B(a))a:A. Intuitively, the elements of the coinductive type M(A,B) are trees with nodes labeled by elements of A such that a node labeled by a: A has B(a)-many subtrees, given by a map B(a) → M(A,B); see Figure 1 for an example. The inductive type W(A,B) contains only trees where any path within that tree eventually leads to a leaf, that is, to a node a: A such that B(a) is empty. a, b, c: A B(a) =

    Programming with monadic CSP-style processes in dependent type theory

    Get PDF
    We introduce a library called CSP-Agda for representing processes in the dependently typed theorem prover and interactive programming language Agda. We will enhance processes by a monad structure. The monad structure facilitates combining processes in a modular way, and allows to define recursion as a direct operation on processes. Processes are defined coinductively as non-well-founded trees. The nodes of the tree are formed by a an atomic one step relation, which determines for a process the external, internal choices, and termination events it can choose, and whether the process has terminated. The data type of processes is inspired by Setzer and Hancock's notion of interactive programs in dependent type theory. The operators of CSP will be defined rather than atomic operations, and compute new elements of the data type of processes from existing ones. The approach will make use of advanced type theoretic features: the use of inductive-recursively defined universes; the definition of coinductive types by their observations, which has similarities to the notion of an object in object-oriented programming; the use of sized types for coinductive types, which allow coinductive definitions in a modular way; the handling of finitary information (names of processes) in a coinductive settings; the use of named types for automatic inference of arguments similar to its use in template Meta-programming in C++; and the use of interactive programs in dependent type theory.We introduce a simulator as an interactive program in Agda. The simulator allows to observe the evolving of processes following external or internal choices. Our aim is to use this in order to simulate railway interlocking system and write programs in Agda which directly use CSP processes

    Normalization by Evaluation in the Delay Monad: A Case Study for Coinduction via Copatterns and Sized Types

    Get PDF
    In this paper, we present an Agda formalization of a normalizer for simply-typed lambda terms. The normalizer consists of two coinductively defined functions in the delay monad: One is a standard evaluator of lambda terms to closures, the other a type-directed reifier from values to eta-long beta-normal forms. Their composition, normalization-by-evaluation, is shown to be a total function a posteriori, using a standard logical-relations argument. The successful formalization serves as a proof-of-concept for coinductive programming and reasoning using sized types and copatterns, a new and presently experimental feature of Agda.Comment: In Proceedings MSFP 2014, arXiv:1406.153

    Guarded recursion in Agda via sized types

    Get PDF
    In type theory, programming and reasoning with possibly non-terminating programs and potentially infinite objects is achieved using coinductive types. Recursively defined programs of these types need to be productive to guarantee the consistency of the type system. Proof assistants such as Agda and Coq traditionally employ strict syntactic productivity checks, which often make programming with coinductive types convoluted. One way to overcome this issue is by encoding productivity at the level of types so that the type system forbids the implementation of non-productive corecursive programs. In this paper we compare two different approaches to type-based productivity: guarded recursion and sized types. More specifically, we show how to simulate guarded recursion in Agda using sized types. We formalize the syntax of a simple type theory for guarded recursion, which is a variant of Atkey and McBride\u27s calculus for productive coprogramming. Then we give a denotational semantics using presheaves over the preorder of sizes. Sized types are fundamentally used to interpret the characteristic features of guarded recursion, notably the fixpoint combinator

    Deterministic stream-sampling for probabilistic programming: semantics and verification

    Get PDF
    Probabilistic programming languages rely fundamentally on some notion of sampling, and this is doubly true for probabilistic programming languages which perform Bayesian inference using Monte Carlo techniques. Verifying samplers - proving that they generate samples from the correct distribution - is crucial to the use of probabilistic programming languages for statistical modelling and inference. However, the typical denotational semantics of probabilistic programs is incompatible with deterministic notions of sampling. This is problematic, considering that most statistical inference is performed using pseudorandom number generators.We present a higher-order probabilistic programming language centred on the notion of samplers and sampler operations. We give this language an operational and denotational semantics in terms of continuous maps between topological spaces. Our language also supports discontinuous operations, such as comparisons between reals, by using the type system to track discontinuities. This feature might be of independent interest, for example in the context of differentiable programming.Using this language, we develop tools for the formal verification of sampler correctness. We present an equational calculus to reason about equivalence of samplers, and a sound calculus to prove semantic correctness of samplers, i.e. that a sampler correctly targets a given measure by construction
    • …
    corecore