# 良构公式

良构公式（well-formed formula，常简称为公式）是由给定字母表中的符号组成的有限序列，按照形式语言——如命题逻辑或一阶逻辑——的文法构造而成。良构性是一种纯粹语法层面的属性：它意味着该表达式具有语言所要求的语法结构，而不意味着它是真的、有效的、可满足的或可证明的。缩写 WFF 按惯例读作“whiff”。<sup>[1](https://www.uvm.edu/~cbcafier/cs-fundamentals/05_logic/propositional_logic.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 由形式语言字母表中的符号构成的有限字符串，能够通过该语言的形成规则从原子情形推导得出；它是一个语法对象，本身并不承载真值 |
| 定义方法 | 递归（归纳）定义：以原子公式为基础情形，然后对联结词和量词取闭包<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> |
| 一阶基础情形 | 形如 \( R(\tau_{1},\ldots,\tau_{n}) \) 的原子公式，其中 \( R \) 为 \( n \) 元谓词，\( \tau_{1},\ldots,\tau_{n} \) 为项；外加等式 \( \tau_{1} = \tau_{2} \)<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> |
| 唯一解析 | 每个公式都有唯一的分解方式，因而有唯一的解析树，所以不能被“读”成两种不同的意思<sup>[3](https://cs.uwaterloo.ca/~eblais/cs245e/f25/fol-syntax)</sup> |
| 语句 | 不含变元自由出现的公式称为闭公式，也叫语句<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> |
| 历史渊源 | 量词以及包含关系的系统最早出现于弗雷格的《概念文字》（1879），它是现代形式语法的前身<sup>[4](https://frege.info/basiclaws/index.html)</sup> |
| 可判定性 | 根据丘奇定理（1936），不存在判定哪些一阶公式是有效的算法<sup>[5](https://www.rep.routledge.com/articles/thematic/churchs-theorem-and-the-decision-problem/v-1)</sup> |

## 递归定义

公式的形成规则以递归方式陈述：一个基础情形，以及一种反复应用语法规则的方式。<sup>[6](https://milnepublishing.geneseo.edu/concise-introduction-to-logic/chapter/12-all-and-some/)</sup> 在一个典型的一阶语言 \( \mathcal{L} \) 中，词汇表包括常元符号、指定元数的谓词、个体变元，以及逻辑符号，如真值函数联结词 \( \lnot, \land, \lor, \rightarrow, \leftrightarrow \)、常元 \( \top \) 和 \( \bot \)、等词、量词 \( \forall \) 和 \( \exists \)，以及括号。<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup>

公式集随后由如下子句定义：

\[ \varphi \ := \ R(\tau_1,\dots,\tau_n) \ | \ \tau_1 = \tau_2 \ | \ \neg \varphi \ | \ (\varphi \land \varphi) \ | \ \forall x \varphi, \]

其中前两种备选情形是原子公式。其余联结词 \( \vee, \rightarrow, \leftrightarrow \) 和常元 \( \top, \bot \) 可以用 \( \neg \) 和 \( \wedge \) 来定义，而 \( \exists x \varphi \) 是 \( \neg \forall x \neg \varphi \) 的缩写。<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> 不同的表述会选择不同的原始符号、不同的联结词集合和不同的括号约定，甚至在波兰记号法中完全省略括号；所有做法的共同之处在于，形成规则以归纳方式定义项和公式。<sup>[7](https://builds.openlogicproject.org/content/first-order-logic/first-order-logic.pdf)</sup>

**项在先。** 在一阶语法中，项——指称论域中对象的表达式——先由变元、常元符号和函数符号构造出来，然后才能出现在原子公式内部；一个 \( n \) 元谓词后跟 \( n \) 个项，就得到一个原子公式。<sup>[7](https://builds.openlogicproject.org/content/first-order-logic/first-order-logic.pdf)</sup><sup> • </sup><sup>[8](https://milnepublishing.geneseo.edu/concise-introduction-to-logic/chapter/16-summary-of-first-order-logic/)</sup> 一个表达式作为项在语法上构造合法，本身并不使它成为公式；必须由公式形成子句从原子公式出发生成它才行。

**通不过检验的情形。** 任意的符号串不会仅仅因为看起来像数学记号就成为良构公式；运算符位置错误、元数不对、标点不配对或无法给出语法推导的表达式都不合格。例如，\( \forall x_{1}(\forall x_{2}(((x_{1} = a) \lor (x_{1} = b)) \land \neg(f(x_{2}) = f(x_{1})))) \) 是良构的，而 \( \forall(\forall x_{1}(x = ab)\neg()x_{2}) \) 则不是。<sup>[9](https://www.cse.iitb.ac.in/~supratik/courses/cs719/fol.pdf)</sup> 一个表达式是良构公式，当且仅当它能按照该形式语言的形成规则构造出来；把它翻译成一个正确的英语句子并不是充分的检验标准。<sup>[10](https://www.cs.odu.edu/~toida/nerzic/level-a/logic/pred_logic/construction/wff_intro.html)</sup><sup> • </sup><sup>[21](https://philosophy.hku.hk/think/sl/wff.php?m=1)</sup>

## 唯一解析与解析树

定义中括号的作用，是确保任何公式都只能以唯一一种方式按照归纳定义获得，因此每个公式都有唯一的解析树。<sup>[11](https://www.math.uni-bielefeld.de/~frettloe/papers/wikibuch.pdf)</sup> 形式上，一阶逻辑的唯一解析定理指出：每个公式 \( \phi \) 都有唯一的分解方式，或为原子公式 \( P(t_{1},\ldots,t_{n}) \)，或为否定式 \( \neg \psi \)，或为二元复合式 \( (\psi \,\square\, \theta) \)，或为量化式 \( \forall v \, \psi \) 或 \( \exists v \, \psi \)；而每个项也都有唯一的分解方式，或为变元，或为常元，或为函数应用，或为二元函数应用。<sup>[3](https://cs.uwaterloo.ca/~eblais/cs245e/f25/fol-syntax)</sup> 因此，一个良构公式不可能被读成两种不同的意思。<sup>[12](https://cpb-us-w2.wpmucdn.com/sites.uml.edu/dist/8/95/files/2018/10/oct-25-22tm159.pdf)</sup>

这一性质有实际作用。它为对公式进行归纳定义和归纳证明提供了依据，因为每个公式都有定义明确的直接结构可供归纳。<sup>[13](https://www.encyclopedia.com/humanities/encyclopedias-almanacs-transcripts-and-maps/first-order-logic)</sup> 它也是递归定义可作为算法使用的基础：这些规则能够判定任意符号串是否为良构公式。<sup>[14](https://formallogic.eu/EN/3.4.SyntaxAndSemanticsOfPredicateLogic.html)</sup>

## 自由变元与语句

公式中变元的出现分为自由出现和约束出现，取决于该出现是否位于量词的辖域之内。<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> 在 \( \forall x \, H(a,x,c) \) 中，变元 \( x \) 是约束的；而单独的 \( H(a,x,c) \) 中，它是自由的。<sup>[6](https://milnepublishing.geneseo.edu/concise-introduction-to-logic/chapter/12-all-and-some/)</sup> 不含变元自由出现的闭公式称为语句。<sup>[2](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)</sup> 语句是那些在结构中可以直接为真或为假的公式，而一个理论就是一个语句集。<sup>[15](https://www.uvm.edu/~cbcafier/cs-fundamentals/05_logic/predicate_logic.html)</sup>

## 从语法到意义

公式是语法层面的东西；意义通过语义学而来。塔斯基的真定义通过对公式结构的归纳来进行：原子公式的处理方式是问所指定的元组是否属于结构赋予该谓词的关系，而归纳子句则用直接构成部分来规定否定、析取和量化的真。<sup>[16](https://people.cs.umass.edu/~immerman/cs513/lect5Notes.pdf)</sup> 满足关系遵循这一递归，因为要知道哪些赋值满足一个复合公式，只需知道哪些赋值满足其直接构成部分。<sup>[17](https://plato.stanford.edu/archives/spr2017/entries/tarski-truth/)</sup> 当今使用的真定义的模型论版本，基于塔斯基与罗伯特·沃特（Robert Vaught）于1956年发表的版本。<sup>[18](https://plato.stanford.edu/entries/tarski-truth/)</sup>

语法与语义的区分也标明了良构性概念的界限。

## 历史背景

现代的这一概念源自戈特洛布·弗雷格（Gottlob Frege）的《概念文字》（1879），该书首次在形式逻辑中引入了量词，包括二阶量化，首次对多重和嵌套的量化作了形式处理，并首次表述了包含关系的逻辑系统。<sup>[4](https://frege.info/basiclaws/index.html)</sup> 在弗雷格成熟的项逻辑中，所有项和良构公式都是指称表达式，甚至语句也是指称真值的复合项。<sup>[19](https://plato.stanford.edu/entries/frege/)</sup>

良构性在计算方面也很重要。由于公式是可数字母表上的有限字符串，它们可以被编码为自然数的有限序列，这使得可计算性概念可以应用于公式集和理论。<sup>[13](https://www.encyclopedia.com/humanities/encyclopedias-almanacs-transcripts-and-maps/first-order-logic)</sup> 其结果是否定性的：丘奇定理发表于1936年，指出一阶逻辑的有效公式集不是能行可判定的，因此没有算法能判定哪些一阶公式是有效的。<sup>[5](https://www.rep.routledge.com/articles/thematic/churchs-theorem-and-the-decision-problem/v-1)</sup>

## 机器可读的公式

自动定理证明依赖于精确规定的公式语法。TPTP 库是一个面向自动定理证明器的测试问题集合，它以一阶形式（FOF）、子句范式（CNF）以及带类型的一阶和高阶形式存储问题，每个逻辑公式都包裹在带注释的公式记录中，并有已发布的 BNF 文法定义其语法。<sup>[20](https://tptp.org/UserDocs/TPTPLanguage/TPTPLanguage.shtml)</sup> 在此类语言中，公式中的每个变元都必须被前面具有足够辖域的量化所约束，括号则强制二元联结词的正确结合。<sup>[20](https://tptp.org/UserDocs/TPTPLanguage/TPTPLanguage.shtml)</sup>

## References

1. [Propositional logic, Clayton Cafiero, University of Vermont](https://www.uvm.edu/~cbcafier/cs-fundamentals/05_logic/propositional_logic.html)
2. [Temporal Logic, Supplement: First-order Relational Structures and Languages, Stanford Encyclopedia of Philosophy](https://plato.stanford.edu/Entries/logic-temporal/1st-order-relational.html)
3. [Syntax of First-Order Logic, CS 245, University of Waterloo](https://cs.uwaterloo.ca/~eblais/cs245e/f25/fol-syntax)
4. [Gottlob Frege: Basic Laws of Arithmetic, translated and edited by Philip A. Ebert and Marcus Rossberg](https://frege.info/basiclaws/index.html)
5. [Church's theorem and the decision problem, Routledge Encyclopedia of Philosophy](https://www.rep.routledge.com/articles/thematic/churchs-theorem-and-the-decision-problem/v-1)
6. ["All" and "Some", A Concise Introduction to Logic, Milne Publishing](https://milnepublishing.geneseo.edu/concise-introduction-to-logic/chapter/12-all-and-some/)
7. [Syntax of First-Order Logic, Open Logic Project](https://builds.openlogicproject.org/content/first-order-logic/first-order-logic.pdf)
8. [Summary of first order logic, A Concise Introduction to Logic, Milne Publishing](https://milnepublishing.geneseo.edu/concise-introduction-to-logic/chapter/16-summary-of-first-order-logic/)
9. [First Order Logic: A Brief Introduction, Supratik Chakraborty, IIT Bombay](https://www.cse.iitb.ac.in/~supratik/courses/cs719/fol.pdf)
10. [Well-Formed Formula for First Order Predicate Logic, Old Dominion University](https://www.cs.odu.edu/~toida/nerzic/level-a/logic/pred_logic/construction/wff_intro.html)
11. [Chapter 1. First-Order Logic, Universität Bielefeld](https://www.math.uni-bielefeld.de/~frettloe/papers/wikibuch.pdf)
12. [First-order logic: ingredients, Tibor Beke, University of Massachusetts Lowell](https://cpb-us-w2.wpmucdn.com/sites.uml.edu/dist/8/95/files/2018/10/oct-25-22tm159.pdf)
13. [First-Order Logic, Encyclopedia.com](https://www.encyclopedia.com/humanities/encyclopedias-almanacs-transcripts-and-maps/first-order-logic)
14. [Syntax and semantics of predicate logic, formallogic.eu](https://formallogic.eu/EN/3.4.SyntaxAndSemanticsOfPredicateLogic.html)
15. [Predicate logic, Clayton Cafiero, University of Vermont](https://www.uvm.edu/~cbcafier/cs-fundamentals/05_logic/predicate_logic.html)
16. [CS513 Lecture 5: First Order Logic via Tarski's Definition of Truth, Neil Immerman, UMass Amherst](https://people.cs.umass.edu/~immerman/cs513/lect5Notes.pdf)
17. [Tarski's Truth Definitions (Spring 2017 edition), Stanford Encyclopedia of Philosophy](https://plato.stanford.edu/archives/spr2017/entries/tarski-truth/)
18. [Tarski's Truth Definitions, Stanford Encyclopedia of Philosophy](https://plato.stanford.edu/entries/tarski-truth/)
19. [Gottlob Frege, Stanford Encyclopedia of Philosophy](https://plato.stanford.edu/entries/frege/)
20. [The TPTP Language, TPTP World](https://tptp.org/UserDocs/TPTPLanguage/TPTPLanguage.shtml)
21. [(SL02) Well-formed formula](https://philosophy.hku.hk/think/sl/wff.php?m=1)

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

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Logical calculi and logical syntax › Predicate logic › First-order syntax and formulas

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/well-formed-formula

English original: https://www.edgepedia.org/well-formed-formula
