Probabilistic Simple Types for Almost-Sure Termination (Extended Version)
Ugo Dal Lago, Willem Heijltjes
Abstract
We present a type system for almost-sure termination (AST) in higher-order probabilistic computation. Our vehicle is the recent Functional Machine Calculus (FMC), which combines the lambda-calculus with effectful imperative computation. Importantly for our purpose, it models branching and looping computation with sum types and a typed iterator construct. Our key observation is that by replacing sum types with probability distributions, types ensure that iteration has a non-zero chance of exiting, which then gives AST in a simple and natural way. Concretely, our type system assigns explicit probability distributions to termination outcomes, allowing probabilistic behaviour to be tracked compositionally at the type level. Types then soundly guarantee almost-sure termination, even in the presence of higher-order functions. The fragment of ground terms, which consists purely of the branching and iteration constructs with probabilistic sampling, is equivalent to finite Markov chains and is positively AST (expected evaluation time is finite). The full calculus is more expressive, which we demonstrate through an example term with infinite expected evaluation time.
Create a lesson
Related papers
Hereditary permutations for simple types revisited: A baby case for University Algebra
Shared title terminology · Thorsten Altenkirch
Connecting Extended Modal Dependence Logics
Shared title terminology · Johan van Benthem, Chenwei Shi, Wenfei Ouyang
Graded Intersection Types
Shared title terminology · Rémy Cerda, Ugo Dal Lago
Typed Knowledge over Constructive Institutions: A Proof-Relevant Type Theory for Verified Science
Shared title terminology · Hans-Martin Will
Optimal Probabilistic Answer Set Programming: Complexity and Implementations
Shared title terminology · Damiano Azzolini, Giuseppe Mazzotta, Francesco Ricca et al.
Typed Knowledge over Constructive Institutions
Shared title terminology · Hans-Martin Will