# 等式逻辑

**等式逻辑**是一种形式逻辑，其公式为恒等式，即形如 \( s = t \) 的陈述，其中 \( s \) 与 \( t \) 是由变量和常量借助函数符号构造而成的项，其唯一的推理规则是将相等视为项上的同余关系的那些规则。它是泛代数、代数规格说明与项重写背后的演绎系统，其核心定理由加勒特·伯克霍夫（Garrett Birkhoff）于1935年证明，该定理指出：这一系统对于代数中关于等式的推理是可靠且完备的。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup><sup> • </sup><sup>[2](https://plato.stanford.edu/archives/spr2023/entries/algebra/)</sup>

| 关键事实 | 详情 |
|---|---|
| 公式 | 恒等式 \( s = t \)，其中项由变量和常量借助函数符号（运算）构造而成<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> |
| 推理规则 | 自反性、对称性、传递性、同余性（在函数参数中用相等项替换相等项）以及代换（实例化），即以项代换变量<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup><sup> • </sup><sup>[3](https://fm.csl.sri.com/SSFT13/speaklogicV2.pdf)</sup> |
| 语义 | 当 \( E \) 中的每个恒等式在代数 \( A \) 中成立时，称 \( A \) 是恒等式集合 \( E \) 的模型<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> |
| 完备性 | \( s = t \) 在 \( E \) 的每个模型中都成立，当且仅当它可在等式逻辑中从 \( E \) 推出；这就是伯克霍夫定理（1935）<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup><sup> • </sup><sup>[2](https://plato.stanford.edu/archives/spr2023/entries/algebra/)</sup> |
| 代数对应物 | 伯克霍夫簇（HSP）定理：一个代数类是某个恒等式集合的全部模型构成的类，当且仅当它在同态像、子代数和积下封闭<sup>[2](https://plato.stanford.edu/archives/spr2023/entries/algebra/)</sup><sup> • </sup><sup>[4](https://ualib.org/Demos.HSP.html)</sup> |
| 与重写的联系 | 将每个恒等式视为两条重写规则（每个方向一条），得到一个项重写系统，其中 \( s = t \) 可推出，当且仅当 \( s \) 与 \( t \) 可互转<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> |
| 可判定性 | 大多数常见的等式理论以及任何有限代数的理论都是可判定的<sup>[5](https://www.sciencedirect.com/science/article/pii/S0049237X08705317)</sup> |

## 语言与推理规则

等式逻辑的项由变量和常量借助函数符号（亦称运算）构造而成。形如 \( s = t \) 的恒等式（其中 \( s \) 与 \( t \) 为项）是唯一的一类公式；对象语言中没有逻辑联结词或量词。通常给定一个有限的恒等式集合 \( E \) 作为公理模式，任务是从中推导出更多的恒等式。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup>

演绎系统由五个规则模式组成，读法为横线上方是前提、下方是结论：<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup><sup> • </sup><sup>[3](https://fm.csl.sri.com/SSFT13/speaklogicV2.pdf)</sup>

1. **自反性：** \( s = s \) 直接成立；该规则没有前提。
2. **对称性：** 由 \( s = t \) 推出 \( t = s \)。
3. **传递性：** 由 \( s = t \) 与 \( t = v \) 推出 \( s = v \)。
4. **同余性（替换）：** 由 \( s_1 = t_1, \ldots, s_n = t_n \) 推出 \( f(s_1, \ldots, s_n) = f(t_1, \ldots, t_n) \)，其中 \( f \) 为任意 \( n \) 元函数符号，\( n \geq 0 \)。
5. **代换（实例化）：** 由 \( s = t \) 推出 \( s\theta = t\theta \)，其中 \( \theta \) 为任意代换，其精神与合一相通，即以任意项替换变量。

前三条规则表明相等是一个等价关系；同余性进一步表明它在每个运算下都保持，因此可以在任何表达式中用相等项替换相等项而不改变该表达式的值。<sup>[6](https://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15671-f95/www/handouts/equational/node4.html)</sup> 综合起来，这些规则表明：只要横线上方的公式是从公理推出的定理，横线下方的公式也是定理。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup>

同样的规则也可以用矢列风格表述：给定等式集合 \( E \)，\( E \vdash t = u \) 成立，当且仅当它可由 \( E \) 中公理的可代换性、自反性以及对称性、传递性和同余性这些演绎规则推出。<sup>[7](https://courses.grainger.illinois.edu/cs476/sp2012/hw/lecture-notes-peter.pdf)</sup>

## 语义与等式理论

在语义方面，当 \( E \) 的所有恒等式在代数 \( A \) 中成立时，称 \( A \) 是 \( E \) 的模型。对于由函数符号 \( \mathcal{F} \) 和变量 \( \mathcal{V} \) 构造的项 \( T(\mathcal{F}, \mathcal{V}) \) 上的恒等式集合 \( E \)，由 \( E \) 定义的等式理论 \( \equiv_E \) 是项上包含 \( E \) 且在代换下封闭的最小同余关系：它是自反的、对称的、传递的，与每个函数符号相容，且没有更小的关系在包含 \( E \) 的同时具有这些性质。<sup>[8](https://www3.risc.jku.at/education/courses/ss2018/unification/slides/03_E-Unification_general.pdf)</sup> 当两个项 \( s \) 与 \( t \) 处于这一关系时，称它们在模 \( E \) 下相等，记作 \( s \equiv_E t \)。<sup>[8](https://www3.risc.jku.at/education/courses/ss2018/unification/slides/03_E-Unification_general.pdf)</sup>

**完备性。** 等式逻辑是完备的：若 \( A \) 是 \( E \) 的模型，则 \( s = t \) 在 \( A \) 中成立，当且仅当它可在由 \( E \) 定义的等式逻辑中推出。该定理有时被称为伯克霍夫定理。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> 换言之，在一组等式的所有模型中都为真的东西，仅凭这五条规则即可证明——这是带有量词和联结词的更强逻辑在这种简单形式下所不具备的性质。完备性结果可推广到多类情形：当允许载体集为空的代数时，伯克霍夫等式演算的标准多类推广是不可靠的——这一情形与代数规格说明和抽象数据类型相关——可靠性与完备性反而需要一种修改后的演算。<sup>[9](https://explore.openaire.eu/search/publication?articleId=doi_dedup___%3A%3A06611fb3b41b919b5ef23e7efd710c6e)</sup><sup> • </sup><sup>[16](https://iris.unive.it/handle/10278/20860)</sup>

## 伯克霍夫簇定理

等式逻辑与代数类的分类相伴而行。簇是在商（同态像）、直积和子代数下封闭的代数类；等式类则是某个恒等式集合的全部模型构成的类。伯克霍夫簇定理，亦称HSP定理，断言：代数类 \( \mathcal{K} \) 是等式类，当且仅当它是一个簇。<sup>[2](https://plato.stanford.edu/archives/spr2023/entries/algebra/)</sup><sup> • </sup><sup>[4](https://ualib.org/Demos.HSP.html)</sup> 该定理还稍强一些：对任意类 \( C \)，其闭包 \( \mathrm{HSP}(C) \) 是一个簇。<sup>[2](https://plato.stanford.edu/archives/spr2023/entries/algebra/)</sup>

这两半直接与演绎相关联。若 \( \mathcal{K} \) 由恒等式 \( \mathcal{E} \) 公理化，则类 \( H\mathcal{K} \)、\( S\mathcal{K} \)、\( P\mathcal{K} \) 以及 \( \mathcal{K} \) 本身都满足相同的等式，因此闭包 \( V\mathcal{K} \) 满足 \( \mathcal{E} \) 的每个恒等式，从而 \( V\mathcal{K} \subseteq \mathcal{K} \)。<sup>[4](https://ualib.org/Demos.HSP.html)</sup> 反过来，理论与簇之间的对应关系构成了更一般情形下等式的通用可靠且完备演绎系统的基础，其中具体应用的完备性通过以语法方式表述证明规则而获得。<sup>[10](https://link.springer.com/chapter/10.1007/978-3-030-17127-8_23)</sup> 伯克霍夫1935年的原始证明见于其论文第8–9页（亦编号为第440–441页）。<sup>[11](https://settheory.net/arithmetic/limits)</sup>

## 与项重写和计算的关系

等式逻辑有一个计算的对偶。若将 \( E \) 中的每个恒等式视为两条重写规则——一条将左侧变为右侧，一条反向——则所得的项重写系统等价于由 \( E \) 定义的等式逻辑：恒等式 \( s = t \) 在等式逻辑中可推出，当且仅当 \( s \) 与 \( t \) 在重写系统中可互转，这一性质称为项重写系统的逻辑性。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> 将等式定向为一个方向，便把演绎变成了计算；这两种思想的历史发展在逻辑与计算、即证明与算法的交汇处沿着相互交织的线索推进。<sup>[12](https://www.sciencedirect.com/science/article/abs/pii/B978044451624450006X)</sup>

等式推理也出现在自动化工具中。电子图（e-graph）是最初为自动定理证明器开发的数据结构，可紧凑地表示大量表达式及它们之间的相等关系。等式饱和技术将电子图用于程序优化：重写只是向电子图添加信息，而非破坏性地替换项，随后由提取过程根据用户提供的代价函数选出最佳项。<sup>[13](https://doi.org/10.1145/3815481)</sup>

## 扩展与判定问题

基本系统允许若干扩充。等式逻辑可与一阶逻辑结合，此时同余规则扩展到谓词符号，代换规则被省略；三段论随后可转化为蕴涵形式的公理模式，适用肯定前件式，一阶逻辑的主要结果在这一扩展理论中成立。<sup>[1](https://mathworld.wolfram.com/EquationalLogic.html)</sup> 针对代数规格说明，已发展出多类与条件变体：条件等式逻辑的表达力介于普通等式逻辑与霍恩子句逻辑之间，支持等式带有前提的规格说明。<sup>[14](https://www.cambridge.org/core/journals/mathematical-structures-in-computer-science/article/abs/equivalence-and-difference-between-institutions-simulating-horn-clause-logic-with-based-algebras/62AD9B2818172BA8C68F5A38481D26E5)</sup> 在泛代数的术语中，“等式的”一词指无条件恒等式，通常不包括霍恩公式之类的条件等式。<sup>[15](https://math.stackexchange.com/questions/639684/do-equational-theories-include-sequents)</sup>

在算法方面，大多数常见的等式理论以及任何有限代数的理论都是可判定的，因此对于这些情形，形如“\( E \) 是否证明 \( s = t \)？”的问题可以有效地解决。<sup>[5](https://www.sciencedirect.com/science/article/pii/S0049237X08705317)</sup> 等式合一——即寻找使两个项在模 \( E \) 下相等的代换的问题——在等式公理被内置于推理中时取代了演绎系统中的语法合一；一个理论的合一类型（单一的、有限的、无限的或零的）取决于理论 \( E \) 与可用的函数符号，而模非空 \( E \) 的可合一问题可能不存在一个最一般合一子，正如 \( f(x, y) \) 与 \( f(a, b) \) 的交换合一所示。<sup>[8](https://www3.risc.jku.at/education/courses/ss2018/unification/slides/03_E-Unification_general.pdf)</sup>

## References

1. [Equational Logic, Wolfram MathWorld (entry contributed by Alex Sakharov)](https://mathworld.wolfram.com/EquationalLogic.html)
2. [Algebra, Stanford Encyclopedia of Philosophy (Spring 2023 edition), sections on universal algebra and Birkhoff's theorem](https://plato.stanford.edu/archives/spr2023/entries/algebra/)
3. [Speaking Logic, SRI International (equational logic inference rules)](https://fm.csl.sri.com/SSFT13/speaklogicV2.pdf)
4. [Demos.HSP module, Agda Universal Algebra Library](https://ualib.org/Demos.HSP.html)
5. [Equational Logic and Equational Theories of Algebras, ScienceDirect](https://www.sciencedirect.com/science/article/pii/S0049237X08705317)
6. [Semantics, Equational Logic handout, Carnegie Mellon University](https://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15671-f95/www/handouts/equational/node4.html)
7. [Equational Logic lecture notes, University of Illinois (CS 476)](https://courses.grainger.illinois.edu/cs476/sp2012/hw/lecture-notes-peter.pdf)
8. [Introduction to Unification Theory: Equational Unification, Temur Kutsia, RISC, Johannes Kepler University Linz](https://www3.risc.jku.at/education/courses/ss2018/unification/slides/03_E-Unification_general.pdf)
9. [Soundness and completeness of the Birkhoff equational calculus for many-sorted algebras with possibly empty carrier sets](https://explore.openaire.eu/search/publication?articleId=doi_dedup___%3A%3A06611fb3b41b919b5ef23e7efd710c6e)
10. [Equational Axiomatization of Algebras with Structure, Springer Nature](https://link.springer.com/chapter/10.1007/978-3-030-17127-8_23)
11. [Limits and colimits, settheory.net (note on Birkhoff's 1935 proof)](https://settheory.net/arithmetic/limits)
12. [Equational Logic and Rewriting, ScienceDirect (Handbook chapter)](https://www.sciencedirect.com/science/article/abs/pii/B978044451624450006X)
13. [egg: Fast and Extensible Equality Saturation, Communications of the ACM](https://doi.org/10.1145/3815481)
14. [Equivalence and difference between institutions: simulating Horn Clause Logic with based algebras, Mathematical Structures in Computer Science](https://www.cambridge.org/core/journals/mathematical-structures-in-computer-science/article/abs/equivalence-and-difference-between-institutions-simulating-horn-clause-logic-with-based-algebras/62AD9B2818172BA8C68F5A38481D26E5)
15. [Do "equational theories" include sequents?, Mathematics Stack Exchange (reference to Burris and Sankappanavar, A Course in Universal Algebra)](https://math.stackexchange.com/questions/639684/do-equational-theories-include-sequents)
16. [Soundness and completeness of the Birkhoff equational calculus for many-sorted algebras with possibly empty carrier sets](https://iris.unive.it/handle/10278/20860)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Logical calculi and logical syntax › Proof theory

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/equational-logic

English original: https://www.edgepedia.org/equational-logic
