A Synthetic Approach to Markov Kernels
Tobias Fritz · 2020 ·
arXiv:1908.07021
Stochastic functions form a category with copy and discard. Whether a function is deterministic or stochastic is detected by whether it commutes with copying.
What's a Markov category
A Markov category (nLab) is three things:
- Objects are types (finite sets, state spaces — the "what")
- Morphisms are stochastic functions: input → distribution over outputs (the "how")
- 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. 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.
Kleisli composition
Morphisms in FinStoch compose via Kleisli composition: feed the output distribution of f into g, marginalizing over the intermediate. This is
>>= (bind) from monads.
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.
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 sufficient statistics.
Notation reference
| Paper | Python | Meaning |
|---|---|---|
| FinStoch | # dicts as distributions | Category of finite stochastic matrices |
| f >=> g | kleisli(f, g) | Kleisli composition (marginalize intermediate) |
| ν | lambda x: (x, x) | Copy morphism |
| ε | lambda x: None | Discard morphism |
| C_det | # functions where copy commutes | Deterministic subcategory |
| supp(f) | {k for k,v in d.items() if v>0} | Support — nonzero outcomes |
| f ≤ g | # g factors through f | Informativeness preorder |
Neighbors
Other paper pages
- 🍞 Staton 2025 — Hoare logic works in FinStoch because it's an imperative category
- 🍞 Baez, Fritz, Leinster 2011 — entropy is the unique information loss measure in FinStoch
- 🍞 Fritz, Perrone, Rezagholi 2021 — support as a monad morphism
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.
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. (
Ambient Category,
The Natural Framework)