# 函子

函子是范畴之间保持结构的映射：它把一个范畴的每个对象送到另一个范畴的对象，把每个态射送到一个态射，并保持恒等与复合。函子是范畴之范畴中的态射；它由哥伦比亚大学（Columbia University）的数学家塞缪尔·艾伦伯格（Samuel Eilenberg）与芝加哥大学（University of Chicago）的桑德斯·麦克莱恩（Saunders Mac Lane）在 1945 年的论文《自然等价的一般理论》（*General Theory of Natural Equivalences*）中引入，其中“函子”一词借自哲学家鲁道夫·卡尔纳普（Rudolf Carnap），“范畴”一词则借自亚里士多德（Aristotle）、康德（Kant）和 C. S. 皮尔士（C. S. Peirce）的哲学。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup>

| 关键事实 | 细节 |
|---|---|
| 定义 | 函子 \( F: \mathcal{C} \to \mathcal{D} \) 把 \( \mathcal{C} \) 的每个对象 \( x \) 送到 \( \mathcal{D} \) 的对象 \( F(x) \)，把每个态射 \( f: x \to y \) 送到 \( F(f): F(x) \to F(y) \)，并保持复合与恒等<sup>[2](https://math.ucr.edu/home/baez/act_course/lecture_44.html)</sup> |
| 两条法则 | \( F(g \circ f) = F(g) \circ F(f) \) 与 \( F(1_x) = 1_{F(x)} \)<sup>[2](https://math.ucr.edu/home/baez/act_course/lecture_44.html)</sup> |
| 反变形式 | 反变函子 \( \mathcal{C} \to \mathcal{D} \) 是一个协变函子 \( \mathcal{C}^{\mathrm{op}} \to \mathcal{D} \)<sup>[3](https://math.hodapp.com/lectures/higher/category-theory/functors.html)</sup> |
| 起源 | 艾伦伯格与麦克莱恩，《美国数学会会刊》58(2)，231–294（1945）<sup>[4](https://people.math.osu.edu/cogdell.1/6112-Eilenberg%26MacLane-www.pdf)</sup> |
| 函子范畴 | 函子 \( \mathcal{C} \to \mathcal{D} \) 构成一个范畴，其态射是自然变换<sup>[5](https://logic.kastel.kit.edu/ap/orbital/Orbital-doc/api/orbital/math/functional/doc-files/Categories.html)</sup> |
| 极限行为 | 可表示函子保持所有极限；右伴随保持极限；来自 Grp、Ring、Vect \( k \)、Pos 和 Mon 的遗忘函子创造极限<sup>[6](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)</sup> |
| 编程中的形式 | 在 Haskell 中，类型 \( f \) 若提供满足 `fmap id == id` 与 `fmap (f . g) == fmap f . fmap g` 的 `fmap :: (a -> b) -> f a -> f b`，则为一个 Functor<sup>[7](https://downloads.haskell.org/~ghc/9.6.1/docs/libraries/base-4.18.0.0/Data-Functor.html)</sup> |

## 定义

给定范畴 \( \mathcal{C} \) 与 \( \mathcal{D} \)，函子 \( F: \mathcal{C} \to \mathcal{D} \) 为 \( \mathcal{C} \) 的每个对象 \( x \) 指派 \( \mathcal{D} \) 的一个对象 \( F(x) \)，并为每个态射 \( f: x \to y \) 指派一个态射 \( F(f): F(x) \to F(y) \)，且须满足两个条件：保持复合，\( F(g \circ f) = F(g) \circ F(f) \)；保持恒等，\( F(1_x) = 1_{F(x)} \)。<sup>[2](https://math.ucr.edu/home/baez/act_course/lecture_44.html)</sup> 在一种标准处理的记号中，该函子由对象上的函数 \( F_{\mathrm{Obj}}: |K_1| \to |K_2| \) 以及每一对对象 \( A, B \) 的态射集上的函数 \( F_{A,B}: K_1(A,B) \to K_2(F_{\mathrm{Obj}}(A), F_{\mathrm{Obj}}(B)) \) 组成，满足 \( F_{A,A}(\mathrm{id}_A) = \mathrm{id}_{F_{\mathrm{Obj}}(A)} \) 与 \( F_{A,C}(f;g) = F_{A,B}(f);F_{B,C}(g) \)。<sup>[8](https://duch.mimuw.edu.pl/~tarlecki/teaching/ct/papers/chap3.pdf)</sup>

因为函子保持复合与恒等，它立即保持图表的交换性。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup> 上面定义的函子也称为**协变**函子，以区别于反变情形。<sup>[8](https://duch.mimuw.edu.pl/~tarlecki/teaching/ct/papers/chap3.pdf)</sup>

## 反变函子

反变函子反转态射的方向：它把 \( f: x \to y \) 送到从 \( F(y) \) 到 \( F(x) \) 的态射，并反转复合的次序。<sup>[9](https://www.cl.cam.ac.uk/teaching/2223/CAT/lectures/CatTheory-lectures.pdf)</sup> 标准约定不另作定义，而把反变函子 \( \mathcal{C} \to \mathcal{D} \) 视为普通协变函子 \( \mathcal{C}^{\mathrm{op}} \to \mathcal{D} \)，其中 \( \mathcal{C}^{\mathrm{op}} \) 是所有态射都反向的对偶范畴。<sup>[3](https://math.hodapp.com/lectures/higher/category-theory/functors.html)</sup> 这种说法让每个函子都字面上是协变的，而把反转推入源范畴，从而简化后续工作。<sup>[10](https://notes.amittai.studio/category-theory/foundations/functors)</sup>

一个熟悉的例子是向量空间的对偶：把向量空间 \( V \) 送到其对偶 \( V^* = \mathrm{Hom}(V,k) \)，把线性映射 \( f \) 送到前复合映射 \( f^* \)，这是从 \( \mathbf{Vect}_k \) 到自身的反变函子。<sup>[10](https://notes.amittai.studio/category-theory/foundations/functors)</sup> 幂集运算给出另一个有启发性的例子：在集合范畴上，\( \wp \) 根据其对函数的作用如何定义而给出两个函子，把子集 \( A \subseteq X \) 或者送到其像 \( f(A) \subseteq Y \)，或者送到其在 \( f \) 下的原像。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup>

## 数学各处的例子

普通数学中的许多构造，一旦辨认出它们的定义域与余定义域范畴，便是函子。

**代数拓扑。** 奇异同调是函子性的：对每个阿贝尔群 \( A \) 和每个 \( n \)，指派 \( X \mapsto H_n(X; A) \) 把连续映射 \( f: X \to Y \) 送到群同态 \( f_*: H_n(X; A) \to H_n(Y; A) \)，并满足 \( (\mathrm{id}_X)_* = \mathrm{id} \) 与 \( (g \circ f)_* = g_* \circ f_* \)；换言之，\( H_n(-; A) \) 是从拓扑空间与连续映射到阿贝尔群与群同态的函子。<sup>[11](https://www.math.ru.nl/~sagave/teaching/at-lecturenotes-2020.pdf)</sup> 基本群 \( \pi_1 \) 同样如此：它为每个连续映射指派群同态 \( f_* \)，并满足 \( (g \circ f)_* = g_* \circ f_* \)。<sup>[12](https://euclid.nmu.edu/~joshthom/ma516/lectures/lecture15.html)</sup> 斯坦福哲学百科全书把同调、上同调、同伦与 K-理论列为函子的例子。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup>

**代数。** 遗忘函子 \( \mathbf{Grp} \to \mathbf{Set} \) 把群送到其底层集合，把同态送到其底层函数；它是自由群函子的右伴随，并保持所有极限，因此群的乘积的底层集合就是底层集合的乘积。<sup>[13](https://calwoo.github.io/notes/concepts/category-theory/foundations/03-limits-colimits/)</sup> 自由阿贝尔群函子 \( \mathbf{Set} \to \mathbf{Ab} \) 是左伴随，保持所有余极限。<sup>[13](https://calwoo.github.io/notes/concepts/category-theory/foundations/03-limits-colimits/)</sup>

**平凡情形。** 对任意范畴 \( \mathcal{X} \)，都有恒等函子 \( 1_{\mathcal{X}}: \mathcal{X} \to \mathcal{X} \)，它固定每个对象与态射。<sup>[14](https://math.ucr.edu/home/baez/act_course/lecture_41.html)</sup> 从一个节点、无边生成的自由范畴到 \( \mathcal{C} \) 的函子，不过是 \( \mathcal{C} \) 的一个对象；从两个节点、一条边生成的自由范畴到 \( \mathcal{C} \) 的函子，则是一个态射。<sup>[2](https://math.ucr.edu/home/baez/act_course/lecture_44.html)</sup>

## 函子范畴与自然变换

给定两个平行函子 \( F, G: \mathcal{C} \to \mathcal{D} \)，自然变换 \( \alpha: F \to G \) 为每个对象 \( x \) 选择一个态射 \( \alpha_x: F(x) \to G(x) \)，使得对每个态射 \( f: x \to y \) 都有 \( G(f) \circ \alpha_x = \alpha_y \circ F(f) \)。<sup>[2](https://math.ucr.edu/home/baez/act_course/lecture_44.html)</sup> 函子 \( \mathcal{C} \to \mathcal{D} \) 连同这些自然变换构成一个范畴，即函子范畴 \( [\mathcal{C}, \mathcal{D}] \)。<sup>[5](https://logic.kastel.kit.edu/ap/orbital/Orbital-doc/api/orbital/math/functional/doc-files/Categories.html)</sup> 在这个范畴中，极限是逐点计算的，一次求值一个点。<sup>[6](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)</sup>

函子可以复合：若 \( F: \mathcal{C} \to \mathcal{D} \) 且 \( G: \mathcal{D} \to \mathcal{E} \)，则复合 \( G \circ F \) 仍是函子。函子的复合是本学科的基本运算之一；在应用范畴论中，正是这一性质使得复合系统的模型可以由其各部分的模型搭建起来。<sup>[15](https://arxiv.org/abs/2408.14014)</sup>

## 与极限和伴随的行为

函子 \( F: \mathcal{A} \to \mathcal{B} \) 保持形状 \( I \) 的极限，如果它把每个极限锥送到极限锥；它反射极限，如果逆命题成立；它创造极限，如果下方的每个极限锥都能唯一地提升为上方的极限锥。创造是三者中最强的性质：若 \( F \) 创造形状 \( I \) 的极限且 \( \mathcal{B} \) 具有这些极限，则 \( \mathcal{A} \) 也具有它们，且 \( F \) 保持它们。由于 Set 完备，而来自 Grp、Ring、\( \mathbf{Vect}_k \)、Pos 和 Mon 的遗忘函子创造极限，一个引理便给出五个完备性定理。<sup>[6](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)</sup>

两个结构性定理支配这种行为。可表示函子 \( \mathcal{A}(A, -): \mathcal{A} \to \mathbf{Set} \) 保持所有极限，形式为 \( \mathcal{A}(A, \lim D) \cong \lim \mathcal{A}(A, D) \)。<sup>[6](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)</sup> 并且，每个有左伴随的函子保持极限，而左伴随保持余极限；遗忘函子 \( \mathbf{Top} \to \mathbf{Set} \) 既保持极限也保持余极限，但两者都不反射，这说明这两个性质是独立的。<sup>[6](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)</sup> 到 20 世纪 70 年代初，伴随函子的概念已被视为范畴论的核心，而各个领域中许多重要定理都可以看作等价于特定范畴之间特定函子的存在。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup>

## 编程中的函子

在函数式编程语言 Haskell 中，`Functor` 类型类捕捉数学概念的一个特例：类型构造子 \( f \) 是一个 Functor，如果它提供一个函数 `fmap :: (a -> b) -> f a -> f b`，该函数应用一个函数把 `f a` 变成 `f b`，同时保持 `f` 的结构，并满足法则 `fmap id == id` 与 `fmap (f . g) == fmap f . fmap g`。<sup>[7](https://downloads.haskell.org/~ghc/9.6.1/docs/libraries/base-4.18.0.0/Data-Functor.html)</sup> 这些正是函子的恒等法则与复合法则，它们确保 `fmap g` 改变容器的元素而不改变其形状。<sup>[16](https://www.haskell.org/wikiupload/e/e9/Typeclassopedia.pdf)</sup>

## 历史与作用

艾伦伯格与麦克莱恩 1945 年的论文定义了范畴、函子与自然变换，催生了范畴论；论文的核心概念是自然变换，而函子是为了赋予自然变换一般含义才被定义的。<sup>[1](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)</sup> 此后，函子成为在数学各领域之间翻译结构的标准载体：在应用范畴论中，定义域范畴提供语法，余定义域提供语义，函子则提供二者之间的联系。<sup>[17](https://derangedmathematician.substack.com/p/is-category-theory-practical)</sup> 在类型论的范畴语义中，程序的解释被刻画为保持结构的函子，其中程序是态射，复合则描述程序如何组合。<sup>[18](https://arxiv.org/abs/2309.08822)</sup>

## References

1. [Category Theory, Stanford Encyclopedia of Philosophy (Spring 2021 edition)](https://plato.stanford.edu/archives/spr2021/entries/category-theory/index.html)
2. [Lecture 44 – Categories, Functors and Natural Transformations, John Baez, Applied Category Theory course](https://math.ucr.edu/home/baez/act_course/lecture_44.html)
3. [Functors and natural transformations – Math foundations, Hodapp](https://math.hodapp.com/lectures/higher/category-theory/functors.html)
4. [Samuel Eilenberg and Saunders Mac Lane (1945). General Theory of Natural Equivalences, Transactions of the AMS 58(2), 231–294](https://people.math.osu.edu/cogdell.1/6112-Eilenberg%26MacLane-www.pdf)
5. [Category theory – Categories and functors, KIT](https://logic.kastel.kit.edu/ap/orbital/Orbital-doc/api/orbital/math/functional/doc-files/Categories.html)
6. [Preservation, Reflection, and Creation of Limits, Amittai Axelrod study notes](https://notes.amittai.studio/category-theory/limits-colimits/limits-and-functors)
7. [Data.Functor, GHC 9.6.1 libraries documentation](https://downloads.haskell.org/~ghc/9.6.1/docs/libraries/base-4.18.0.0/Data-Functor.html)
8. [Chapter 3: Category theory, A. Tarlecki, University of Warsaw](https://duch.mimuw.edu.pl/~tarlecki/teaching/ct/papers/chap3.pdf)
9. [Category Theory lectures, University of Cambridge Computer Laboratory](https://www.cl.cam.ac.uk/teaching/2223/CAT/lectures/CatTheory-lectures.pdf)
10. [Functors: Maps Between Categories, Amittai Axelrod study notes](https://notes.amittai.studio/category-theory/foundations/functors)
11. [Lecture notes for the master course in algebraic topology, S. Sagave, Radboud University](https://www.math.ru.nl/~sagave/teaching/at-lecturenotes-2020.pdf)
12. [The Fundamental Group of the Circle, MA516 lecture notes, Northern Michigan University](https://euclid.nmu.edu/~joshthom/ma516/lectures/lecture15.html)
13. [Category Theory III: Limits and Colimits, Calvin Woo's notes](https://calwoo.github.io/notes/concepts/category-theory/foundations/03-limits-colimits/)
14. [Lecture 41 – Applied Category Theory course, John Baez](https://math.ucr.edu/home/baez/act_course/lecture_41.html)
15. [Category-Theoretical and Topos-Theoretical Frameworks in Machine Learning: A Survey, arXiv:2408.14014](https://arxiv.org/abs/2408.14014)
16. [The Typeclassopedia, The Monad.Reader Issue 13](https://www.haskell.org/wikiupload/e/e9/Typeclassopedia.pdf)
17. [Is Category Theory Practical?, The Deranged Mathematician](https://derangedmathematician.substack.com/p/is-category-theory-practical)
18. [A Categorical Framework for Program Semantics and Semantic Abstraction, arXiv:2309.08822](https://arxiv.org/abs/2309.08822)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Foundations of mathematics › Foundational programs and schools

Copyright 2026 Edgepedia

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

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

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