Compositional Thermostatics

Applied Category Theory 2022

Statement of Purpose

Compositional Thermostatics represents the beginning of an attempt to integrate applied category theory and thermodynamics.

But mostly, this is a result of trying to learn thermodynamics, and then trying to tidy it all up into nice categorical presentations.

Overview

1. Thermostatic systems
2. Composition of thermostatic systems
3. Examples
4. Conclusion

Thermostatic systems

A thermostatic system consists of a convex space $X$ called the state space and a concave function $S:X \to \bar{\mathbb{R}}$ called the entropy function.

A convex space is a set $X$ along with an operation $c_{\lambda} \colon X \times X \to X$ for every $\lambda\in[0,1]$ such that

• $c_{\lambda}(x,x) = x$
• $c_{1}(x,y) = x$
• $c_{\lambda}(x,y) = c_{1-\lambda}(y,x)$
• $c_{\lambda}(c_{\gamma}(x,y),z) = c_{\lambda \gamma}(x,c_{\eta}(y,z))$ if $\lambda(1-\gamma)=(1-\lambda\gamma)\eta$.

Example convex spaces

A subset $X \subset \mathbb{R}^{n}$ for some $n$ such that for $x,y \in X$ and $\lambda \in [0,1]$

$\lambda x + (1-\lambda)y \in X$

is a convex space.

Convex subset

Example convex spaces

The extended reals $\bar{\mathbb{R}}=[-\infty,+\infty]$ is a convex space where for $\lambda \in (0,1)$

$c_\lambda(x,y) = \lambda x + (1-\lambda) y \quad \text{for x,y \in \mathbb{R}}$

$c_\lambda(x,+\infty) = +\infty \quad \text{for x \in (-\infty,+\infty]}$

$c_\lambda(x,-\infty) = -\infty \quad \text{for x \in [-\infty,+\infty]}$

Concave functions

A concave function $S \colon X \to \bar{\mathbb{R}}$ is a function such that for all $x,y \in X$,

$S(c_\lambda(x,y)) \geq c_\lambda(S(x),S(y))$

Examples of thermostatic systems

A constant heat-capacity system has state space $X=\mathbb{R}_{>0}$ and the entropy function

$S(U) = C \log U$

Why does this make sense?

$\frac{1}{T} = \frac{\partial S}{\partial U}$

$CT = U$

Examples of thermostatic systems

A heat bath at constant temperature $T$ has state space $X=\mathbb{R}$ and entropy function

$S(\Delta U) = \frac{\Delta U}{T}$

Examples of thermostatic systems

A probabilistic system has state space $X=\mathcal{P}(\Omega)$ for some finite set $\Omega$, and

$S(p) = -\sum_{\omega \in \Omega} p(\omega) \log p(\omega)$

(Shannon entropy)

A quantum system has state space $X$ equal to the collection of mixed states of a quantum system, and $S$ given by von Neumann entropy.

There are generalizations of probability theory used in quantum foundations that also fit into this framework.

Example composition

State space $X_{1} = \mathbb{R}_{>0}$, $S_{1}(U_{1}) = C_{1} \log U_{1}$

State space $X_{2} = \mathbb{R}_{>0}$, $S_{2}(U_{2}) = C_{2} \log U_{2}$

Total energy conserved, i.e.

$U = U_1 + U_2$

Found by maximizing $S_1(U_1) + S_2(U_2)$ with respect to constraint $U_1 + U_2 = U$.

Example composition

Found by maximizing $S_1(U_1) + S_2(U_2)$ with respect to constraint $U_1 + U_2 = U$.

From calculus, at the maximum we can derive

$\frac{\partial S_{1}}{\partial U_{1}} = \frac{\partial S_{2}}{\partial U_{2}}$

that is, $\frac{1}{T_1} = \frac{1}{T_2}$

Example composition

Found by maximizing $S_1(U_1) + S_2(U_2)$ with respect to constraint $U_1 + U_2 = U$.

Also,

$S(U) = \sup_{U_1+U_2 = U} S_1(U_1) + S_2(U_2) = (C_{1} + C_{2}) \log U + K$

Pie+icecream can be viewed as a single thermostatic system with variable $U \in \mathbb{R}_{>0}$

The Central Dogma

The independent composition of thermostatic systems $(X_{1},S_{1}),\ldots,(X_{n},S_{n})$ is

$(X_{1} \times \cdots \times X_{n}, S_{1} + \cdots + S_{n})$

The coarse-graining of a thermostatic system $(X, S)$ via a convex relation $R \subset X \times Y$ is the thermostatic system $(Y, R_{\ast} S)$ where

$R_{\ast} S(y) = \sup_{(x,y) \in R} S(x)$

Composition of thermostatic systems is independent composition followed by coarse-graining.

Formalization of the central dogma

A convex relation $R$ between convex spaces $X$ and $Y$ is a convex subspace of $X \times Y$ and is written $R \colon X \not \to Y$.

The composite of $R_{1} \colon X \not\to Y$ and $R_{2} \colon Y \not\to Z$ defined by

$R_{2} \circ R_{1} = \{ (x,z) \in X \times Z \mid \exists y \in Y, (x,y) \in R_{1}, (y,z) \in R_{2} \}$

is a convex subspace of $X \times Z$.

There is a category $\mathsf{ConvRel}$ that has as objects convex spaces, and as morphisms convex relations.

Convex relations visualized

Pie and icecream relation

Formalization of the central dogma

There is a functor $\mathrm{Ent} \colon \mathsf{ConvRel} \to \mathsf{Set}$ defined in the following way.

