[Paper Review] The Compositional Structure of Bayesian Inference
This paper formalizes Bayesian inference as a compositional process within symmetric monoidal categories of Markov kernels, showing that Bayesian inversion can be systematically computed piecewise using a lens-like chain rule analogous to backpropagation. The key contribution is a functorial, type-driven framework for probabilistic programming that enables correct-by-construction inference through compositional inversion and approximate inference via parameterized loss functions.
Bayes' rule tells us how to invert a causal process in order to update our beliefs in light of new evidence. If the process is believed to have a complex compositional structure, we may observe that the inversion of the whole can be computed piecewise in terms of the component processes. We study the structure of this compositional rule, noting that it relates to the lens pattern in functional programming. Working in a suitably general axiomatic presentation of a category of Markov kernels, we see how we can think of Bayesian inversion as a particular instance of a state-dependent morphism in a fibred category. We discuss the compositional nature of this, formulated as a functor on the underlying category and explore how this can used for a more type-driven approach to statistical inference.
Motivation & Objective
- To formalize Bayesian inversion as a compositional operation in a categorical framework, abstracting away from specific probabilistic models.
- To address the challenge that Bayesian inverses depend on prior distributions, which vary with composition, by introducing state-dependent morphisms in a fibred category.
- To develop a functorial structure for Bayesian inversion that supports modular, reusable inference components in probabilistic programming.
- To unify concepts from probabilistic inference, automatic differentiation, and predictive coding through a common compositional lens framework.
- To enable algorithmic optimization and static type safety in probabilistic programming via dependent types and compositional loss functions.
Proposed method
- Uses a categorical framework based on symmetric monoidal categories with copying and deletion maps to model Markov kernels and their composition.
- Defines Bayesian inversion as a state-dependent morphism in a fibred category, where the inverse depends on the prior distribution on the input object.
- Introduces a chain rule for Bayesian inversion: BayesInv(f ∘ g, p) = BayesInv(g, p) ∘ BayesInv(f, g ∘ p), analogous to reverse-mode automatic differentiation.
- Constructs a category of Bayesian lenses by equipping morphisms with associated Bayesian inverses, enabling compositional inference.
- Applies string diagrams to visualize and simplify inference computations, reducing complex equations to intuitive graphical compositions.
- Introduces parameterized loss functions—such as KL divergence and variational free energy—to quantify approximation error in compositional inversion.
Experimental results
Research questions
- RQ1Can Bayesian inversion be systematically composed across sequential stochastic processes, and if so, under what categorical conditions?
- RQ2How does the dependency of Bayesian inversion on prior distributions affect its compositional structure in a categorical framework?
- RQ3To what extent can the chain rule for Bayesian updating be formalized as a functor on a Markov category, and what are its structural properties?
- RQ4Can the lens-like structure of Bayesian inversion be leveraged to unify probabilistic inference with other bidirectional processes such as backpropagation and predictive coding?
- RQ5How can compositional Bayesian inversion be used to construct approximate inference algorithms that are correct by construction?
Key findings
- Bayesian inversion composes via a chain rule that mirrors reverse-mode automatic differentiation, enabling efficient, modular inference computation.
- The compositional structure of Bayesian inversion is formalized as a functor on a Markov category, with inverses depending on the prior distribution through state-dependent morphisms.
- String diagrams provide a powerful visual calculus for simplifying and reasoning about complex inference equations, revealing underlying compositional patterns.
- Approximate Bayesian inversion can be parameterized using local loss functions such as Kullback-Leibler divergence, enabling principled, modular approximation.
- The framework naturally unifies probabilistic inference with predictive coding and reinforcement learning through shared lens-like structures.
- The approach supports a type-driven, correct-by-construction design for probabilistic programming languages, with potential for static verification and optimization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.