A Domain Theory for Statistical Probabilistic Programming

Matthijs Vákár, Ohad Kammar, Sam StatonarXiv 2018 · DOI

TL;DR

This paper introduces $\omega$-quasi-Borel spaces ($\omega$qbses) to provide the first mathematically sound and adequate denotational semantics for probabilistic programming languages that simultaneously support higher-order functions, continuous distributions, and recursion. By decoupling the domain-theoretic order from the measure-theoretic structure, the authors solve a long-standing open problem in denotational semantics, justifying critical program transformations like commutativity.

What Problem Does This Paper Address?

Statistical probabilistic programming languages (PPLs) like Church, WebPPL, and Hakaru allow developers to define complex statistical models using standard programming features, including higher-order functions and recursion (such as loops or recursive data types like infinite streams). To ensure these languages behave predictably and allow for compiler optimizations, researchers rely on denotational semantics—a mathematical framework that gives programs precise meanings.

However, combining higher-order recursion and continuous probability has faced a major mathematical roadblock for decades known as the Jung-Tix problem. Traditional domain theory models recursion using chain-complete partial orders (cpos). When you try to add probability to cpos using probabilistic powerdomains, the order in which independent random choices are evaluated suddenly matters. In other words, the model loses commutativity (the computer science equivalent of Fubini's theorem), which breaks basic compiler optimizations like reordering independent lines of code.

Methods

The authors sidestep the Jung-Tix problem by introducing a new mathematical structure: $\omega$-quasi-Borel spaces ($\omega$qbses), also referred to as quasi-Borel predomains.

Instead of forcing the probability structure to be derived directly from a cpo's topology, an $\omega$qbs keeps the two structures separate but compatible. It consists of a set equipped with:

  1. A partial order where limits of $\omega$-chains exist (to handle recursion).
  2. A set of admissible random elements (to handle probability theory via quasi-Borel spaces).

Using this framework, the authors:

  • Construct a commutative probabilistic powerdomain that works seamlessly with higher-order functions.
  • Apply Fiore and Plotkin’s axiomatic domain theory to solve recursive domain equations, allowing the language to support recursive types (like lists and streams) and untyped lambda calculi.
  • Prove an adequacy theorem that mathematically links this new denotational model to a practical, Monte-Carlo-based operational semantics.

The primary language analyzed is Statistical FPC (SFPC), which includes standard functional constructs alongside statistical primitives like sample (drawing from continuous distributions) and score (soft constraints for conditioning).

Datasets

Not discussed in the paper. As a foundational paper in theoretical computer science and programming language theory, it does not utilize empirical datasets or benchmarks.

Key Insights and Ideas

  • Separation of Concerns: The core "aha moment" is realizing that the Jung-Tix problem is an artifact of coupling the measurable structure directly to the topology of the domain. By treating the partial order and the random elements as independent but compatible entities, commutativity is preserved.
  • First-Class Recursion over Infinite Structures: The model provides a rigorous compositional meaning to complex higher-order functions like reduce or fold when operating over infinite stochastic processes, rather than just evaluating whole closed programs.
  • Validating Practical Optimizations: It mathematically justifies exact Bayesian inference techniques (like disintegration used in the Hakaru system) that rely on reordering integrals and program statements.

Key Results

  • Theorem 6.9 (Adequacy): The authors prove that if two programs are equal in the $\omega$qbs model, they are contextually equivalent in a Monte-Carlo operational semantics.
  • Corollary 6.11 (Commutativity): The model successfully validates that statement reordering is safe: $$\text{let } x = t \text{ in let } y = s \text{ in } r \quad \approx \quad \text{let } y = s \text{ in let } x = t \text{ in } r$$ This holds true even when $t$ and $s$ involve higher-order functions and recursive types.

The paper illustrates these capabilities using practical probabilistic programming examples, such as first-order Bayesian linear regression and higher-order recursive Gaussian random walks:

Fig. 1. Bayesian linear regression as (a) a first-order probabilistic program, (b) an informal specification, and (c) a plot of the prior and posterior distributions. Here 푁(휇, 휎) is the normal (Gaussian) distribution with
Fig. 2. A Gaussian random walk as (a) a higher-order recursive program and (b) an informal specification, with (c) some samples. The function reduce is sometimes called fold lef.

Limitations and Future Work

  • Non-Standard Spaces: If a space is not a standard Borel space, the $\omega$qbs powerdomain might omit some s-finite valuations, meaning aspects of the Jung-Tix problem remain open for highly exotic, non-standard spaces.
  • Synthetic Measure Theory: While the authors show that $\omega$qbses form a model of Kock’s synthetic measure theory, fully replicating previous compiler verification proofs specifically for the more expressive SFPC language is left for future work.
  • Topological Connections: The formal relationships between Topological Domain Theory (TDT) and $\omega$qbses require further investigation. TDT disallows certain discontinuities (like zero-testing conditionals) that $\omega$qbses handle easily, and exploring this trade-off is an open direction.

Summary updated

BibTeX
@misc{vakar2018domain,
  author = {Matthijs Vákár and Ohad Kammar and Sam Staton},
  title = {{A Domain Theory for Statistical Probabilistic Programming}},
  year = {2018},
  eprint = {1811.04196},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.04196},
}
Figure