# 余单子

范畴上的一个余单子是一个三元组 \((T, \varepsilon, \delta)\)，由一个自函子 \(T: \mathcal{C} \to \mathcal{C}\)、一个称为余单位的自然变换 \(\varepsilon: T \Rightarrow \mathrm{Id}_{\mathcal{C}}\)，以及一个称为余乘法的自然变换 \(\delta: T \Rightarrow T \circ T\) 组成，并满足余结合律与余单位恒等式。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> 它是单子的形式对偶：\(\mathcal{C}\) 上的余单子恰好就是相反范畴 \(\mathcal{C}^{\mathrm{op}}\) 上的单子。<sup>[2](https://pi.math.cornell.edu/~bts82/events/homotopyF20/notes/bar-construction-typed.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 数据 | 自函子 \(T\)、余单位 \(\varepsilon: T \Rightarrow \mathrm{Id}\)、余乘法 \(\delta: T \Rightarrow T^2\)<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> |
| 公理 | \(\delta\) 满足余结合律，且 \(\varepsilon\) 是 \(\delta\) 的双边余单位；余单位由 \((T, \delta)\) 唯一确定<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> |
| 幺半群解读 | 余单子是自函子幺半范畴中的余幺半群，其张量积为复合<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> |
| 来自伴随 | 每个伴随 \((F, G, \varepsilon, \eta)\) 都给出一个余单子 \((FG, \delta = F\eta G, \varepsilon)\)<sup>[3](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)</sup> |
| 对偶性 | \(\mathcal{C}\) 上的余单子是 \(\mathcal{C}^{\mathrm{op}}\) 上的单子<sup>[2](https://pi.math.cornell.edu/~bts82/events/homotopyF20/notes/bar-construction-typed.pdf)</sup> |
| 余代数 | 余单子的余代数承载着单子所编码的代数结构的对偶；经典的状态透镜既是单子代数又是余单子余代数<sup>[4](https://arxiv.org/abs/2108.00390)</sup> |
| 首次出现 | 罗杰·戈德门特（Roger Godement）使用松弛层余单子为层构造解消以计算层上同调；该理论由胡贝尔（Huber）、巴尔（Barr）和贝克（Beck）形式化并加以应用<sup>[5](https://www.cambridge.org/core/books/abs/categorical-foundations/aspects-of-monads/DAE5E7135F78327CCBAA54D4B592E6CA)</sup> |

## 定义

余单子公理就是将单子定义中的所有箭头反向所得的图表。余乘法必须满足余结合律，即两个自然变换

\[ T \xrightarrow{\delta} T^2 \xrightarrow{\delta T,\; T\delta} T^3 \]

相等，并且两个变换

\[ T \xrightarrow{\delta} T^2 \xrightarrow{\varepsilon T,\; T\varepsilon} T \]

都必须等于 \(\mathrm{id}_T\)。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> 换言之，\(\delta\) 满足余结合律，而 \(\varepsilon\) 是它的双边余单位。<sup>[6](https://notes.amittai.studio/category-theory/monads-algebras/monads)</sup> 一个有用的结构解读是：\(\mathcal{C}\) 上的自函子以复合为张量积、以自然变换为态射构成一个幺半范畴，而余单子恰好就是该范畴中的余幺半群。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> 这解释了为何这些图表类似于余幺半群的公理，正如单子在那里是幺半群一样。

余单位并非独立的数据：对于满足余结合律的给定配对 \((T, \delta)\)，余单位若存在则唯一确定。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup>

## 来自伴随的余单子

每个伴随都产生一个余单子。给定一个伴随 \((F, G, \varepsilon, \eta)\)，其中 \(F: \mathcal{C} \to \mathcal{D}\) 左伴随于 \(G\)，复合 \(FG\) 是 \(\mathcal{C}\) 的自函子，而 \((FG, \delta = F\eta G, \varepsilon)\) 是 \(\mathcal{C}\) 上的余单子，其中 \(\delta\) 称为余乘法、\(\varepsilon\) 称为余单位，与伴随的单位—余单位术语保持一致。<sup>[3](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)</sup> 同一个伴随同时产生 \(\mathcal{D}\) 上的单子 \(GF\)，因此单个伴随携带两种结构，各在一侧。<sup>[3](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)</sup>

反之，每个单子都来自某个伴随，且方式不止一种，其极大与极小解消分别由 Eilenberg–Moore 构造和 Kleisli 构造给出；对偶的陈述对余单子成立，其相应的构造是余 Eilenberg–Moore 范畴和余 Kleisli 范畴。<sup>[3](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)</sup>

## 例子

**积余单子。** 固定一个集合 \(E\)，令 \(G: \mathrm{Set} \to \mathrm{Set}\) 为 \(X \mapsto X \times E\)。映射 \((x, e) \mapsto (x, e, e)\) 是余乘法 \(G \to G \circ G\)，而 \((x, e) \mapsto e\) 是余单位 \(G \to \mathrm{id}\)；三元组 \((G, c, \varepsilon)\) 是一个余单子。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup> 更一般地，在任何具有有限积的范畴中，每个对象 \(S\) 都确定一个 \(S\)-积余单子，其函子为 \(S \times -\)。<sup>[7](https://citeseerx.ist.psu.edu/document?doi=d17c89db53833969220c576b9cc7aab96d30fbc1&repid=rep1&type=pdf)</sup>

**流余单子。** 在集合范畴上，无限流函子 \(D(X) = X^{\mathbb{N}}\) 携带一个余单子，其余单位为 \(\varepsilon(f) = f(0)\)，即取流在第一个位置的值，余乘法为 \(\delta(f)(n)(m) = f(n + m)\)，即将流平移 \(n\) 位。<sup>[8](https://www.numberanalytics.com/blog/category-theory-seminar-comonads)</sup>

**Reader 式余单子。** Reader 单子的对偶给出形如 \((-) \times R\) 或函数空间形式的余单子；用编程术语来说，余单子提供一个 `extract` 操作和一个 `extend` 操作，用 `extend` 链接计算称为余 Kleisli 复合。<sup>[9](https://blog.higher-order.com/blog/2015/06/23/a-scala-comonad-tutorial/)</sup>

## 余代数与余 Kleisli 构造

单子的代数描述的是携带运算结构的对象，而余单子的余代数描述的是携带对偶的、观测性结构的对象。余单子的余 Kleisli 范畴与基范畴具有相同的对象，从 \(A\) 到 \(B\) 的态射由映射 \(TA \to B\) 给出，并使用余乘法进行复合。这一构造在由余单子构建的笛卡尔闭范畴理论中再次出现，是通往线性逻辑模型的一条途径。<sup>[6](https://notes.amittai.studio/category-theory/monads-algebras/monads)</sup>

余单子的余代数也出现在具体的建模问题中。经典的状态透镜，也称为极良态透镜，同时是某个单子的代数和某个余单子的余代数；布莱斯·克拉克（Bryce Clarke）通过证明从基上的 δ 透镜到基上的余函子的遗忘函子是余单子的，从而表明推广了状态透镜的 δ 透镜是某个余单子的余代数。<sup>[4](https://arxiv.org/abs/2108.00390)</sup>

## 历史

余单子，即范畴的对偶中的单子，最早出现在罗杰·戈德门特（Roger Godement）的工作中，他使用松弛层余单子为层构造解消以计算层上同调。这些结构随后由胡贝尔（Huber）、巴尔（Barr）和贝克（Beck）形式化并应用于同伦论和同调论。<sup>[5](https://www.cambridge.org/core/books/abs/categorical-foundations/aspects-of-monads/DAE5E7135F78327CCBAA54D4B592E6CA)</sup> 教科书处理通常展开单子一侧，再通过对偶性获得余单子；一部标准教材指出，在许多语境中余单子及其衍生的概念至少与单子同等重要，而它自身的处理仍是对偶的并集中于单子。<sup>[3](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)</sup>

## 应用

**层上同调与同伦。** 最初的应用是罗杰·戈德门特（Roger Godement）的松弛层解消，随后的形式化工作汇入了同伦论和同调论。<sup>[5](https://www.cambridge.org/core/books/abs/categorical-foundations/aspects-of-monads/DAE5E7135F78327CCBAA54D4B592E6CA)</sup> 在同调代数中，当 \(A\) 是阿贝尔范畴且余单子是加性的时，所得的机制构成余单子同调的基础。<sup>[10](https://ncatlab.org/nlab/show/comonad)</sup>

**下降与坦纳卡范畴。** 在坦纳卡范畴理论中，范畴 \(B\) 上的余单子充当更丰富结构的“影子”，一个标准结果将原范畴 \(C\) 描述为该余单子在 \(B\) 中的“G-模”范畴。<sup>[1](https://jmilne.org/math/Books/tcdraft.pdf)</sup>

**有限模型论与计算资源。** 由萨姆森·阿布拉姆斯基（Samson Abramsky）、阿努吉·达瓦尔（Anuj Dawar）及其合作者提出的博弈余单子，提供了一种将范畴语义学与有限模型论联系起来的途径。它们对该领域的核心概念给出了结构性的、内蕴的刻画，包括关于逻辑片段的等价性（如有限变量片段、有界量词秩片段和模态片段）、结构的组合参数（如树宽和树深），以及模型比较博弈（如卵石博弈、埃伦费希特–弗赖塞博弈和双模拟博弈）；这些博弈中的策略表现为余 Kleisli 态射。<sup>[11](https://tomas.jakl.one/teaching/2022-su-game-comonads)</sup> 阿布拉姆斯基、达瓦尔和王（Wang）的卵石余单子捕捉有限变量逻辑，余单子框架已被推广到守卫片段、洛瓦兹（Lovász）型计数定理以及库尔塞勒（Courcelle）式定理的刻画。<sup>[11](https://tomas.jakl.one/teaching/2022-su-game-comonads)</sup>

**双向变换。** 上述透镜结果将余单子余代数置于双向变换理论的中心，在该理论中系统在两个方向上保持对应。<sup>[4](https://arxiv.org/abs/2108.00390)</sup>

## References

1. [J.S. Milne, Tannakian Categories, Definition 5.1 and Example 5.2](https://jmilne.org/math/Books/tcdraft.pdf)
2. [Categorical construction notes, Cornell University (bar construction seminar)](https://pi.math.cornell.edu/~bts82/events/homotopyF20/notes/bar-construction-typed.pdf)
3. [Jaap van Oosten, Basic Category Theory, Chapter 6: Monads and Algebras](https://www.staff.science.uu.nl/~ooste110/syllabi/catsmoeder.pdf)
4. [Bryce Clarke, Delta lenses as coalgebras for a comonad, arXiv:2108.00390](https://arxiv.org/abs/2108.00390)
5. [Aspects of Monads (V), Categorical Foundations, Cambridge University Press](https://www.cambridge.org/core/books/abs/categorical-foundations/aspects-of-monads/DAE5E7135F78327CCBAA54D4B592E6CA)
6. [Monads from Adjunctions, Amittai study notes](https://notes.amittai.studio/category-theory/monads-algebras/monads)
7. [Categoric lecture notes, CiteSeerX](https://citeseerx.ist.psu.edu/document?doi=d17c89db53833969220c576b9cc7aab96d30fbc1&repid=rep1&type=pdf)
8. [Category Theory Seminar: Definition and Examples of Comonads](https://www.numberanalytics.com/blog/category-theory-seminar-comonads)
9. [A Scala Comonad Tutorial, Part 1, Higher Order blog](https://blog.higher-order.com/blog/2015/06/23/a-scala-comonad-tutorial/)
10. [Comonad in nLab](https://ncatlab.org/nlab/show/comonad)
11. [Tomáš Jakl and Luca Reggio, Relating Structure to Power: An Invitation to Game Comonads, ESSLLI 2022 course page](https://tomas.jakl.one/teaching/2022-su-game-comonads)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Algebraic structures › Universal algebra and category theory › Functors and natural transformations

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/comonad

English original: https://www.edgepedia.org/comonad
