Wiki. 单子 [单子]

观念

单子 (monad) 是一种具有许多理解方式的对象, 很难说哪种理解最为基本:

定义

自函子范畴中的结合代数

一个范畴 $\mathcal C$ 的单子是其自函子范畴 $\operatorname{End}(\mathcal C)$ 中的结合代数. 对偶范畴 $\mathcal C^{\mathrm{op}}$ 上的单子称为 $\mathcal C$ 上的余单子.

更具体地, 一个 ($1$-)范畴 $\mathcal C$ 上的单子是一个函子 $T\colon \mathcal C\to\mathcal C$, 带有自然变换 $\eta\colon \mathrm{id}\to T$, $\mu\colon T^2\to T$, 且有两个自然变换 $T^3\to T$ 之间的同构.

当然, 上述定义中的 $\mathcal C$ 也可设为任何 $2$-范畴的对象.

松 2-函子

等价的定义是, 单子为 $2$-范畴之间的松函子 $$ 1\to \mathsf{Cat}. $$ 一般地, $2$-范畴 $\mathcal C$ 的一个单子定义为松函子 $1 \to \mathcal C$ (注意区分一个对象的单子与一个 $2$-范畴的单子).

伴随给出单子

任何一对函子 $L\colon \mathcal C\to\mathcal D$, $R\colon \mathcal D\to\mathcal C$ 之间的伴随 $L\dashv R$ 都给出一个单子 $RL\colon \mathcal C\to\mathcal C$ 与一个余单子 $LR\colon \mathcal D\to\mathcal D$. 见伴随给出单子. 事实上任何单子都是某一对伴随给出的.

Set 上的单子

考虑带基点集合 $\mathsf {Set}_*$ 到 $\mathsf {Set}$ 的遗忘函子, 其对应的自由函子 (左伴随) 是对集合添加一个新的点作为基点. 这对伴随的单位 $\operatorname{id}_{\mathsf {Set}}\to RL$ 是对集合添加一个新的点. 这在计算机科学中称作可能单子 (maybe monad).

固定集合 $S$, 称为状态集合 (set of states), 张量-同态伴随 $(S\times)\dashv (-)^S$ 的单位 $(S\times -)^S$ 称为状态单子 (state monad).

结合代数

设 $A$ 是幺半范畴 $(\mathcal C,\otimes)$ 中的结合代数, 则有单子 $A\otimes(-)\colon \mathcal C\to\mathcal C$. 这是因为 $$ A \mapsto (A\otimes (-)) \colon \mathcal C \to \operatorname{End}(\mathcal C) $$ 是幺半函子, 从而将结合代数 $A$ 变为单子.

相关概念

算畴, 杠构造