# 产生式系统（计算机科学）

产生式系统是人工智能中一种基于规则的计算方法，其中一组条件—动作规则、一个工作记忆和一个规则解释器共同从数据中推导出新的事实或动作。解释器反复将规则条件与[工作记忆](https://www.edgepedia.org/zh/working-memory)进行匹配，在匹配的规则之间消解冲突，并执行一条规则的动作，这些动作会添加或删除工作记忆元素；这种数据驱动的执行方式即前向链接。由于规则仅通过共享的工作记忆进行交互，这种格式被证明非常适合专家系统，后来又适用于认知架构。<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup><sup> • </sup><sup>[2](https://www.cs.utexas.edu/~mooney/cs343/slide-handouts/inference-sys.4.pdf)</sup><sup> • </sup><sup>[3](http://www0.cs.ucl.ac.uk/staff/r.m.young/publications/00.PS-encyc-article.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 组成部分 | 一组规则、一个工作记忆（数据库）和一个规则解释器<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup> |
| 执行周期 | 匹配、冲突消解、执行；当没有规则条件与工作记忆匹配时循环停止<sup>[4](https://www.cs.unm.edu/~luger/ai-final2/CH4_Depth-.%20Breadth-,%20and%20Best-first%20Search.pdf)</sup> |
| 匹配开销 | 某些系统将超过十分之九的总运行时间花在模式匹配上<sup>[5](https://doi.org/10.1016/0004-3702%2882%2990020-0)</sup> |
| Rete算法 | 将规则编译为网络并保存匹配状态；用于具有数百到一千多个模式和对象的系统<sup>[5](https://doi.org/10.1016/0004-3702%2882%2990020-0)</sup> |
| 冲突消解 | OPS按字典序应用折射、近因、特异性、规则顺序和随机决胜<sup>[6](http://www.cogsys.org/courses/langley/aicogsys11/notes/ps.pdf)</sup> |
| 扩展性 | 在100,000条规则下，Rete/UL算法的运行速度约为Rete的100倍<sup>[7](http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf)</sup> |
| 认知时序 | 在人类行为的ACT-R模型中，一条产生式大约需要50毫秒来选择和应用<sup>[8](https://arxiv.org/pdf/2201.09305)</sup> |

## 工作原理

产生式系统持有两种记忆。产生式记忆是长期记忆，存储规则；工作记忆（数据记忆）是短期记忆，保存规则条件所测试的任务信息，表示为一组无序的无变量工作记忆元素（WME）。<sup>[3](http://www0.cs.ucl.ac.uk/staff/r.m.young/publications/00.PS-encyc-article.pdf)</sup><sup> • </sup><sup>[9](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)</sup> 一条带有条件和动作的规则在某个替换 \( \sigma \) 使每个条件在 \( \sigma \) 下都成为WME时被触发；它通过在 \( \sigma \) 下执行每个动作来执行规则，通常是添加或删除WME。<sup>[9](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)</sup>

解释器运行一个识别—执行周期：将条件与工作记忆匹配，将触发的实例化收集到冲突集中，选择一个并执行它，重复直到没有规则被触发。<sup>[9](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)</sup><sup> • </sup><sup>[4](https://www.cs.unm.edu/~luger/ai-final2/CH4_Depth-.%20Breadth-,%20and%20Best-first%20Search.pdf)</sup> 由于每个周期基于工作记忆的全部内容进行选择，被启用的实例化由当前工作记忆决定；高效的实现会在工作记忆变化时增量更新它们，避免每个周期进行完整重新评估。<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup> 工作记忆是唯一的状态存储：没有单独的程序计数器或栈，这一特性称为数据与控制存储的统一。<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup> 纽厄尔的认知表述假设唤醒时间与产生式数量、短期记忆内容以及被唤醒产生式的条件无关，具有 \( N \) 个动作的产生式需要 \( T_{\mathrm{production}} = T_{\mathrm{evoke}} + N \cdot T_{\mathrm{action}} \)。<sup>[10](http://doi.library.cmu.edu/10.1184/OCLC/240474312)</sup>

## 实现方法

一个周期分四步进行。第一步，匹配：解释器找到规则实例化；OPS解释器执行完整搜索，找到每条产生式的每个合法实例化，这与其前身PSG不同，后者的匹配取决于条件元素的顺序。<sup>[11](https://www.ijcai.org/Proceedings/77-2/Papers/081.pdf)</sup> 第二步，冲突消解选择一个实例化。OPS谱系按字典序应用五种策略：折射（不选择已应用的实例）、近因（偏好匹配更新近元素的实例）、特异性（偏好更专门的条件）、规则顺序和随机决胜。<sup>[6](http://www.cogsys.org/courses/langley/aicogsys11/notes/ps.pdf)</sup> CLIPS提供七种模式：深度（默认）、广度、LEX、MEA、复杂度、简单度和随机。<sup>[12](https://www.clipsrules.net/documentation/v631/ug631.pdf)</sup> MYCIN的控制结构是目标导向的反向链接，其元规则通过修剪或重排为某个目标考虑的规则列表来引导该过程，这类似于让规则修改解释器。<sup>[13](https://www.ijcai.org/Proceedings/77-2/Papers/080.pdf)</sup> 第三步，执行：所选规则的动作更新工作记忆。纯模型在没有启用项时简单地停止，没有从搜索死胡同恢复的机制；实际实现添加了回溯到先前工作记忆状态的功能。<sup>[4](https://www.cs.unm.edu/~luger/ai-final2/CH4_Depth-.%20Breadth-,%20and%20Best-first%20Search.pdf)</sup>

每个周期重新测试所有规则的朴素匹配效率太低。<sup>[2](https://www.cs.utexas.edu/~mooney/cs343/slide-handouts/inference-sys.4.pdf)</sup> Rete算法由查尔斯·L·福吉（Charles L. Forgy）于1982年在《人工智能》（Artificial Intelligence）上发表，将规则编译为判别网络，通常是一个有向无环图，具有共享节点和位于终端的产生式节点：每个WME的标记通过alpha节点（简单测试）和beta节点（跨条件约束），在测试失败时停止。<sup>[5](https://doi.org/10.1016/0004-3702%2882%2990020-0)</sup><sup> • </sup><sup>[9](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)</sup> 其速度依赖于在工作记忆变化之间在alpha和beta记忆中保存匹配结果的状态，以及在重复测试序列的产生式之间共享节点。<sup>[7](http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf)</sup><sup> • </sup><sup>[14](http://i.stanford.edu/pub/cstr/reports/cs/tr/86/1124/CS-TR-86-1124.pdf)</sup> 它假设固定的规则记忆、轻微变化的工作记忆、无变量WME、数据驱动执行和共享条件。<sup>[9](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)</sup><sup> • </sup><sup>[5](https://doi.org/10.1016/0004-3702%2882%2990020-0)</sup>

## 起源

该名称来自埃米尔·波斯特（Emil Post）1943年发表于《美国数学杂志》（American Journal of Mathematics）的论文《一般组合判定问题的形式归约》（Formal Reductions of the General Combinatorial Decision Problem），其中他的形式系统的各个规则被称为“产生式”；可计算性中的相关形式工作建立在这种字符串重写系统风格之上。<sup>[15](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)</sup><sup> • </sup><sup>[16](https://doi.org/10.2307/2371809)</sup> 产生式系统被采用来建模人类问题解决，这项工作在《人类问题解决》（Human Problem Solving，1972年）中获得了广泛传播。<sup>[15](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)</sup> 第一个实现的产生式系统语言谱系经由PSG，记录在纽厄尔（Newell）和麦克德莫特（McDermott）1975年的手册中，后来成为OPS的前身。<sup>[11](https://www.ijcai.org/Proceedings/77-2/Papers/081.pdf)</sup> 20世纪70年代中期，D·A·沃特曼（D. A. Waterman）1974年关于自适应产生式系统的报告引入了构建操作，赋予产生式系统第一个有用的学习能力。<sup>[17](https://doi.org/10.21236/ada013570)</sup><sup> • </sup><sup>[15](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)</sup> 斯坦福Dendral项目在20世纪60年代末采用了这种组织方式，MYCIN医疗咨询程序使用了并行规则组织，确立了产生式系统作为应用AI的主要候选方案。<sup>[15](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)</sup>

## 变体

**OPS5和OPS83**是纯产生式系统的语言；OPS5提供了冲突消解过程，允许用户实现自己的策略，其解释器包括高效匹配算法和调试工具。<sup>[15](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)</sup> OPS83沿同一谱系后继。<sup>[18](https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&identifierValue=10.4324%2F9781315806938&type=googlepdf)</sup> **CLIPS**（C语言集成产生式系统）是一种专家系统工具，其七种冲突消解模式已在上文列出。<sup>[12](https://www.clipsrules.net/documentation/v631/ug631.pdf)</sup> **Drools**是一种混合推理系统，同时使用前向和反向链接并具有真值维护；其Phreak算法从Rete和增强的ReteOO演变而来，是惰性的（延迟评估）和目标导向的，而非立即求值和数据导向的，具有节点、段和规则记忆层、基于位掩码的链接以及基于栈的暂停—恢复评估。<sup>[19](https://docs.jboss.org/drools/release/latest/drools-docs/drools/rule-engine/index.html)</sup><sup> • </sup><sup>[20](https://docs.drools.org/6.5.0.Final/drools-docs/html/ch05.html)</sup> **Soar**将长期程序性知识存储为产生式规则，并运行五阶段决策周期，在子状态中解决僵局并通过分块学习，将解决僵局的实例化组合成新的产生式。<sup>[21](https://soar.eecs.umich.edu/soar_manual/02_TheSoarArchitecture/)</sup><sup> • </sup><sup>[22](https://doi.org/10.7551/mitpress/7688.001.0001)</sup> **ACT-R**将认知技能视为由产生式规则组成；其工作记忆是一组固定的模块缓冲区，保存块，而Soar的工作记忆是无限制的元素图。<sup>[18](https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&identifierValue=10.4324%2F9781315806938&type=googlepdf)</sup><sup> • </sup><sup>[8](https://arxiv.org/pdf/2201.09305)</sup>

## 应用

产生式系统驱动了经典专家系统：MYCIN用于医疗咨询，R1用于配置计算机系统；从MYCIN创建的EMYCIN是最早的专家系统外壳之一。<sup>[18](https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&identifierValue=10.4324%2F9781315806938&type=googlepdf)</sup><sup> • </sup><sup>[20](https://docs.drools.org/6.5.0.Final/drools-docs/html/ch05.html)</sup> 基于Soar的系统包括TacAirSoar等合成角色；相比之下，卡内基学习（Carnegie Learning）的认知导师（Cognitive Tutors）基于[ACT-R](https://www.edgepedia.org/zh/act-r)而非Soar。<sup>[6](http://www.cogsys.org/courses/langley/aicogsys11/notes/ps.pdf)</sup> 认知产生式系统模型可能达到数千条规则。<sup>[3](http://www0.cs.ucl.ac.uk/staff/r.m.young/publications/00.PS-encyc-article.pdf)</sup>

## 局限与替代方案

匹配主导执行：在OPS5中，如同许多产生式系统，匹配过程通常主导所有其他计算并决定执行速度。<sup>[14](http://i.stanford.edu/pub/cstr/reports/cs/tr/86/1124/CS-TR-86-1124.pdf)</sup> Rete和TREAT在规则数量上都呈线性减慢，这为学习新规则的系统带来了效用问题；在100,000条规则下，Rete/UL的运行速度约为Rete的100倍。<sup>[7](http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf)</sup> 标准控制策略均不具备防止组合爆炸的内在能力。<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup> 与过程式形式化相比，逐步行为通常不透明，控制知识通常埋藏在代码中，因此系统难以解释其问题解决策略，构建者也难以修改它。<sup>[1](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)</sup> 产生式系统也缺乏逻辑语义，完全通过副作用工作，而Prolog将程序表示为霍恩子句，通过深度优先搜索的反向链接执行，不保证终止。<sup>[6](http://www.cogsys.org/courses/langley/aicogsys11/notes/ps.pdf)</sup><sup> • </sup><sup>[2](https://www.cs.utexas.edu/~mooney/cs343/slide-handouts/inference-sys.4.pdf)</sup> DADO2、NON-VON和产生式系统机器等专用并行机器被设计来加速匹配阶段。<sup>[23](https://dl.acm.org/doi/10.1145/54331.54339)</sup> 在神经网络方面，神经产生式系统使规则可微分：每条规则是一个独立的MLP，具有用于规则—实体绑定的查询—键注意力，规则选择使用直通Gumbel softmax，\( r = \arg\max_{i}(q_{p} \cdot k_{i} + \gamma_{i}) \)，每个候选具有独立的 \( \gamma_{i} \sim \mathrm{Gumbel}(0,1) \)，其中软松弛提供直通梯度，在鲁棒未来状态预测上优于GNN方法。<sup>[24](https://proceedings.neurips.cc/paper_files/paper/2021/file/d785bf9067f8af9e078b93cf26de2b54-Paper.pdf)</sup>

## References

1. [Rule-Based Expert Systems: The MYCIN Experiments, chapter on Production Systems (Buchanan & Shortliffe, 1984)](https://people.dbmi.columbia.edu/~ehs7001/Buchanan-Shortliffe-1984/Chapter-02.pdf)
2. [Rule-Based Programming Languages (R. Mooney, UT Austin slides)](https://www.cs.utexas.edu/~mooney/cs343/slide-handouts/inference-sys.4.pdf)
3. [Production Systems in Cognitive Psychology (R. M. Young, encyclopedia article)](http://www0.cs.ucl.ac.uk/staff/r.m.young/publications/00.PS-encyc-article.pdf)
4. [Depth-, Breadth-, and Best-First Search Using the Production System Design Pattern (Luger)](https://www.cs.unm.edu/~luger/ai-final2/CH4_Depth-.%20Breadth-,%20and%20Best-first%20Search.pdf)
5. [Rete: A fast algorithm for the many pattern/many object pattern match problem (Artificial Intelligence, 1982)](https://doi.org/10.1016/0004-3702%2882%2990020-0)
6. [Notes for Meeting 12: Production Systems (Pat Langley)](http://www.cogsys.org/courses/langley/aicogsys11/notes/ps.pdf)
7. [Rete/UL: An Improved Match Algorithm for Production Systems (CMU-CS-95-113, Doorenbos)](http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf)
8. [A detailed comparison of ACT-R and Soar representations and processes](https://arxiv.org/pdf/2201.09305)
9. [Knowledge Representation and Reasoning, Chapter 12: Production Systems (Stuart C. Shapiro, SUNY Buffalo)](https://cse.buffalo.edu/~shapiro/Courses/CSE563/Slides/chap12.pdf)
10. [Production Systems: Models of Control Structures (Allen Newell, CMU)](http://doi.library.cmu.edu/10.1184/OCLC/240474312)
11. [The OPS Language and Compiler (Forgy and McDermott, IJCAI 1977)](https://www.ijcai.org/Proceedings/77-2/Papers/081.pdf)
12. [CLIPS User's Guide (v6.31)](https://www.clipsrules.net/documentation/v631/ug631.pdf)
13. [Less Than General Production System Architectures (IJCAI 1977)](https://www.ijcai.org/Proceedings/77-2/Papers/080.pdf)
14. [Efficient Matching Algorithms for the SOAR/OPS5 Production System (Stanford CS-TR-86-1124)](http://i.stanford.edu/pub/cstr/reports/cs/tr/86/1124/CS-TR-86-1124.pdf)
15. [Production Systems: Introduction and Issues (Allen Newell, CMU)](http://iiif.library.cmu.edu/file/Newell_box00033_fld02251_doc0001/Newell_box00033_fld02251_doc0002.pdf)
16. [Emil L. Post (1943). Formal Reductions of the General Combinatorial Decision Problem. American Journal of Mathematics.](https://doi.org/10.2307/2371809)
17. [D. A. Waterman (1974). Adaptive Production Systems. .](https://doi.org/10.21236/ada013570)
18. [The Atomic Components of Thought (ACT-R, Anderson), chapter on production rules](https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&identifierValue=10.4324%2F9781315806938&type=googlepdf)
19. [Drools rule engine :: Drools Documentation (latest)](https://docs.jboss.org/drools/release/latest/drools-docs/drools/rule-engine/index.html)
20. [Chapter 5. Hybrid Reasoning (Drools 6.5 documentation)](https://docs.drools.org/6.5.0.Final/drools-docs/html/ch05.html)
21. [The Soar Architecture (Soar manual chapter)](https://soar.eecs.umich.edu/soar_manual/02_TheSoarArchitecture/)
22. [John E. Laird (2012). The Soar Cognitive Architecture. The MIT Press eBooks.](https://doi.org/10.7551/mitpress/7688.001.0001)
23. [Comparing production system architectures](https://dl.acm.org/doi/10.1145/54331.54339)
24. [Neural Production Systems (NeurIPS 2021)](https://proceedings.neurips.cc/paper_files/paper/2021/file/d785bf9067f8af9e078b93cf26de2b54-Paper.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/production-system-computer-science

English original: https://www.edgepedia.org/production-system-computer-science
