Wiki. 单子 [单子]
Wiki. 单子 [单子]
观念
单子 (monad) 是一种具有许多理解方式的对象, 很难说哪种理解最为基本:
- 范畴 $\mathcal C$ 上的单子是自函子范畴 $\operatorname{End}(\mathcal C)$ 中的结合代数; 在这种意义上它是结合代数的范畴化.
- 幺半范畴 $\mathcal C$ 中的一个结合代数 $A$ 给出 $\mathcal C$ 上的一个单子 $A\otimes(-)$; 在这种意义上单子是结合代数的推广; 单子上的模 (或叫单子上的代数) 是结合代数上的模的推广.
- 单子是代数理论的推广. 许多代数结构可理解为某个单子上的代数; 此时这个单子给出 “自由代数”. 这件事可由单子性函子描述.
- 在 $2$-范畴的理论中, 单子可视为 $1$ 到 $\mathsf{Cat}$ 的松函子, 从而进一步推广为 $1$ 到一般的 $2$-范畴的松函子.
定义
自函子范畴中的结合代数
一个范畴 $\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$ 变为单子.