Reference. Verifying Exact Samplers for Continuous Distributions with a Discrete Program Logic
Most implementations of sampling algorithms for continuous distributions use floating-point numbers, which introduce round-off errors and approximations. These errors can be difficult to analyze, and can cause security issues when used in algorithms for differential privacy. An alternative is to use exact sampling algorithms based on computable reals, which can lazily generate the digits of a continuous sample to arbitrary precision. However, these algorithms are intricate, and implementing and using them involves a combination of semantically challenging language features, such as probabilistic choice, higher-order functions, and dynamically-allocated mutable state. In this paper we present Continuous-Eris, a higher-order separation logic for verifying the correctness of exact sampling algorithms for computable distributions. To demonstrate Continuous-Eris, we verify the correctness of computable samplers for the uniform, Gaussian, and Laplace distributions, as well as a library for exact real arithmetic for working with generated samples. All of the results in this paper have been verified in the Rocq proof assistant.
Cite
Cites 54 works (9 here)
With notes (9)
Modular Specifications and Implementations of Random Samplers in Higher-Order Separation Logic marionneau-2026-modular
Modular Reasoning about Error Bounds for Concurrent Probabilistic Programs li-2025-modular
We present Coneris, the first higher-order concurrent separation logic for reasoning about error probability bounds of higher-order concurrent probabilistic programs with higher-order state. To support modular reasoning about concurrent (non-probabilistic) program modules, state-of-the-art program logics internalize the classic notion of linearizability within the logic through the concept of logical atomicity . In Coneris, we extend this idea to probabilistic concurrent program modules by capturing a novel notion of randomized logical atomicity within the logic. To do so, Coneris utilizes presampling tapes and a novel probabilistic update modality to describe how state is changed probabilistically at linearization points. We demonstrate this approach by means of smaller synthetic examples and larger case studies. All of the presented results, including the meta-theory, have been mechanized in the Rocq prover and the Iris separation logic framework.
Verified Foundations for Differential Privacy demedeiros-2025-verified
Differential privacy (DP) has become the gold standard for privacy-preserving data analysis, but implementing it correctly has proven challenging. Prior work has focused on verifying DP at a high level, assuming either that the foundations are correct or that a perfect source of random noise is available. However, the underlying theory of differential privacy can be very complex and subtle. Flaws in basic mechanisms and random number generation have been a critical source of vulnerabilities in real-world DP systems. In this paper, we present SampCert, the first comprehensive, mechanized foundation for executable implementations of differential privacy. SampCert is written in Lean with over 12,000 lines of proof. It offers a generic and extensible notion of DP, a framework for constructing and composing DP mechanisms, and formally verified implementations of Laplace and Gaussian sampling algorithms. SampCert provides (1) a mechanized foundation for developing the next generation of differentially private algorithms, and (2) mechanically verified primitives that can be deployed in production systems. Indeed, SampCert’s verified algorithms power the DP offerings of Amazon Web Services, demonstrating its real-world impact. SampCert’s key innovations include: (1) A generic DP foundation that can be instantiated for various DP definitions (e.g., pure, concentrated, Rényi DP); (2) formally verified discrete Laplace and Gaussian sampling algorithms that avoid the pitfalls of floating-point implementations; and (3) a simple probability monad and novel proof techniques that streamline the formalization. To enable proving complex correctness properties of DP and random number generation, SampCert makes heavy use of Lean’s extensive Mathlib library, leveraging theorems in Fourier analysis, measure and probability theory, number theory, and topology.
Tachis: Higher-Order Separation Logic with Credits for Expected Costs haselwarter-2024-tachis
We present Tachis, a higher-order separation logic to reason about the expected cost of probabilistic programs. Inspired by the uses of time credits for reasoning about the running time of deterministic programs, we introduce a novel notion of probabilistic cost credit. Probabilistic cost credits are a separation logic resource that can be used to pay for the cost of operations in programs, and that can be distributed across all possible branches of sampling instructions according to their weight, thus enabling us to reason about expected cost. The representation of cost credits as separation logic resources gives Tachis a great deal of flexibility and expressivity. In particular, it permits reasoning about amortized expected cost by storing excess credits as potential into data structures to pay for future operations. Tachis further supports a range of cost models, including running time and entropy usage. We showcase the versatility of this approach by applying our techniques to prove upper bounds on the expected cost of a variety of probabilistic algorithms and data structures, including randomized quicksort, hash tables, and meldable heaps. All of our results have been mechanized using Coq, Iris, and the Coquelicot real analysis library.
Error Credits: Resourceful Reasoning about Error Bounds for Higher-Order Probabilistic Programs aguirre-2024-error
Probabilistic programs often trade accuracy for efficiency, and thus may, with a small probability, return an incorrect result. It is important to obtain precise bounds for the probability of these errors, but existing verification approaches have limitations that lead to error probability bounds that are excessively coarse, or only apply to first-order programs. In this paper we present Eris, a higher-order separation logic for proving error probability bounds for probabilistic programs written in an expressive higher-order language. Our key novelty is the introduction of error credits , a separation logic resource that tracks an upper bound on the probability that a program returns an erroneous result. By representing error bounds as a resource, we recover the benefits of separation logic, including compositionality, modularity, and dependency between errors and program terms, allowing for more precise specifications. Moreover, we enable novel reasoning principles such as expectation-preserving error composition, amortized error reasoning, and error induction. We illustrate the advantages of our approach by proving amortized error bounds on a range of examples, including collision probabilities in hash functions, which allow us to write more modular specifications for data structures that use them as clients. We also use our logic to prove correctness and almost-sure termination of rejection sampling algorithms. All of our results have been mechanized in the Coq proof assistant using the Iris separation logic framework and the Coquelicot real analysis library.
Lilac: A Modal Separation Logic for Conditional Probability li-2023-lilac
We present Lilac, a separation logic for reasoning about probabilistic programs where separating conjunction captures probabilistic independence. Inspired by an analogy with mutable state where sampling corresponds to dynamic allocation, we show how probability spaces over a fixed, ambient sample space appear to be the natural analogue of heap fragments, and present a new combining operation on them such that probability spaces behave like heaps and measurability of random variables behaves like ownership. This combining operation forms the basis for our model of separation, and produces a logic with many pleasant properties. In particular, Lilac has a frame rule identical to the ordinary one, and naturally accommodates advanced features like continuous random variables and reasoning about quantitative properties of programs. Then we propose a new modality based on disintegration theory for reasoning about conditional probability. We show how the resulting modal logic validates examples from prior work, and give a formal verification of an intricate weighted sampling algorithm whose correctness depends crucially on conditional independence structure.
A domain theory for statistical probabilistic programming vakar-2019-a
We give an adequate denotational semantics for languages with recursive higher-order types, continuous probability distributions, and soft constraints. These are expressive languages for building Bayesian models of the kinds used in computational statistics and machine learning. Among them are untyped languages, similar to Church and WebPPL, because our semantics allows recursive mixed-variance datatypes. Our semantics justifies important program equivalences including commutativity. Our new semantic model is based on ‘quasi-Borel predomains’. These are a mixture of chain-complete partial orders (cpos) and quasi-Borel spaces. Quasi-Borel spaces are a recent model of probability theory that focuses on sets of admissible random elements. Probability is traditionally treated in cpo models using probabilistic powerdomains, but these are not known to be commutative on any class of cpos with higher order functions. By contrast, quasi-Borel predomains do support both a commutative probabilistic powerdomain and higher-order functions. As we show, quasi-Borel predomains form both a model of Fiore’s axiomatic domain theory and a model of Kock’s synthetic measure theory.
Iris from the ground up: A modular foundation for higher-order concurrent separation logic jung_etal_iris_ground_up_2018
Iris is a framework for higher-order concurrent separation logic, which has been implemented in the Coq proof assistant and deployed very effectively in a wide variety of verification projects. Iris was designed with the express goal of simplifying and consolidating the foundations of modern separation logics, but it has evolved over time, and the design and semantic foundations of Iris itself have yet to be fully written down and explained together properly in one place. Here, we attempt to fill this gap, presenting a reasonably complete picture of the latest version of Iris (version 3.1), from first principles and in one coherent narrative.
A convenient category for higher-order probability theory heunen-2017-a
External (45)
- Artifact for "Verifying exact samplers for continuous distributions with a discrete program logic" (2026)
- Verifying exact samplers for continuous distributions with a discrete program logic (2026)
- Bayesian separation logic: A logical foundation and axiomatic semantics for probabilistic programming (2026)
- Foundations for deductive verification of continuous probabilistic programs: From lebesgue to riemann and back (2025)
- Approximate relational reasoning for higher-order probabilistic programs (2025)
- Bit blasting probabilistic programs (2024)
- Asynchronous probabilistic couplings in higher-order separation logic (2024)
- Formally verified samplers from probabilistic programs with loops and conditioning (2023)
- Affine monads and lazy structures for bayesian programming (2023)
- ωpap spaces: Reasoning denotationally about higher-order, recursive probabilistic and differentiable programs (2023)
- Guaranteed bounds for posterior inference in universal probabilistic programming (2022)
- Program logic for higher-order probabilistic programs in isabelle/hol (2022)
- Towards an API for the real numbers (2020)
- Semantics of higher-order probabilistic programs with conditioning (2020)
- On the computability of conditional probability (2019)
- Time Credits and Time Receipts in Iris (2019)
- Formal verification of higher-order probabilistic programs: reasoning about approximation, convergence, bayesian inference, and optimization (2019)
- Measurable cones and stable, measurable functions: A model for probabilistic higher-order programming (2018)
- Contextual equivalence for a probabilistic language with continuous random variables and recursion (2018)
- A Program Logic for Union Bounds (2016)
- A lambda-calculus foundation for universal probabilistic programming (2016)
- An application of computable distributions to the semantics of probabilistic programming languages (2016)
- Sampling exactly from the normal distribution (2016)
- Approximate relational hoare logic for continuous random samplings (2016)
- Coquelicot: A user-friendly library of real analysis for Coq (2015)
- A domain-theoretic approach to brownian motion and general continuous stochastic processes (2014)
- The algorithmic foundations of differential privacy (2014)
- Computable de finetti measures (2012)
- On significance of the least significant bits for differential privacy (2012)
- A computable approach to measure and integration theory (2009)
- Computability of probability measures and martin-löf randomness over metric spaces (2009)
- Implementing real numbers with RZ (2007)
- Arbitrary precision real arithmetic: design and algorithms (2003)
- The iRRAM: Exact arithmetic in C++ (2000)
- Lazy functional algorithms for exact real functionals (1998)
- Semantics of exact real arithmetic (1997)
- PCF extended with real numbers (1996)
- Real number computability and domain theory (1996)
- Probability and Measure (1995)
- Optimizing programs over the constructive reals (1990)
- Exact real computer arithmetic with continued fractions (1990)
- A categorical approach to probability theory (1982)
- Computing with infinite objects (1980)
- Various techniques used in connection with random digits (1951)
- Partially-sampled random numbers for accurate sampling of continuous distributions