# 元组

元组是元素的一个有限有序列表，例如写作 (1, 2, 3) 或 ⟨x, y, z⟩，其中元素的顺序以及每个元素出现的次数都是该对象身份的一部分。与集合不同，元组可以包含同一个元素多次，而重新排列其元素会产生不同的元组：(1, 2, 3) ≠ (3, 2, 1)，而集合 {1, 2, 3} 与 {3, 2, 1} 是相等的<sup>[1](https://stackoverflow.com/questions/972924/differences-between-vector-set-and-tuple)</sup>。元组中元素的个数称为它的长度或元数，含两个、三个和四个元素的元组分别称为有序对、三元组和四元组<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 元素的有限有序列表；(1, 2, 2, 3) ≠ (1, 2, 3)，因为重数计入身份；(1, 2, 3) ≠ (3, 2, 1)，因为顺序计入身份<sup>[1](https://stackoverflow.com/questions/972924/differences-between-vector-set-and-tuple)</sup> |
| 有序对作为集合 | 库拉托夫斯基1921年的定义 ⟨a, b⟩ = {{a}, {a, b}}，满足 ⟨a, b⟩ = ⟨c, d⟩ 当且仅当 a = c 且 b = d<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup><sup> • </sup><sup>[3](https://us.metamath.org/mpeuni/df-op.html)</sup> |
| 更长的元组 | 递归定义，⟨a₁, ..., aₙ, aₙ₊₁⟩ = ⟨⟨a₁, ..., aₙ⟩, aₙ₊₁⟩，基始为 ⟨a⟩ = a<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup> |
| 相等性 | 两个 n 元组相等，恰好当所有对应分量都相等时<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup> |
| 笛卡尔积 | A × B = {⟨x, y⟩ : x ∈ A 且 y ∈ B}；若 A 有 n 个元素，则 Aᵏ 有 nᵏ 个元素<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup> |
| 在数据库中 | 元组是关系中数据的理论单元，这一概念由 E. F. 科德形式化<sup>[5](https://www.arhfoundation.org/tuples-database-explained)</sup> |
| 在 Python 中 | 元组不可变且长度固定，因此位置可以承载含义；列表可变且长度不固定<sup>[6](https://realpython.com/python-lists-tuples/)</sup> |

## 集合论中的形式定义

在 ZFC 等集合理论中，所讨论的对象都是集合，因此有序对必须用集合来构造，且构造方式要能重现其预期的行为。有序对的相等性是定义性特征：这样的对恰好在其第一分量和第二分量都匹配时重合，这尤其意味着当 a ≠ b 时 (a, b) ≠ (b, a)<sup>[7](https://plato.stanford.edu/ARCHIVES/WIN2009/entries/set-theory/primer.html)</sup>。无序对 {x, y} 无法做到这一点，因为根据外延性 {x, y} = {y, x}，而有序对在 x ≠ y 时必须区分二者<sup>[8](https://st.openlogicproject.org/settheory-screen.pdf)</sup>。

**标准构造。** 波兰逻辑学家卡齐米日·库拉托夫斯基（Kazimierz Kuratowski）于1921年给出了如今标准的定义<sup>[9](https://www.mathnotes.xyz/math/set_theory/tuples)</sup>：

\[ \langle a, b \rangle = \{\{a\}, \{a, b\}\} \]

通过三次应用配对公理，该对象作为集合存在，a 和 b 称为该对的第一分量和第二分量，或称投影<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。由此定义可证明其特征性质：⟨a, b⟩ = ⟨c, d⟩ 当且仅当 a = c 且 b = d<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。

**更早的和替代的定义。** 诺伯特·维纳（Norbert Wiener）于1914年给出了第一个成功的集合论定义，⟨A, B⟩ = {{{A}, ∅}, {{B}}}，库拉托夫斯基于1921年将其简化为现今的标准形式<sup>[3](https://us.metamath.org/mpeuni/df-op.html)</sup>。几乎在同一时期，费利克斯·豪斯多夫（Felix Hausdorff）在其《集合论基础》（*Grundzüge der Mengenlehre*，1914年，第32页）中提出了定义 ⟨A, B⟩ = {{A, O}, {B, T}}，其中 O 和 T 是两个不同的固定集合<sup>[3](https://us.metamath.org/mpeuni/df-op.html)</sup>。其他构造也满足该特征性质；例如 (a, b) = {{a}, {{a}, b}} 同样满足<sup>[10](https://math-sci.ui.ac.ir/article_28147_53cdac105bd76ae58cd33be7b4030809.pdf?lang=en)</sup>。一个对真类也适用的定义是 ⟨A, B⟩ = (A × {∅}) ∪ (B × {{∅}})<sup>[3](https://us.metamath.org/mpeuni/df-op.html)</sup>。

**库拉托夫斯基对的局限。** 维纳–库拉托夫斯基定义在许多集合理论中行之有效，但对于那些含有不能作为单元素集合成员的类的理论则失效；使用基础公理的递归定义弥补了这一缺陷，并且自然推广到更长的有序元组<sup>[11](https://www.cambridge.org/core/journals/bulletin-of-symbolic-logic/article/abs/reconsidering-ordered-pairs/32384D31F06F699F1F04714329A595AB)</sup>。库拉托夫斯基的定义也不保持类型层级不变，在新基础集合论中使用不便，那里罗瑟（Rosser）的定义是常见的替代方案<sup>[3](https://us.metamath.org/mpeuni/df-op.html)</sup>。

**从对到 n 元组。** 更长的元组通过嵌套来构造。三元组是 ⟨x, y, z⟩ = ⟨⟨x, y⟩, z⟩，四元组是 ⟨x, y, z, u⟩ = ⟨⟨⟨x, y⟩, z⟩, u⟩，一般地<sup>[8](https://st.openlogicproject.org/settheory-screen.pdf)</sup>：

\[ \langle a_1, \ldots, a_n, a_{n+1} \rangle = \langle \langle a_1, \ldots, a_n \rangle, a_{n+1} \rangle \]

以 1 元组基始 ⟨a⟩ = a<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。一份参考文献将 0 元组定义为空集，其余情况用递归 (a₁, (a₂, a₃, ..., aₙ))<sup>[9](https://www.mathnotes.xyz/math/set_theory/tuples)</sup>；约克大学的讲义以 1 元组为基始陈述递归，未给出 0 元组的情形，因此 0 元组的处理在不同表述之间有所差异<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。

元组的相等性是逐分量的：⟨a₁, ..., aₙ⟩ = ⟨b₁, ..., bₙ⟩ 当且仅当 a₁ = b₁ 且 a₂ = b₂ 且……且 aₙ = bₙ<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。这与集合相等性截然不同，后者完全忽略顺序和重数。

**固定长度与“以 n 为定义域的函数”替代方案。** 嵌套对构造有一个已知的缺点：由于 ⟨a⟩ = a，每个 (n+1) 元组同时也是 n 元组，因此该构造不固定元组的长度<sup>[12](https://www.math.uni-bonn.de/~raesch/jensen/jensen/pdf/Jensen_Manuscript_Chapter_0_Preliminaries.pdf)</sup>。如果要求每个元组具有固定长度，则可以将 n 元组等同于长度为 n 的向量，即以 n 为定义域的函数，并以库拉托夫斯基对作为预备定义<sup>[12](https://www.math.uni-bonn.de/~raesch/jensen/jensen/pdf/Jensen_Manuscript_Chapter_0_Preliminaries.pdf)</sup>。

## 元组与相关的集合论结构

两个集合的笛卡尔积收集从它们中取出的所有有序对：A × B = {⟨x, y⟩ : x ∈ A 且 y ∈ B}<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。迭代积按左结合定义，因此 A × B × C 意为 (A × B) × C，一般地 A × B × C ≠ A × (B × C)<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。笛卡尔幂满足 A¹ = A 和 A^(k+1) = Aᵏ × A<sup>[8](https://st.openlogicproject.org/settheory-screen.pdf)</sup>，且若 A 有 n 个元素，则 Aᵏ 有 nᵏ 个元素，可用归纳法证明<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。

二元关系是任何由有序对组成的集合<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。由于 n 元组是嵌套对，n > 2 的 n 元关系可归约为二元关系<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。

## 历史

有序对是20世纪初数理逻辑的核心基础关切之一。完全在集合论内部给出有序对的一个可行定义，被列为那个时期最重要的发现之一，这一成果通常归功于诺伯特·维纳和卡齐米日·库拉托夫斯基，二人各自独立地取得了这一成果<sup>[13](https://www.cambridge.org/core/journals/canadian-journal-of-philosophy/article/abs/settheoretical-representations-of-ordered-pairs-and-their-adequacy-for-the-logic-of-relations/DAC61B8AB4768B73C5DF08D112829126)</sup>。事关重大的是关系和函数这两个概念，二者都被视为数学基础中不可或缺的概念；一旦有序对被归约为集合，关系和函数便容易定义，其结果是逻辑主义的一次关键胜利<sup>[13](https://www.cambridge.org/core/journals/canadian-journal-of-philosophy/article/abs/settheoretical-representations-of-ordered-pairs-and-their-adequacy-for-the-logic-of-relations/DAC61B8AB4768B73C5DF08D112829126)</sup><sup> • </sup><sup>[10](https://math-sci.ui.ac.ir/article_28147_53cdac105bd76ae58cd33be7b4030809.pdf?lang=en)</sup>。

在数据库的关系模型中，E. F. 科德将元组形式化为关系中数据的单元<sup>[5](https://www.arhfoundation.org/tuples-database-explained)</sup>。

## 计算中的元组

**Python。** 在 Python 中，列表与元组最显著的差别在于列表可变而元组不可变<sup>[6](https://realpython.com/python-lists-tuples/)</sup>。列表没有固定长度，天然容纳同质元素，而元组长度固定，因此元素的位置可以承载含义，支持异质数据<sup>[6](https://realpython.com/python-lists-tuples/)</sup>。Python 类型规范将任意长度的同质元组表示为 tuple[int, ...]，等价于包含零个或多个 int 元素的元组的联合<sup>[14](https://typing.python.org/en/latest/spec/tuples.html)</sup>。它还支持解包形式，如 tuple[int, *tuple[str, ...], str]，即一个元组类型，其第一个元素保证为 int，最后一个元素为 str，中间可变，可通过 TypeVarTuple 用于 *args 参数<sup>[14](https://typing.python.org/en/latest/spec/tuples.html)</sup>。由于元组不可变，元组元素类型是协变的：tuple[bool, int] 是 tuple[int, object] 的子类型<sup>[14](https://typing.python.org/en/latest/spec/tuples.html)</sup>。Python 3.12 引入了新的类型参数语法以及用于泛型类型和类型别名的 type 语句<sup>[15](https://docs.python.org/3/whatsnew/3.12.html)</sup>，Python 3.13 增加了对类型参数中类型默认值的支持以及新的类型收窄注解 typing.TypeIs<sup>[16](https://www.python.org/downloads/release/python-31312/)</sup>。

**TypeScript。** TypeScript 的元组类型可以有可选元素和剩余元素，甚至可以为工具和可读性添加标签<sup>[17](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html)</sup>。TypeScript 4.2 扩展了剩余元素，使其可以出现在元组中的任何位置，只有少数限制；此前的版本只允许 ...rest 出现在最后的位置<sup>[17](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html)</sup>。

**C#。** C# 有两个设计不同的元组家族：System.ValueTuple 类型是值类型且可变，而 System.Tuple 类型是引用类型且不可变<sup>[18](https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/builtin-types/value-tuples.md)</sup>。元组上的 == 和 != 运算按位置比较元素，不考虑元组字段名<sup>[18](https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/builtin-types/value-tuples.md)</sup>。

## 数据一览

不可变性在 CPython 中有可测量的后果。在一项已报告的 CPython 测量中，通过迭代器创建的10元素元组用 sys.getsizeof 测得占用128字节，而等价的列表占用200字节<sup>[19](https://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python)</sup>。索引访问接近但不完全相同：在 Python 3.6 的 timeit 下对一个3元素元组，a[1] 每循环测得0.0304微秒，而列表为0.0309微秒<sup>[19](https://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python)</sup>。不可变性还带来一个身份捷径：运行 tuple(some_tuple) 会立即返回同一对象，因为元组不可变，无需复制<sup>[19](https://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python)</sup>。

在数学方面，计数规则是精确的：n 元素集合的笛卡尔幂 Aᵏ 有 nᵏ 个元素<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。

## 与集合、列表和记录的比较

三条区分组织起这一比较。

**元组与集合。** 元组有序且允许重复；集合无序且合并重复项。因此 (1, 2, 2, 3) ≠ (1, 2, 3) 但 {1, 2, 2, 3} = {1, 2, 3}，且 (1, 2, 3) ≠ (3, 2, 1) 但 {1, 2, 3} = {3, 2, 1}<sup>[1](https://stackoverflow.com/questions/972924/differences-between-vector-set-and-tuple)</sup>。元组有有限个元素，而集合或多重集可以有无限个<sup>[1](https://stackoverflow.com/questions/972924/differences-between-vector-set-and-tuple)</sup>。

**元组与列表（Python）。** 列表可变且长度不固定，元组不可变且长度固定；正是固定长度使元素位置能够承载含义并支持异质数据<sup>[6](https://realpython.com/python-lists-tuples/)</sup>。同样的不可变性构成了类型系统中元组元素类型协变性的基础<sup>[14](https://typing.python.org/en/latest/spec/tuples.html)</sup>。

**元组与记录。** C# 使这一对比具体化：元组相等性按位置进行，忽略字段名<sup>[18](https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/builtin-types/value-tuples.md)</sup>。在关系理论中，同样的区分表现为元组与属性：术语“元组”指关系代数和集合论中的理论概念，而“行”指物理存储，“记录”指逻辑编程实体<sup>[5](https://www.arhfoundation.org/tuples-database-explained)</sup>。

## 应用

**数据库。** 在关系数据库理论中，元组是关系中数据元素的集合，这一概念由关系模型的创立者 E. F. 科德形式化<sup>[5](https://www.arhfoundation.org/tuples-database-explained)</sup>。在关系模型中，关系内的元组是唯一的；第一范式（1NF）通常被描述为要求元组的每个属性包含一个原子值<sup>[5](https://www.arhfoundation.org/tuples-database-explained)</sup>。

**关系与积。** 在逻辑和集合论中，元组是关系的元素：二元关系是有序对的集合，n 元关系是 n 元组的集合<sup>[4](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)</sup>。元组同样是笛卡尔积的元素，因此 A × B × C 中的一个点是从 A、B 和 C 中取出的坐标三元组<sup>[2](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)</sup>。

## References

1. [Differences between vector, set, and tuple, Stack Overflow](https://stackoverflow.com/questions/972924/differences-between-vector-set-and-tuple)
2. [Pairs, Tuples, Cartesian Products, Open Logic Project](https://builds.openlogicproject.org/content/sets-functions-relations/sets/pairs-and-products.pdf)
3. [df-op, Metamath Proof Explorer](https://us.metamath.org/mpeuni/df-op.html)
4. [Notes on a (very) Elementary Set Theory, Part IV, York University](https://www.eecs.yorku.ca/~tgeorge/papers/Notes-on-sets-IV.pdf)
5. [What are Tuples in Database Systems?, ARH Foundation](https://www.arhfoundation.org/tuples-database-explained)
6. [Lists vs Tuples in Python, Real Python](https://realpython.com/python-lists-tuples/)
7. [Basic Set Theory, Stanford Encyclopedia of Philosophy (2009 archive)](https://plato.stanford.edu/ARCHIVES/WIN2009/entries/set-theory/primer.html)
8. [Set Theory: An Open Introduction, Open Logic Project](https://st.openlogicproject.org/settheory-screen.pdf)
9. [Tuples, MathNotes](https://www.mathnotes.xyz/math/set_theory/tuples)
10. [An Investigation of Kuratowski's Definition of an Ordered Pair](https://math-sci.ui.ac.ir/article_28147_53cdac105bd76ae58cd33be7b4030809.pdf?lang=en)
11. [Reconsidering Ordered Pairs, Bulletin of Symbolic Logic](https://www.cambridge.org/core/journals/bulletin-of-symbolic-logic/article/abs/reconsidering-ordered-pairs/32384D31F06F699F1F04714329A595AB)
12. [Preliminaries, Ronald Jensen manuscript, University of Bonn](https://www.math.uni-bonn.de/~raesch/jensen/jensen/pdf/Jensen_Manuscript_Chapter_0_Preliminaries.pdf)
13. [Set-Theoretical Representations of Ordered Pairs, Canadian Journal of Philosophy](https://www.cambridge.org/core/journals/canadian-journal-of-philosophy/article/abs/settheoretical-representations-of-ordered-pairs-and-their-adequacy-for-the-logic-of-relations/DAC61B8AB4768B73C5DF08D112829126)
14. [Tuples, Python Typing Specification](https://typing.python.org/en/latest/spec/tuples.html)
15. [What's New In Python 3.12](https://docs.python.org/3/whatsnew/3.12.html)
16. [Python Release Python 3.13.12](https://www.python.org/downloads/release/python-31312/)
17. [TypeScript 4.2 Release Notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html)
18. [C# tuple types, .NET documentation](https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/builtin-types/value-tuples.md)
19. [Are tuples more efficient than lists in Python?, Stack Overflow](https://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python)

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

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Set theory › Elementary set theory

Copyright 2026 Edgepedia

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

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

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