# LF（逻辑框架）

**LF**，是爱丁堡逻辑框架（Edinburgh Logical Framework）的缩写，是一种带依赖类型的类型化 λ 演算，设计用作定义逻辑和编程语言的元语言。它由罗伯特·哈珀（Robert Harper）、富里奥·洪塞尔（Furio Honsell）和戈登·普洛特金（Gordon Plotkin）在《定义逻辑的框架》（"A Framework for Defining Logics"）中提出，首次发表于第二届 IEEE 逻辑学与计算机科学研讨会（Second Annual IEEE Symposium on Logic in Computer Science，LICS 1987），并于 1993 年在《ACM杂志》（Journal of the ACM）上以扩展形式发表。<sup>[1](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)</sup><sup> • </sup><sup>[2](https://www.lfcs.inf.ed.ac.uk/reports/91/ECS-LFCS-91-162/)</sup>

| 关键事实 | 详情 |
|---|---|
| 全名 | 爱丁堡逻辑框架（LF），由罗伯特·哈珀、富里奥·洪塞尔和戈登·普洛特金提出<sup>[1](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)</sup> |
| 形式基础 | 一种带一阶依赖类型的类型化 λ 演算，与 AUTOMATH 语言密切相关<sup>[2](https://www.lfcs.inf.ed.ac.uk/reports/91/ECS-LFCS-91-162/)</sup> |
| 核心原则 | 判断即类型：对象逻辑的每个判断都等同于其证明的类型，因此证明检查归约为类型检查<sup>[1](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)</sup> |
| 类型结构 | 三个层次：对象、类型（对对象进行分类）和种类；类型包括依赖函数类型 Πx:A.A′<sup>[2](https://www.lfcs.inf.ed.ac.uk/reports/91/ECS-LFCS-91-162/)</sup><sup> • </sup><sup>[3](https://www.cs.cmu.edu/~rwh/papers/lfias/lf.pdf)</sup> |
| 正确性标准 | 一个编码是充分的，当且仅当它与该演绎系统的原始描述同构<sup>[4](https://twelf.org/wiki/lf/)</sup> |
| 主要实现 | Twelf（卡内基梅隆大学，Carnegie Mellon University）和 Beluga（麦吉尔大学，McGill University）<sup>[5](https://twelf.org/wiki/about-the-twelf-project/)</sup><sup> • </sup><sup>[6](https://research.cs.queensu.ca/home/jana/papers/beluga-system/)</sup> |
| 认可 | LICS 1987 论文于 2007 年获得 LICS 时间检验奖（LICS Test-of-Time Award）<sup>[1](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)</sup> |

## 目的与设计

逻辑框架是一种用于形式化逻辑和编程语言的元语言。<sup>[7](https://www.cs.cmu.edu/~fox/lf.html)</sup> 其动机是实现上的经济性：单一框架提供一种简洁的记法和演算来规定逻辑，使得各种逻辑的系统可以快速原型化，而不必为每一种逻辑做冗余的实现工作。<sup>[8](https://cordis.europa.eu/project/id/3245)</sup> LF 的设计目标正是成为这样一个框架，因此它是一种非常小的语言，恰好提供规定形式系统所需的构造。<sup>[9](https://kwarc.info/people/frabe/Research/phdthesis.pdf)</sup>

该形式系统基于一种带一阶依赖类型的类型化 λ 演算，与 1960 年代和 1970 年代开创性的计算机检验数学系统家族 AUTOMATH 的若干语言密切相关。<sup>[2](https://www.lfcs.inf.ed.ac.uk/reports/91/ECS-LFCS-91-162/)</sup> 用类型论的术语说，LF 是依赖类型论的一个变体，与马丁-洛夫类型论（Martin-Löf type theory）有关。它包含简单类型论，后者构成 Isabelle 框架的基础；它又被构造演算所包含，后者构成 Coq 的基础。<sup>[9](https://kwarc.info/people/frabe/Research/phdthesis.pdf)</sup>

## 判断即类型

核心表示思想是“判断即类型”原则：演绎系统中的一个判断被表示为 LF 类型族，该类型族对判断的推导的表示进行分类。对象系统中的推导随后可以通过对其 LF 表示进行类型检查来检查，推理规则被视为高阶判断的证明。<sup>[4](https://twelf.org/wiki/lf/)</sup><sup> • </sup><sup>[1](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)</sup> 所有数学对象、命题和证明都统一表示为 LF 项，关于它们的判断则表示为 LF 类型。<sup>[9](https://kwarc.info/people/frabe/Research/phdthesis.pdf)</sup>

编码的正确性由充分性定理陈述，该定理把对象逻辑的语法和演绎与适当 LF 类型的规范形式关联起来。一个 LF 表示是充分的，当且仅当它与该演绎系统的原始描述同构。<sup>[4](https://twelf.org/wiki/lf/)</sup><sup> • </sup><sup>[10](https://paperity.org/p/376996461/on-equivalence-and-canonical-forms-in-the-lf-type-theory)</sup> 定义相等性的可判定性以及项到规范形式的转换，在框架的元理论中起核心作用；原始论文在定义相等性方面只考虑 β-转换，哈珀和普芬宁（Pfenning）后来给出了处理整个系统的类型导向等价算法。<sup>[10](https://paperity.org/p/376996461/on-equivalence-and-canonical-forms-in-the-lf-type-theory)</sup>

该框架促成的一项关键表示技术是高阶抽象语法（higher-order abstract syntax，HOAS），其中对象语言的绑定器被表示为 LF 自身 lambda 演算中的绑定器。这使用户避免实现棘手的变量例程，例如避免捕获的替换、重命名和生成新名称。<sup>[11](https://www.cs.mcgill.ca/~bpientka/papers/flops.pdf)</sup>

## Twelf

LF 的主要实现是 Twelf，由卡内基梅隆大学开发。Twelf 是 LF 一系列实现中的当前版本，包含 LF 逻辑框架本身（包括类型重建）；Elf 约束逻辑编程语言（现已集成到 Twelf 中）；一个用于 LF 的归纳元定理证明器；以及一个 Emacs 界面。<sup>[5](https://twelf.org/wiki/about-the-twelf-project/)</sup><sup> • </sup><sup>[12](https://www.cs.cmu.edu/~twelf/guide/twelf_1.html)</sup><sup> • </sup><sup>[13](https://www.cs.cmu.edu/~fp/lfs/lfs-impl.html)</sup> 主要作者是弗兰克·普芬宁和卡斯滕·舒尔曼（Carsten Schürmann），布丽吉特·皮恩特卡（Brigitte Pientka）、罗伯托·维尔加（Roberto Virga）和凯文·沃特金斯（Kevin Watkins）作出了重要贡献。这项工作由美国国家科学基金会（National Science Foundation）根据资助号 CCR-9619584、CCR-9988281 和 CCR-0306313 资助，并由美国国防高级研究计划局（DARPA）根据合同 F196268-95-C-0050 为福克斯项目（Fox Project）资助。<sup>[5](https://twelf.org/wiki/about-the-twelf-project/)</sup>

Twelf 提供一种统一的元语言，用于规定和实现编程语言与逻辑，并证明它们的性质。其示例套件包括笛卡尔闭范畴和 lambda 演算、无类型 lambda 演算的丘奇-罗瑟定理（Church-Rosser theorem）、带类型保持和编译的 Mini-ML、切消、逻辑编程理论以及希尔伯特演绎定理（Hilbert's deduction theorem）。<sup>[5](https://twelf.org/wiki/about-the-twelf-project/)</sup> 采用它的主要研究工作中包括 TALT（一种类型化汇编语言）、一个用于携带证明的代码（proof-carrying code）的基础系统，以及 Standard ML 的类型安全性证明。<sup>[14](https://twelf.org/)</sup> TALT 的 LF 规范由 2,081 行 Twelf 代码组成。<sup>[15](https://citeseerx.ist.psu.edu/document?doi=a9a155c61ec94557a2106d2d3e3dd25384fd99cb&repid=rep1&type=pdf)</sup>

Twelf 不再进行积极开发，但仍拥有用户社区，并仍是一种研究工具。<sup>[14](https://twelf.org/)</sup>

## 应用

**携带证明的代码。** 在携带证明的代码架构中，二进制文件安全性的形式证明用 LF 表达，并作为可检查的证书附加到代码上，由经过优化的检查器验证。福克斯项目的 Touchstone 实现包含一个生成证明的定理证明器，以及一个用于检查以 LF 片段表示的证明的高效检查器。<sup>[7](https://www.cs.cmu.edu/~fox/lf.html)</sup> 普林斯顿（Princeton）开发的一种携带证明的代码的基础变体使用 Twelf 作为其证明语言。<sup>[16](https://www.cs.princeton.edu/~appel/fpcc.html)</sup>

**元理论的机械化。** 典型工作流程是在 LF 中形式化语言的语法和判断，使用 Twelf 检查类型保持和进展等元定理的证明，并在示例上运行语言定义。得到的机器可检查产物可以在语言后来扩展时被研究或重用。<sup>[17](https://twelf.org/wiki/proving-metatheorems-with-twelf/)</sup>

**逻辑工程。** 由于 LF 签名可以统一地表示逻辑，它们支持逻辑的等价、翻译和组合的一般定义；当时在不来梅雅各布大学（Jacobs University Bremen）的计算机科学家弗洛里安·拉贝（Florian Rabe）利用这一设置，将逻辑之间的翻译定义为理论态射。<sup>[18](https://doi.org/10.1093/logcom/exu079)</sup> 拉贝还设计了一种在 LF 内部使用 LF 模块系统表示 Isabelle 逻辑框架的方法，自然地捕捉了 Isabelle 的类型类和局部环境（locales）。<sup>[19](https://arxiv.org/abs/1009.2794)</sup>

## LF 在逻辑框架家族中

LF 是若干被用作逻辑框架的系统之一。由剑桥大学（University of Cambridge）的劳伦斯·保尔森（Lawrence Paulson）开发的 Isabelle 是另一种框架，基于带浅多态的高阶逻辑，而不是依赖类型论；其优点包括递归和归纳计算以及半自动推理支持。<sup>[20](https://paperzz.com/doc/7103653/a-logical-framework-combining-model-and-proof-theory)</sup> 在 INRIA-Rocquencourt 开发的 Coq 基于归纳构造演算，这是一种更丰富的依赖类型论，用于构造性逻辑和程序抽取。<sup>[8](https://cordis.europa.eu/project/id/3245)</sup><sup> • </sup><sup>[21](https://inferensys.com/differences/neuro-symbolic-ai-frameworks/automated-reasoning-platforms/isabelle-hol-vs-coq-logical-foundations-for-formal-methods)</sup> 其他框架和类框架系统包括 Automath、ALF、Agda、LEGO、Nuprl 和 Forum，后者是一种基于经典线性逻辑的框架。<sup>[13](https://www.cs.cmu.edu/~fp/lfs/lfs-impl.html)</sup><sup> • </sup><sup>[22](https://www.cs.cmu.edu/~fp/talks/mdorf01-slides.pdf)</sup> LF 与 Isabelle 和 Coq 的区别在于它刻意保持极简：它较少强调框架内部的计算，而更强调语法和证明论的统一表示。<sup>[9](https://kwarc.info/people/frabe/Research/phdthesis.pdf)</sup>

研究还探索了框架本身的变体。罗宾·亚当斯（Robin Adams）定义了 TF，即类型框架（Type Framework），一种没有 lambda 抽象或积种类的无 lambda 逻辑框架，并证明它可以保守地嵌入 LF，其中 TF 判断对应于处于 β-规范、η-长规范形式的 LF 判断；若干元理论性质（包括充分性定理）可以在 TF 中更容易地证明，然后提升到 LF。<sup>[23](https://arxiv.org/abs/0804.1879)</sup> LF+ 等扩展添加锁类型构造子，以将证明无关判断的验证委托给外部工具。<sup>[24](https://jfr.unibo.it/article/view/9757)</sup>

## Beluga 及其后继

**Beluga** 以推理扩展了 LF 方法。Beluga 由麦吉尔大学（McGill University）计算机科学教授布丽吉特·皮恩特卡（Brigitte Pientka）和贾娜·邓菲尔德（Jana Dunfield）开发，实现 LF 以通过高阶抽象语法规定和原型化形式系统，并添加一种依赖类型函数式语言，用户在该语言中把关于形式系统的归纳证明实现为递归函数。<sup>[6](https://research.cs.queensu.ca/home/jana/papers/beluga-system/)</sup> 其显著特征是直接支持带上下文的推理：上下文对象表示假设性和参数化推导，从而得到紧凑的证明，测试用例包括丘奇-罗瑟定理、类型唯一性、编译器变换，以及类 ML 语言的保持和进展。<sup>[6](https://research.cs.queensu.ca/home/jana/papers/beluga-system/)</sup> Beluga 用 OCaml 实现，并将上下文视为一等对象。<sup>[25](https://complogic.cs.mcgill.ca/beluga/)</sup> 一个交互式配套工具 Harpoon 借助策略辅助构造 Beluga 函数。<sup>[26](https://link.springer.com/chapter/10.1007/978-3-030-79876-5_38)</sup>

## References

1. [A Framework for Defining Logics (LICS 1987), LICS Archive](https://lics.siglog.org/archive/1987/HarperHonsellPlotki-AFrameworkforDefini.html)
2. [A Framework for Defining Logics, LFCS Report ECS-LFCS-91-162, University of Edinburgh](https://www.lfcs.inf.ed.ac.uk/reports/91/ECS-LFCS-91-162/)
3. [Notes on Logical Frameworks, Robert Harper, Carnegie Mellon University](https://www.cs.cmu.edu/~rwh/papers/lfias/lf.pdf)
4. [LF, Twelf Wiki](https://twelf.org/wiki/lf/)
5. [About The Twelf Project, Twelf Wiki](https://twelf.org/wiki/about-the-twelf-project/)
6. [Beluga: A Framework for Programming and Reasoning with Deductive Systems, Pientka and Dunfield, IJCAR 2010](https://research.cs.queensu.ca/home/jana/papers/beluga-system/)
7. [The Fox Project / Logical Frameworks, Carnegie Mellon University](https://www.cs.cmu.edu/~fox/lf.html)
8. [Logical Frameworks: Design, Implementation and Experiment, CORDIS Project 3245, European Commission](https://cordis.europa.eu/project/id/3245)
9. [Representing Logics and Logic Translations, Florian Rabe, PhD thesis](https://kwarc.info/people/frabe/Research/phdthesis.pdf)
10. [On Equivalence and Canonical Forms in the LF Type Theory, Harper and Pfenning](https://paperity.org/p/376996461/on-equivalence-and-canonical-forms-in-the-lf-type-theory)
11. [Beluga: programming with dependent types, contextual data, and contexts, Pientka](https://www.cs.mcgill.ca/~bpientka/papers/flops.pdf)
12. [Twelf User's Guide, Introduction](https://www.cs.cmu.edu/~twelf/guide/twelf_1.html)
13. [Logical Framework Implementations, Frank Pfenning, Carnegie Mellon University](https://www.cs.cmu.edu/~fp/lfs/lfs-impl.html)
14. [The Twelf Programming Language and Theorem Prover](https://twelf.org/)
15. [Toward a Foundational Typed Assembly Language](https://citeseerx.ist.psu.edu/document?doi=a9a155c61ec94557a2106d2d3e3dd25384fd99cb&repid=rep1&type=pdf)
16. [Foundational Proof-Carrying Code, Andrew Appel, Princeton University](https://www.cs.princeton.edu/~appel/fpcc.html)
17. [Proving metatheorems with Twelf, Twelf Wiki](https://twelf.org/wiki/proving-metatheorems-with-twelf/)
18. [How to identify, translate and combine logics?, Florian Rabe, Journal of Logic and Computation](https://doi.org/10.1093/logcom/exu079)
19. [Representing Isabelle in LF, Florian Rabe, arXiv:1009.2794](https://arxiv.org/abs/1009.2794)
20. [A Logical Framework Combining Model and Proof Theory](https://paperzz.com/doc/7103653/a-logical-framework-combining-model-and-proof-theory)
21. [Isabelle/HOL vs Coq: Logical Foundations for Formal Methods, Inference Systems](https://inferensys.com/differences/neuro-symbolic-ai-frameworks/automated-reasoning-platforms/isabelle-hol-vs-coq-logical-foundations-for-formal-methods)
22. [Logical and Meta-Logical Frameworks, Frank Pfenning, talk slides](https://www.cs.cmu.edu/~fp/talks/mdorf01-slides.pdf)
23. [Lambda-Free Logical Frameworks, Robin Adams, arXiv:0804.1879](https://arxiv.org/abs/0804.1879)
24. [LF+ in Coq for "fast and loose" reasoning, Journal of Formalized Reasoning](https://jfr.unibo.it/article/view/9757)
25. [Beluga, Complogic Group, McGill University](https://complogic.cs.mcgill.ca/beluga/)
26. [Harpoon: Mechanizing Metatheory Interactively, Springer](https://link.springer.com/chapter/10.1007/978-3-030-79876-5_38)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Logical calculi and logical syntax › Lambda calculus and type theory › Lambda cube, pure type systems, and System F

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/lf-logical-framework

English original: https://www.edgepedia.org/lf-logical-framework
