# 概率逻辑编程

概率逻辑编程（PLP）是一族编程语言方法，它们把逻辑程序与概率分布结合起来，使单个程序能够表示不确定的关系知识，并计算关于这些知识的查询答案。一个程序定义了一个在普通逻辑程序上的分布，而任何查询的概率都由该分布推出。<sup>[1](https://ml.unife.it/wp-content/uploads/2022/08/2022ICLP_Invited_Riguzzi.pdf)</sup> 这一方法构成了包括 ICL、PRISM、LPADs、ProbLog 和 P-log 在内的语言与系统的基础。<sup>[2](https://dl.acm.org/doi/10.1145/3191315.3191319)</sup>

| 关键事实 | 详情 |
|---|---|
| 程序计算什么 | 在可能世界（普通逻辑程序）上的一个分布；查询的概率是查询为真的那些世界的概率之和<sup>[3](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)</sup> |
| 概率事实 | 一个标有 p 的事实使每个基实例化以概率 \( p \) 为真、以概率 \( 1 - p \) 为假；一个世界的概率是这些因子的乘积<sup>[3](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)</sup> |
| 表达力 | ICL、PRISM、pD、LPADs 和 ProbLog 具有相同的表达力；LPADs 提供最一般的语法<sup>[4](https://doi.org/10.1017/s1471068411000664)</sup> |
| 精确推断 | 归约为对 d-DNNF 编译结果的加权模型计数；最坏情况成本随被编译公式的树宽呈指数增长<sup>[5](https://doi.org/10.1017/s1471068414000076)</sup> |
| 近似推断 | k 最佳解释、迭代加深所得的上下界，以及对世界或子程序的蒙特卡洛采样<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> |
| 学习 | 通过 EM（PRISM、LFI-ProbLog、EMBLEM、ProbLog2）或梯度下降（LeProbLog）学习参数；通过 SEM-CP-logic、SLIPCASE 和 SLIPCOVER 学习结构<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> |
| 应用 | 生物学、医学、链接预测和文本分类；与 Alchemy 等统计关系学习系统相比具有竞争力<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> |

## 工作原理

分布语义定义了概率逻辑程序计算什么。程序在正规逻辑程序上诱导出一个概率分布，这些正规逻辑程序称为实例、可能世界，或简称世界。<sup>[1](https://ml.unife.it/wp-content/uploads/2022/08/2022ICLP_Invited_Riguzzi.pdf)</sup> 该分布被扩展为世界与查询的联合分布，而查询的概率由该联合分布得到：它是目标在其中可证明的所有世界（子句集合）的概率之和。<sup>[1](https://ml.unife.it/wp-content/uploads/2022/08/2022ICLP_Invited_Riguzzi.pdf)</sup><sup> • </sup><sup>[7](https://lmcs.episciences.org/6967/pdf)</sup>

在 ProbLog 中，写作 \( p::A \) 的概率事实意味着 A 的每个基实例化都以概率 \( p \) 为真、以概率 \( 1 - p \) 为假，且彼此独立。一个世界的概率是每个在该世界中包含或排除的基概率事实所对应的因子 \( p \) 或 \( 1 - p \) 的乘积。<sup>[3](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)</sup> ProbLog 用带有相互独立概率标签的概率事实扩展 Prolog，其语义与早期的概率数据库语义和逻辑程序语义密切对应。<sup>[8](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)</sup>

## 实现方式

**精确推断。** 对于正确定程序，每个查询证明对应一个概率事实的合取，而查询概率是二元随机变量上的单调析取范式公式的概率，该问题是 NP 难的。<sup>[8](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)</sup> 用容斥原理直接求值在解释数量上呈指数增长。<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> ProbLog 则把解释编译成二元决策图（Binary Decision Diagrams，BDDs），这为在更一般的逻辑程序类上进行推断提供了计算基础。<sup>[2](https://dl.acm.org/doi/10.1145/3191315.3191319)</sup> ProbLog2 将程序、查询和证据转换为加权布尔公式，并把推断归约为加权模型计数，编译 d-DNNF 电路而非 BDD。<sup>[5](https://doi.org/10.1017/s1471068414000076)</sup>

**近似推断。** ProbLog 只保留 k 个最可能的解释以降低 BDD 成本，并提供一种有界近似：利用带概率阈值的不完整 SLD 树给出的上下界。<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup><sup> • </sup><sup>[9](https://lirias.kuleuven.be/retrieve/10ed2127-227e-4076-93e0-94285d2fb083)</sup> 采样方法把查询概率估计为查询成立的采样世界或随机子程序所占比例；ProbLog 将采样与证明搜索交错进行，并每隔 m 个样本检查 95% 置信区间的宽度。<sup>[10](https://link.springer.com/content/pdf/10.1007/s10994-015-5494-z.pdf)</sup><sup> • </sup><sup>[11](https://ar5iv.labs.arxiv.org/html/1009.3798)</sup>

**规模。** 即使只有几十条边的小图，两个节点之间也可能有 \( 10^{6} \) 数量级的可能路径，使 DNF 求值不可行。<sup>[9](https://lirias.kuleuven.be/retrieve/10ed2127-227e-4076-93e0-94285d2fb083)</sup> pD 实现的朴素容斥在约 10 个或更多合取项时就变得不可行，而 ProbLog 的近似能处理最多 100,000 个合取项的公式。<sup>[8](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)</sup>

**学习。** 从解释进行参数学习时，使用建立在推断算法之上的 EM（期望最大化），见于 PRISM、LFI-ProbLog、EMBLEM 和 ProbLog2 等系统；或使用梯度下降，如 LeProbLog。<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> 结构与[参数](https://www.edgepedia.org/zh/parameter)由 SEM-CP-logic、SLIPCASE 和 SLIPCOVER 联合学习。<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup>

## 起源

综述性历史把该领域的开端定在 20 世纪 90 年代初。<sup>[3](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)</sup> PRISM 语言由佐藤泰介（Taisuke Sato）和龟谷义高（Yoshitaka Kameya）于 1997 年提出，作为一种用于符号-统计建模的语言；一个 PRISM 程序 DB 是一组确定子句，写作 DB = F ∪ R，其中 F 是一组事实（单位子句），R 是一组规则（非单位子句）。用于在不确定性下建模多个智能体的独立选择逻辑（Independent Choice Logic）由大卫·普尔（David Poole）于 1997 年在《人工智能》（Artificial Intelligence）上提出。<sup>[12](https://doi.org/10.1016/s0004-3702%2897%2900027-1)</sup> CP-logic 是一种因果概率事件语言，由约斯特·文内肯斯（Joost Vennekens）、马克·德内克（Marc Denecker）和莫里斯·布鲁诺赫（Maurice Bruynooghe）于 2009 年在《逻辑程序设计理论与实践》（Theory and Practice of Logic Programming）上提出。<sup>[13](https://doi.org/10.1017/s1471068409003767)</sup> 带制表与答案归并的概率推断（Probabilistic Inference with Tabling and Answer subsumption，PITA）由法布里齐奥·里古齐（Fabrizio Riguzzi）和特伦斯·斯威夫特（Terrance Swift）于 2012 年在《逻辑程序设计理论与实践》上提出。<sup>[4](https://doi.org/10.1017/s1471068411000664)</sup> ProbLog2 在加权布尔公式上的推断与学习框架由达安·菲伦斯（Daan Fierens）及其同事于 2014 年在《逻辑程序设计理论与实践》上提出。<sup>[5](https://doi.org/10.1017/s1471068414000076)</sup> 代数模型计数（Algebraic model counting）由安格莉卡·基米希（Angelika Kimmig）、盖伊·范登布鲁克（Guy Van den Broeck）和吕克·德·拉特（Luc De Raedt）于 2016 年在《应用逻辑杂志》（Journal of Applied Logic）上提出。<sup>[14](https://doi.org/10.1016/j.jal.2016.11.031)</sup>

## 变体

分布语义是包括概率逻辑程序、概率霍恩溯因、PRISM、独立选择逻辑、pD、LPADs、ProbLog、P-log 和 CP-logic 在内的一族语言的基础。<sup>[3](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)</sup> 这些语言具有相同的表达力，因为一种语言可以翻译成另一种；但 LPADs（Logic Programs with Annotated Disjunctions，带注释析取逻辑程序）提供了最一般的语法，因为其他语言的结构可以直接编码到其中。<sup>[4](https://doi.org/10.1017/s1471068411000664)</sup> 它们侧重不同：PRISM 程序是带不动点语义的确定子句集合，ProbLog 用独立概率给子句加标签，<sup>[8](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)</sup> 而 CP-logic 描述因果概率事件。<sup>[13](https://doi.org/10.1017/s1471068409003767)</sup>

各系统的区别主要在推断机制。PITA 为每个子目标构建解释，用 BDD 紧凑地表示这些解释，并利用带答案归并的制表；在基准测试中，它在大多数情况下比 cplint、CVE 和 ProbLog 解决了更复杂的查询，并且在有函数符号和无函数符号的数据集上几乎总是更快。<sup>[4](https://doi.org/10.1017/s1471068411000664)</sup> 该领域的综述集中于 PRISM、ProbLog 和 PITA 系统，其中 PRISM 属于最早的系统之一。<sup>[2](https://dl.acm.org/doi/10.1145/3191315.3191319)</sup>

一个 2024 年的框架通过半环统一了 PLP 的扩展：事实标签上的概率半环被其他半环取代，例如 WMI 和梯度半环，从而在逻辑程序层面和编译电路层面支持离散-连续推断、积分和梯度计算，其基础是代数模型计数。<sup>[15](https://arxiv.org/html/2402.13782)</sup> 同一框架通过 DeepProbLog 的神经谓词将神经网络与概率逻辑程序耦合；DeepProbLog 是 ProbLog 的扩展，这些神经谓词作为神经事实并入，封装一个从其输入计算概率的神经网络。<sup>[15](https://arxiv.org/html/2402.13782)</sup><sup> • </sup><sup>[16](https://lirias.kuleuven.be/retrieve/747290/)</sup>

## 应用

ProbLog 的动机是挖掘边带有概率的大型生物网络，其关键贡献是一种有效的推断过程，并被应用于一个现实生活中的链接发现任务。<sup>[8](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)</sup> 该领域的学习系统已应用于生物学、医学、链接预测和文本分类，并且与 Alchemy 等[统计关系学习](https://www.edgepedia.org/zh/statistical-relational-learning)系统相比具有竞争力。<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup>

## 局限与替代方案

[精确推断](https://www.edgepedia.org/zh/exact-inference)是主要瓶颈：容斥求值在解释数量上呈指数增长，<sup>[6](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)</sup> 基于 d-DNNF 的推断与学习在最坏情况下随树宽呈指数增长，<sup>[5](https://doi.org/10.1017/s1471068414000076)</sup> 而且即使很小的网络也可能带有 \( 10^{6} \) 数量级的候选路径。<sup>[9](https://lirias.kuleuven.be/retrieve/10ed2127-227e-4076-93e0-94285d2fb083)</sup> ProbLog 的 k 最佳解释和迭代加深近似只对确定程序可靠；如果使用否定，可靠近似需要三值语义。<sup>[17](https://coherentknowledge.com/wp-content/uploads/2013/05/plp-festschrift-paper-TS+FR.pdf)</sup> 循环程序使一个基于克拉克完成的早期学习算法失效，该算法的正确性仅限于无环程序。<sup>[5](https://doi.org/10.1017/s1471068414000076)</sup>

与马尔可夫逻辑网络（Markov logic networks，MLNs）相比，分布语义下的概率逻辑程序具有直接定义的语义，而不是通过图模型定义；MLN 则遵循知识库模型构造方法，为每个基原子定义一个节点，从而定义一个马尔可夫网络。<sup>[17](https://coherentknowledge.com/wp-content/uploads/2013/05/plp-festschrift-paper-TS+FR.pdf)</sup> 概率逻辑语言的比较评估框架把实现 MLN 的 Alchemy 等系统与分布语义系统放在一起处理。<sup>[18](https://homes.cs.aau.dk/~jaeger/publications/MLG07.pdf)</sup> 在 dPASP 风格实现中，通过枚举所有全选择并列出每个诱导程序的所有模型来进行精确推断，这使可扩展性局限于带少量带注释析取的程序。<sup>[19](https://proceedings.kr.org/2024/69/kr2024-0069-geh-et-al.pdf)</sup> 尽管如此，在某些系统中精确推断仍限于小规模程序。<sup>[19](https://proceedings.kr.org/2024/69/kr2024-0069-geh-et-al.pdf)</sup> 最近的系统如 PSoufflé（2026）是一个精确且可扩展的推断工具链，构建在 Soufflé 之上，用于概率 Datalog 程序，能够完成大型程序分析工作负载（[证据](https://repositum.tuwien.at/bitstream/20.500.12708/230507/1/Li-2026-PSouffle%20Scaling%20Exact%20Probabilistic%20Logic%20Inference%20for%20Program%20...-vor.pdf)）。

## References

1. [Probabilistic Logic Programming: Semantics, Inference and Learning (Distribution Semantics)](https://ml.unife.it/wp-content/uploads/2022/08/2022ICLP_Invited_Riguzzi.pdf)
2. [Declarative Logic Programming: Theory, Systems, and Applications](https://dl.acm.org/doi/10.1145/3191315.3191319)
3. [A History of Probabilistic Inductive Logic Programming](https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2014.00006/full)
4. [FABRIZIO RIGUZZI, TERRANCE SWIFT (2012). Well–definedness and efficient inference for probabilistic logic programming under the distribution semantics. Theory and Practice of Logic Programming.](https://doi.org/10.1017/s1471068411000664)
5. [DAAN FIERENS and colleagues (2014). Inference and learning in probabilistic logic programs using weighted Boolean formulas. Theory and Practice of Logic Programming.](https://doi.org/10.1017/s1471068414000076)
6. [A Survey of Probabilistic Logic Programming](https://ml.unife.it/wp-content/uploads/Papers/RigSwi-WFS16.pdf)
7. [Logical Methods in Computer Science article on distribution semantics](https://lmcs.episciences.org/6967/pdf)
8. [ProbLog: A Probabilistic Prolog and Its Application in Link Discovery](http://www.ijcai.org/papers07/Papers/IJCAI07-396.pdf)
9. [Inference in ProbLog (KU Leuven technical paper)](https://lirias.kuleuven.be/retrieve/10ed2127-227e-4076-93e0-94285d2fb083)
10. [Probabilistic (logic) programming concepts](https://link.springer.com/content/pdf/10.1007/s10994-015-5494-z.pdf)
11. [DNF Sampling for ProbLog Inference](https://ar5iv.labs.arxiv.org/html/1009.3798)
12. [The independent choice logic for modelling multiple agents under uncertainty (Artificial Intelligence, 1997)](https://doi.org/10.1016/s0004-3702%2897%2900027-1)
13. [JOOST VENNEKENS, MARC DENECKER, MAURICE BRUYNOOGHE (2009). CP-logic: A language of causal probabilistic events and its relation to logic programming. Theory and Practice of Logic Programming.](https://doi.org/10.1017/s1471068409003767)
14. [Angelika Kimmig, Guy Van den Broeck, Luc De Raedt (2016). Algebraic model counting. Journal of Applied Logic.](https://doi.org/10.1016/j.jal.2016.11.031)
15. [Semirings for Probabilistic and Neuro-Symbolic Logic Programming](https://arxiv.org/html/2402.13782)
16. [Neuro-symbolic extensions of ProbLog (KU Leuven retrieval)](https://lirias.kuleuven.be/retrieve/747290/)
17. [Probabilistic Logic Programming Under the Distribution Semantics (festschrift paper)](https://coherentknowledge.com/wp-content/uploads/2013/05/plp-festschrift-paper-TS+FR.pdf)
18. [Comparative Evaluation of PL Languages and Systems – a Work-in-Progress Report](https://homes.cs.aau.dk/~jaeger/publications/MLG07.pdf)
19. [dPASP: A Probabilistic Logic Programming Environment For Neurosymbolic Learning and Reasoning](https://proceedings.kr.org/2024/69/kr2024-0069-geh-et-al.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/probabilistic-logic-programming

English original: https://www.edgepedia.org/probabilistic-logic-programming