$\mathrm{Ent}(X) = \{ S \colon X \to \bar{\mathbb{R}} \mid \text{S is concave} \}$

$\mathrm{Ent}(R \colon X \not\to Y) = R_{\ast}$

where

$R_{\ast}S(y) = \sup_{(x,y) \in R} S(x)$

This formalizes “coarse-graining” entropy functions.

Formalization of the central dogma

For each $n$, there is a natural transformation

$\mu \colon \mathrm{Ent}(-) \times \cdots \times \mathrm{Ent}(-) \Rightarrow \mathrm{Ent}(- \times \cdots \times -)$

that for convex spaces $X_1 \times \cdots \times X_n$ looks like the following

$\mu_{X_{1},\ldots,X_{n}} \colon \mathrm{Ent}(X_1) \times \cdots \times \mathrm{Ent}(X_n) \to \mathrm{Ent}(X_1 \times \cdots \times X_n)$

and is defined by

$(S_{1},\ldots,S_{n}) \mapsto S_{1} + \cdots + S_{n}$

This formalizes “independent composition”

Putting it together

(J.C. Baez, O.L., J. Moeller, 2021). $\mathrm{Ent}$ along with $\mu$ as defined before forms a lax symmetric monoidal functor from $\mathsf{ConvRel}$ to $\mathsf{Set}$.

Given thermostatic systems $(X_{1},S_{1}), \ldots, (X_{n},S_{n})$, a convex space $Y$, and a relation $R \colon (X_{1} \times \cdots \times X_{n}) \not\to Y$, the central dogma builds a thermostatic system on $Y$ via

$\mathrm{Ent}(X_{1}) \times \cdots \times \mathrm{Ent}(X_{n}) \xrightarrow{\mu} \mathrm{Ent}(X_1 \times \cdots \times X_n) \xrightarrow{R_{\ast}} \mathrm{Ent}(Y)$

$(S_1, \ldots, S_n) \mapsto S_1 + \cdots + S_n \mapsto R_\ast(S_1 + \cdots + S_n)$

This composition can be formalized using operads.

An operad $\mathcal{O}$ consists of

• A collection $\mathcal{O}_{0}$ of types
• For all types $X_1,\ldots,X_n,Y$, a collection $\mathcal{O}(X_{1},\ldots,X_{n};Y)$ of operations

along with a way of composing the operations.

There is an operad $\mathcal{CR}$ with types convex spaces and where

$\mathcal{CR}(X_1,\ldots,X_n;Y) = \mathsf{ConvRel}(X_1 \times \cdots \times X_n, Y)$

An operad algebra $F$ for an operad $\mathcal{O}$ associates a set of things $F(X)$ to each type $X \in \mathcal{O}_{0}$, and a function

$F(f) \colon F(X_{1}) \times \cdots \times F(X_{n}) \to F(Y)$

to every operation $f \in \mathcal{O}(X_{1},\ldots,X_{n};Y)$, in a way compatible with composition in the operad.

(J.C. Baez, O.L., J. Moeller, 2021). There is an operad algebra $E$ on $\mathcal{CR}$, where $E(X) = \mathrm{Ent}(X)$ is the set of entropy functions on $X$, and given a relation $R \in \mathcal{CR}(X_{1},\ldots,X_{n};Y)$, $E(R)$ is the central dogma formula of

$\mathrm{Ent}(X_{1}) \times \cdots \times \mathrm{Ent}(X_{n}) \xrightarrow{\mu} \mathrm{Ent}(X_1 \times \cdots \times X_n) \xrightarrow{R_{\ast}} \mathrm{Ent}(Y)$

$(S_1, \ldots, S_n) \mapsto S_1 + \cdots + S_n \mapsto R_\ast(S_1 + \cdots + S_n)$

that is,

$E(R)(S_{1},\ldots,S_{n}) = R_\ast(S_1 + \cdots + S_n)$

Examples: Pie and icecream again

Pie and icecream again

Examples: Pie and icecream again

• Start with $X_{1} = X_{2} = Y = \mathbb{R}_{>}$, and $R \colon X_{1} \times X_{2} \not\to Y$ given by

$R = \{ (U_{1},U_{2},U) \mid U_{1} + U_{2} = U \}$

• Take entropy functions $S_{i}(U_{i}) = C_{i} \log U_{i}$

• Use the operad algebra to apply $R$ to $S_{1}$ and $S_{2}$

• End up with an entropy function on $Y$

• This is just the central dogma, but enshrined in math

Examples: Statistical mechanics

• What happens when we attach a probabilistic system to a heat bath?

Probabilistic system, $X_{1}=\mathcal{P}(\Omega)$

$S(p) = - \sum_{\omega \in \Omega} p(\omega) \log p(\omega)$

Heat bath $X_{2}=\mathbb{R}$

$S_2(\Delta U) = \frac{1}{T} \Delta U$

Statistical mechanics

• Let $H \colon \Omega \to \mathbb{R}$ be an observable for the probabilistic system

• Then let the following relation hold for $p \in \mathcal{P}(\Omega) = X_1$ and $\Delta U \in \mathbb{R} = X_2$

$\mathbb{E}_p H + \Delta U = 0$

• The point of maximum entropy here is the canonical distribution

$p(\omega) = \frac{e^{-H(\omega)/T}}{Z_{1/T}}$

where $Z_{1/T}$ is the partition function, a normalizing factor.

Summary and Conclusions

• Operads and operad algebras are a toolbox for complex open systems
• We can get pretty far by just thinking about constrained entropy maximization
• Modeling composition of systems with lax symmetric monoidal functors is productive