# 自动机理论

**自动机理论**是理论计算机科学的一个分支，研究被称为自动机的抽象数学机器，以及它们所能识别的形式语言类。自动机是计算机的理想化模型：它逐符号地读取输入串，依据固定规则在有限或结构化的状态集内转移，并最终接受或拒绝该串。由于真实的计算机过于复杂，难以建立易于处理的数学理论，人们转而设计理想化的计算模型，每一个模型都捕捉与特定问题相关的计算侧面，而将其余部分隐藏起来。<sup>[1](https://www.cambridge.org/core/books/textbook-on-automata-theory/finite-automata/FE2B4782A05B3D2018AC28CFF859F6C5)</sup>

| 关键事实 | 详情 |
|---|---|
| 研究对象 | 抽象机器（自动机）及其所识别的形式语言，作为计算的理想化模型加以研究<sup>[1](https://www.cambridge.org/core/books/textbook-on-automata-theory/finite-automata/FE2B4782A05B3D2018AC28CFF859F6C5)</sup> |
| 基本模型 | 确定性有限自动机（DFA），一个五元组 (Q, Σ, δ, q₀, F)，其转移函数为 δ: Q × Σ → Q<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> |
| 核心结果 | 通过子集构造法，DFA 与 NFA 恰好定义同一个语言类，即正则语言<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> |
| 语言层级 | 正则语言、上下文无关语言、上下文相关语言与递归可枚举语言构成一个真层级（乔姆斯基层次）<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup><sup> • </sup><sup>[22](https://pmc.ncbi.nlm.nih.gov/articles/PMC3367686/)</sup> |
| 里程碑论文 | 麦卡洛克与皮茨（1943）；克莱尼（1956）；拉宾与斯科特（1959）<sup>[3](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)</sup><sup> • </sup><sup>[4](https://doi.org/10.1147/rd.32.0114)</sup> |
| 实际用途 | 编译器中的词法分析、协议规约、硬件设计，以及软件系统的模型学习<sup>[5](https://elearning.univ-biskra.dz/moodle2024/mod/resource/view.php?id=180320)</sup><sup> • </sup><sup>[6](https://link.springer.com/article/10.1007/s10270-024-01158-0)</sup> |

## 有限自动机

确定性有限自动机有五个组成部分：一个有限非空的状态集 Q，一个有限的输入字母表 Σ，一个把 Q × Σ 映射到 Q 的转移函数 δ，一个起始状态，以及一个终态或接受状态集 F。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> 机器从起始状态出发，每次读取一个输入符号，按照转移函数的规定从一个状态转移到另一个状态。如果最后一个符号读完后机器停在接受状态，它就接受该输入串；所有被接受的串构成的集合就是该自动机定义的语言，而由 DFA 定义的语言称为正则语言。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup>

有限自动机是理论中最简单的机器模型，因为它的存储是有限的，且其规模与输入长度无关。<sup>[3](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)</sup> 正是这一限制使该模型易于分析：一个两状态的 DFA 就足以识别含有偶数个 0 的二进制串，而一个三状态的 DFA 可以识别能被三整除的二进制数，每个状态对应一种模 3 的余数。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup>

**非确定性。** 非确定性有限自动机（NFA）对 DFA 作了放宽，允许其转移函数把一个状态和符号映射到一个状态子集，因此机器在每一步可以有零个、一个或多个可能的移动；只要存在一条从初始状态到终态的转移路径恰好拼出该输入串，就接受该串。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> 形式上，一个 NFA 是五元组 A = (Q, Σ, δ, Q₀, F)，其中 δ: Q × Σ → 2^Q，Q₀ 是初始状态集。<sup>[7](https://www.cs.bu.edu/faculty/kfoury/UNI-Teaching/CS512/AK_Documents/Automata_and_Omega_Automata/finite_automata%2Bbuchi_automata.pdf)</sup>

子集构造法是自动机理论的基本算法之一，它把任意 NFA 转换为一个等价的 DFA，该 DFA 并行模拟 NFA 的所有可能移动：DFA 的状态是 NFA 状态的子集，它在某个符号上的转移是 NFA 从当前子集中每个状态出发的转移之并，而其终态是包含 NFA 终态的那些子集。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> 这一构造证明了 NFA 在所定义的语言上并不比 DFA 更强，但代价可能很高：对于“倒数第 n 个字符是 a”的串语言，任何最小 DFA 都至少需要 2ⁿ 个状态。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup>

## 正则语言及其局限

正则表达式与有限自动机描述的是同一个语言类。每个正则表达式定义一个正则集，每个正则集也都由某个正则表达式定义；反过来，任何 NFA 所接受的词构成一个正则集，每个正则集也都由某个 NFA 识别。<sup>[7](https://www.cs.bu.edu/faculty/kfoury/UNI-Teaching/CS512/AK_Documents/Automata_and_Omega_Automata/finite_automata%2Bbuchi_automata.pdf)</sup>

并非所有语言都是正则的。泵引理给出了证明非正则性的标准方法：如果一个语言是正则的，那么存在一个泵长度 p，使得每个长度至少为 p 的词都可写成连接 w = xyz，其中中间部分可以重复任意多次而仍属于该语言。<sup>[8](https://www.cs.utep.edu/vladik/cs3350.23a/finalSolutions.pdf)</sup>

迈希尔–尼罗德定理在不提及自动机的情况下刻画了正则性。若两个串具有相同的延续集合，即把它们分别接在共同前缀之后总是得到相同的接受/拒绝结果，则称这两个串等价；于是，一个语言是正则的当且仅当这种等价关系只有有限多个等价类。<sup>[9](https://www.maths.tcd.ie/~stalker/11602/notes/10.8-the-myhill-nerode-theorem.html)</sup> 该定理还为每个正则语言给出唯一的最小 DFA，其构造方式是合并等价状态，并且它给出了给定语言的 DFA 所需状态数的最优下界。<sup>[10](https://courses.cs.cornell.edu/courses/cs4120/2026sp/notes.html?id=leximpl)</sup><sup> • </sup><sup>[11](https://www.cs.princeton.edu/courses/archive/fall19/cos487/NoteMyhillNerode.pdf)</sup>

## 超越有限存储

乔姆斯基层次把自动机所能识别的语言组织成一个真包含的类链：正则语言、上下文无关语言、上下文相关语言与递归可枚举语言，每一类都严格包含前一类。<sup>[2](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)</sup> 层次中每上升一级，都对应一个更丰富的机器模型。

**下推自动机**在有限控制之上增加一个栈，赋予机器一种受限形式的无界存储。它们恰好识别上下文无关语言，而非确定性下推自动机可以转换为等价的上下文无关文法，反之亦然。<sup>[12](https://syllabus.uncg.edu/CSC-752-Theory-of-Computation-01-Fall-2026)</sup><sup> • </sup><sup>[13](https://users.cms.caltech.edu/~umans/cs21/)</sup> 这一对应关系是编译器语法分析的基础，其中上下文无关文法描述编程语言的句法结构。<sup>[12](https://syllabus.uncg.edu/CSC-752-Theory-of-Computation-01-Fall-2026)</sup> 上下文无关语言的泵引理在这一层级上扮演的角色，正如正则泵引理在更低层级所扮演的角色，它提供了证明某些语言不是上下文无关的方法。<sup>[14](https://arxiv.org/abs/1403.6230)</sup>

**图灵机**位于层次的顶端。图灵机在结构上并不比有限自动机或下推自动机复杂多少，但其无界纸带赋予了它完整的计算能力。<sup>[15](https://math.hws.edu/FoundationsOfComputation/FoundationsOfComputation_2.3.2_8.5x11.pdf)</sup> 可以证明，图灵机在计算能力上等价于带有两个独立栈的下推自动机。<sup>[15](https://math.hws.edu/FoundationsOfComputation/FoundationsOfComputation_2.3.2_8.5x11.pdf)</sup> 在这一层级上，理论转向不可判定性：赖斯定理确立了图灵机所识别语言的非平凡性质是不可判定的，这标志着算法计算的界限。<sup>[16](https://ocw.mit.edu/courses/6-045j-automata-computability-and-complexity-spring-2011/7aead2c728dd3d5a737d832811ef97e6_MIT6_045JS11_lec09.pdf)</sup>

## 历史

1943 年的论文《神经活动中内在思想的逻辑演算》，作者是神经精神病学家沃伦·麦卡洛克（Warren McCulloch）与数学家沃尔特·皮茨（Walter Pitts），通常被视为两个领域的开端：作为计算模型的有限状态机理论，以及人工神经网络。<sup>[17](https://www.dlsi.ua.es/~mlf/nnafmc/pbook/node10.html)</sup> 该论文提出了一个神经元与突触的逻辑模型，意在描述人脑的行为。<sup>[18](https://www.treccani.it/enciclopedia/la-grande-scienza-automi-e-linguaggi-formali_%28Storia-della-Scienza%29/)</sup>

在这些思想的基础上，数学家斯蒂芬·科尔·克莱尼（Stephen Cole Kleene，1909–1994）于 1956 年写出了第一篇关于有限自动机与正则表达式的论文《神经网与有限自动机中事件的表示》，发表于 C. E. 香农与 J. 麦卡锡主编的文集《自动机研究》中。<sup>[3](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)</sup><sup> • </sup><sup>[19](https://www.jstor.org/stable/j.ctt1bgzb3s)</sup> 克莱尼把他记法所描述的模式称为“正则事件”；同样的对象如今被称为正则表达式。<sup>[17](https://www.dlsi.ua.es/~mlf/nnafmc/pbook/node10.html)</sup> 克莱尼定理确立了他的自动机与正则集之间的等价性，无论在时间上还是在学科地位上，都被视为自动机理论的第一个重要定理。<sup>[20](https://www.sciencedirect.com/science/article/pii/S0079816908608818)</sup>

1959 年，迈克尔·拉宾（Michael Rabin）与达纳·斯科特（Dana Scott）在《IBM 研究与发展杂志》（第 3 卷，第 114–125 页）上发表了《有限自动机及其判定问题》，以更简单的数学模型呈现有限自动机，并研究其判定问题，其中一些可由有效算法求解，另一些则不可解。<sup>[3](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)</sup><sup> • </sup><sup>[4](https://doi.org/10.1147/rd.32.0114)</sup> 尽管克莱尼早先的模型更为复杂，两种表述在表达力上是等价的。<sup>[3](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)</sup>

## 应用

凡是系统行为仅依赖于输入的有界历史之处，都会用到有限自动机。有文献记载的应用领域包括编译器设计——其中词法分析扫描程序并识别变量、关键字和数字等记号；专用硬件设计；实时应用；以及协议规约。<sup>[5](https://elearning.univ-biskra.dz/moodle2024/mod/resource/view.php?id=180320)</sup> 词法分析器生成器的工作原理就是把正则表达式转换为确定性有限自动机。<sup>[10](https://courses.cs.cornell.edu/courses/cs4120/2026sp/notes.html?id=leximpl)</sup> 其他例子还包括自动售货机、文本解析、交通灯控制器和电子游戏关卡，其中游戏状态对应于自动机状态。<sup>[5](https://elearning.univ-biskra.dz/moodle2024/mod/resource/view.php?id=180320)</sup>

**自动机学习**把这一理论引向另一个方向：不是手工设计自动机，而是由算法从对系统行为的观察中推断出状态机模型。该领域始于 20 世纪 70 年代，并在达纳·安格卢因（Dana Angluin）的 L* 算法与“最小充分教师”框架下形成现代形态：学习器向教师提出成员查询与等价查询，教师可以用目标语言与学习器当前假设的对称差中的一个反例词来作答。<sup>[6](https://link.springer.com/article/10.1007/s10270-024-01158-0)</sup><sup> • </sup><sup>[21](https://sfortz.github.io/publication/2026-al-agenda/2026-al-agenda.pdf)</sup> 主动自动机学习推断出具有保证性质的简洁模型，如最小性与收敛保证，并被应用于软件工程任务，包括规约生成、基于学习的测试和黑箱验证。<sup>[21](https://sfortz.github.io/publication/2026-al-agenda/2026-al-agenda.pdf)</sup> L* 的扩展涵盖 Mealy 机、非确定性自动机、时间自动机和随机模型。<sup>[6](https://link.springer.com/article/10.1007/s10270-024-01158-0)</sup>

## References

1. [Finite Automata (Chapter 4), A Textbook on Automata Theory, Cambridge Core](https://www.cambridge.org/core/books/textbook-on-automata-theory/finite-automata/FE2B4782A05B3D2018AC28CFF859F6C5)
2. [COMS W3261 Lecture 2: Finite Automata and Regular Languages, Columbia University](https://www.cs.columbia.edu/~aho/cs3261/Lectures/L2-Finite_Automata.html)
3. [Regular Languages and Finite Automata, Hing Leung, Mathematical Association of America](https://old.maa.org/press/periodicals/convergence/regular-languages-and-finite-automata)
4. [Rabin, M. O. and Scott, D. (1959). Finite Automata and Their Decision Problems, IBM Journal of Research and Development](https://doi.org/10.1147/rd.32.0114)
5. [Formal Languages course notes, University of Biskra](https://elearning.univ-biskra.dz/moodle2024/mod/resource/view.php?id=180320)
6. [Active model learning of stochastic reactive systems, Software and Systems Modeling, Springer](https://link.springer.com/article/10.1007/s10270-024-01158-0)
7. [Finite Automata and Büchi Automata, lecture notes by Assaf Kfoury, Boston University](https://www.cs.bu.edu/faculty/kfoury/UNI-Teaching/CS512/AK_Documents/Automata_and_Omega_Automata/finite_automata%2Bbuchi_automata.pdf)
8. [Beyond finite automata: pushdown automata and context-free grammars, University of Texas at El Paso](https://www.cs.utep.edu/vladik/cs3350.23a/finalSolutions.pdf)
9. [The Myhill-Nerode theorem, Trinity College Dublin lecture notes](https://www.maths.tcd.ie/~stalker/11602/notes/10.8-the-myhill-nerode-theorem.html)
10. [DFA minimization, CS 4120 course notes, Cornell University](https://courses.cs.cornell.edu/courses/cs4120/2026sp/notes.html?id=leximpl)
11. [The Myhill-Nerode theorem, CS 487 notes, Princeton University](https://www.cs.princeton.edu/courses/archive/fall19/cos487/NoteMyhillNerode.pdf)
12. [Theory of Computation syllabus, CSC 752, University of North Carolina at Greensboro](https://syllabus.uncg.edu/CSC-752-Theory-of-Computation-01-Fall-2026)
13. [CS 21 course schedule, Caltech](https://users.cms.caltech.edu/~umans/cs21/)
14. [Pumping lemma and Ogden lemma for displacement context-free grammars, arXiv](https://arxiv.org/abs/1403.6230)
15. [Foundations of Computation, textbook PDF](https://math.hws.edu/FoundationsOfComputation/FoundationsOfComputation_2.3.2_8.5x11.pdf)
16. [MIT 6.045J Lecture 9: Rice's Theorem, MIT OpenCourseWare](https://ocw.mit.edu/courses/6-045j-automata-computability-and-complexity-spring-2011/7aead2c728dd3d5a737d832811ef97e6_MIT6_045JS11_lec09.pdf)
17. [McCulloch and Pitts' neural logical calculus, University of Alicante](https://www.dlsi.ua.es/~mlf/nnafmc/pbook/node10.html)
18. [La grande scienza: automi e linguaggi formali, Treccani Encyclopedia](https://www.treccani.it/enciclopedia/la-grande-scienza-automi-e-linguaggi-formali_%28Storia-della-Scienza%29/)
19. [Automata Studies (AM-34), JSTOR, Princeton University Press, 1956](https://www.jstor.org/stable/j.ctt1bgzb3s)
20. [Chapter VII Rational Sets, ScienceDirect](https://www.sciencedirect.com/science/article/pii/S0079816908608818)
21. [A research agenda for active automata learning, Fortz et al.](https://sfortz.github.io/publication/2026-al-agenda/2026-al-agenda.pdf)
22. [pmc.ncbi.nlm.nih.gov](https://pmc.ncbi.nlm.nih.gov/articles/PMC3367686/)

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

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Formal languages and automata theory

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/automata-theory

English original: https://www.edgepedia.org/automata-theory
