← back to index

A Synthetic Approach to Markov Kernels

Tobias Fritz · 2020 · arxiv arXiv:1908.07021

Stochastic functions form a wpcategory with copy and discard. Whether a function is deterministic or stochastic is detected by whether it commutes with copying.

What's a Markov category

copy X X X discard X structural morphisms: every object can be copied and discarded

A Markov category (nLab) is three things:

  1. Objects are types (finite sets, state spaces — the "what")
  2. Morphisms are stochastic functions: input → distribution over outputs (the "how")
  3. Structure: you can copy data (duplicate it) and discard data (throw it away)

That's it. In Python: a morphism is a function that returns a dict. The keys are possible outputs. The values are probabilities. The dict IS the stochastic matrix.

# A morphism in FinStoch — it's just a dict
weather_to_temp = {
    "sunny":  {  "hot": 0.8, "cold": 0.2  },
    "cloudy": {  "hot": 0.3, "cold": 0.7  },
}
# For each input (weather), a distribution over outputs (temperature).
# That's a stochastic matrix. That's a morphism. That's FinStoch.
Scheme

Copy detects determinism

Every object in a Markov category has a copy morphism: ν(x) = (x, x). Fritz's insight: a morphism f is deterministic if and only if it commutes with copy. "Apply then copy" equals "copy then apply to both copies."

Stochastic functions fail this test. If you flip a coin and then copy the result, you get (heads, heads) or (tails, tails). If you copy first and then flip each independently, you can get (heads, tails). Different distributions — the function is stochastic.

f ; ν f ν ; (f⊗f) f f ? Deterministic: = (same) Stochastic: ≠ (different)
Scheme

Kleisli composition

Morphisms in FinStoch compose via wpKleisli composition: feed the output distribution of f into g, marginalizing over the intermediate. This is >>= (bind) from monads.

A f B side channel g C copy at B lets downstream g and a side channel both use the intermediate
x f g g g (f >=> g)(x) — marginalize over intermediate
Scheme

Support — which outputs are possible

The support of a distribution is the set of outcomes with nonzero probability. Fritz uses support to define possibilistic reasoning — forget the probabilities, just ask "can this happen?"

This connects to 🍞 Fritz, Perrone, Rezagholi 2021, where support becomes a monad morphism.

Scheme

Informativeness preorder

Fritz defines when one morphism is "more informative" than another: f ≤ g if g factors through f. If you can recover g's output from f's output via post-processing, then f is at least as informative. This is the categorical version of wpsufficient statistics.

Scheme

Notation reference

Paper Python Meaning
FinStoch# dicts as distributionsCategory of finite stochastic matrices
f >=> gkleisli(f, g)Kleisli composition (marginalize intermediate)
νlambda x: (x, x)Copy morphism
εlambda x: NoneDiscard morphism
C_det# functions where copy commutesDeterministic subcategory
supp(f){k for k,v in d.items() if v>0}Support — nonzero outcomes
f ≤ g# g factors through fInformativeness preorder
Neighbors

Other paper pages

Foundations (Wikipedia)

Translation notes

All examples use finite dicts as distributions over small sets. Fritz's paper works over arbitrary measurable spaces, Borel categories, and continuous distributions. For example: the copy-naturality test on this page checks a function over a handful of integers. In the paper, the same test applies to a Gaussian process over ℝ — infinite-dimensional, continuous, and requiring measure theory to state. The structure (does copying commute?) is identical. The generality is not.

The informativeness preorder example is a simplified illustration — the full definition involves almost-sure factorization, not pointwise equality. Every example is Simplified unless marked otherwise.

Ready for the real thing? arxiv Read the paper. Start at §10 (p.48) for the deterministic/stochastic boundary, §16 (p.72) for the informativeness preorder.

Framework connection: FinStoch is the ambient category for the Natural Framework pipeline; the copy-naturality test distinguishes deterministic stages from stochastic ones. (jkAmbient Category, jkThe Natural Framework)