Fibred Computational Effects

Danel Ahman
DOI: https://doi.org/10.48550/arXiv.1710.02594
2017-10-07
Abstract:Dependent types provide a lightweight and modular means to integrate programming and formal program verification. In particular, the types of programs written in dependently typed programming languages (Agda, Idris, F*, etc.) can be used to express specifications of program correctness. These specifications can vary from being as simple as requiring the divisor in the division function to be non-zero, to as complex as specifying the correctness of compilers of industrial-strength languages. Successful compilation of a program then guarantees that it satisfies its type-based specification. While dependent types allow many runtime errors to be eliminated by rejecting erroneous programs at compile-time, dependently typed languages are yet to gain popularity in the wider programming community. One reason for this is their limited support for computational effects, an integral part of all widely used programming languages, ranging from imperative languages, such as C, to functional languages, such as ML and Haskell. For example, in addition to simply turning their inputs to outputs, programs written in these programming languages can raise exceptions, access computer's memory, communicate over a network, render images on a screen, etc. Therefore, if dependently typed programming languages are to truly live up to their promise of seamlessly integrating programming and formal program verification, we must first understand how to properly account for computational effects in such languages. While there already exists work on this topic, ingredients needed for a comprehensive theory are generally missing. For example, foundations are often not settled; available effects may be limited; or effects may not be treated systematically. In this thesis we address these shortcomings by providing a comprehensive treatment of the combination of dependent types and general computational effects.
Logic in Computer Science
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to combine dependent types and computational effects, two important areas in modern programming language research. Specifically, the author points out that although dependent types and computational effects each have a rigorous mathematical foundation, at present, there is still a lack of a comprehensive and detailed theory when combining the two. Therefore, the goal of the paper is to provide a comprehensive approach in terms of language foundation, category theory, and algebraic treatment to achieve a natural combination of dependent types and computational effects. ### Main problems in the paper 1. **Is it allowed to have computations with computational effects in types?** - For example, in the dependent type `VecA M`, can `M` trigger computational effects (such as performing I/O operations)? - The answer to this question depends on the type of computational effect considered. For effects that do not involve interaction with the runtime environment (such as local names and recursion), `M` does not need to be restricted. But for a wide range of effects including I/O, `M` should be restricted to values to ensure that it can be evaluated as a natural number during type checking. 2. **How to handle type dependencies in sequential composition?** - For example, in the sequential composition rule of CBPV, if this rule is directly used in a dependent - type setting, it will cause the free variable `x` to be unbound in the conclusion. - One way to solve this problem is not to allow the variable `x` to appear freely in the computational type `C`, that is, to require that `C` is well - formed in the context `Γ`, and to modify the type rules to ensure that `x` is bound in the conclusion. ### Specific contributions of the paper - **Defined a core effect - dependent type language eMLTT**: Based on Martin - Löf's intuitionistic type theory, and clearly distinguishes between effect - free values and computations that may carry effects. - **Studied the categorical semantics of eMLTT**: Defined a class of categorical - theoretic models called fibred adjunction models, which naturally combine the split - closed comprehension category of dependent types and the adjunction of computational effects. - **Extended the algebraic method for handling computational effects**: Showed how to extend fibred algebraic effects and their handlers to the dependent - type setting, so that various computational effects can be uniformly specified. Through these works, the paper aims to establish a natural combination of dependent types and computational effects, providing a solid foundation for future research and development.