# Agda

**Agda** 是一种依赖类型编程语言，其类型系统足够强大，使该语言兼作证明助手：数学定理可以在构造性环境中证明，而且这样的证明可以作为算法运行。<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> 它是马丁-洛夫类型论（Martin-Löf type theory）的扩展，也是[查尔姆斯理工大学](https://www.edgepedia.org/zh/chalmers-university-of-technology)（Chalmers University of Technology）编程逻辑小组开发的一系列语言中的最新一员，此前有 Alf、Alfa 和 Agda 1；相关系统包括 Cayenne、Rocq（原名 Coq）、Epigram、Idris 和 Lean。<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup>

| 关键事实 | 详情 |
|---|---|
| 它是什么 | 一种基于马丁-洛夫类型论的依赖类型编程语言和证明助手<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> |
| 证明即程序 | 定理以构造性方式证明，并可作为算法执行<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> |
| 当前系统 | Agda 2，自 2005 年起设计与实现；其主要参考是乌尔夫·诺雷尔（Ulf Norell）2007 年的查尔姆斯博士论文<sup>[2](https://wiki.portal.chalmers.se/agda/Main/History)</sup> |
| 文档版本 | 最新文档对应 Agda 2.9.0<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> |
| 语言特性 | 立方类型论、实例参数、无关性、共模式、共归纳、覆盖检查以及外部函数接口是该系统有文档记载的组成部分<sup>[3](https://agda.readthedocs.io/)</sup> |
| 同类系统 | 与 Idris 2、Lean 4 和 Rocq 一起作为四个主要依赖类型证明助手被基准测试<sup>[4](https://doi.org/10.4230/LIPIcs.ITP.2026.17)</sup> |

## 依赖类型与证明即程序

按照 Agda 的处理方式，[类型论](https://www.edgepedia.org/zh/type-theory)同时服务于编程和逻辑：类型系统是表达句法正确性的一种方式，而依赖类型让类型可以提及值，因此一个类型能够陈述程序必须满足的性质。<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> 在主流证明助手所采用的“命题即类型”解读下，检查一个程序具有某类型，与检查一个证明证实某个命题，是同一件事。<sup>[5](https://proceedings.neurips.cc/paper_files/paper/2024/file/77c87a15bbf0aad017c53995b832cf84-Paper-Conference.pdf)</sup>

因为证明是普通程序，一个完成的证明本身就可执行，这正是 Agda 中证明的定理能够作为算法运行的原因。<sup>[1](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)</sup> 终止检查是这一规范的一部分；Agda 和 Idris 的做法与 Nuprl 等系统不同，因为终止检查可以被禁用，从而以不再保证规范化为代价换取表达力。<sup>[6](https://ecommons.cornell.edu/bitstream/handle/1813/45093/aa755.pdf?sequence=1)</sup> 对于无限对象，Agda 支持基于常规守卫性检查的共归纳，正如 Coq 和 Idris 所做的那样。<sup>[7](https://proofassistants.stackexchange.com/questions/899/comparison-between-proof-assistants-for-coinductive-structures-and-proofs)</sup>

## 历史

Agda 源自查尔姆斯开发的一系列实现。同一传统中较早的系统包括 Alf、Alfa 和 Agda 1；一个面向函数式编程社区的相关语言是 Cayenne，由伦纳特·奥古斯特松（Lennart Augustsson）设计与实现。<sup>[2](https://wiki.portal.chalmers.se/agda/Main/History)</sup>

**Agda 2。** 2004 年，编程逻辑小组开始与位于[尼崎](https://www.edgepedia.org/zh/amagasaki)（Amagasaki）的产业技术综合研究所（AIST）验证与语义学中心合作，Agda 实现者会议（Agda Implementors' Meetings，AIMs）当时开始举办，作为在瑞典和日本轮流举行的半年一次会议。<sup>[2](https://wiki.portal.chalmers.se/agda/Main/History)</sup> 2005 年，该语言新版本的工作开始，乌尔夫·诺雷尔和安德烈亚斯·阿贝尔（Andreas Abel）编写了一个名为 AgdaLight 的原型；不久之后，当前系统 Agda 2 的设计与实现开始。Agda 2 的主要参考是诺雷尔的博士论文《迈向基于依赖类型论的实用编程语言》（*Towards a practical programming language based on dependent type theory*，查尔姆斯理工大学，2007）。<sup>[2](https://wiki.portal.chalmers.se/agda/Main/History)</sup>

## Agda 在证明助手中的位置

Agda、Rocq（Coq）、Lean 和 Idris 2 是最常被比较的系统，而最近一项名为 Panbench 的基准测试工作通过一个单一测试套件测试这四者，该套件关注基于依赖类型论的系统所共享的基本特性，以及“基础工程”行为，例如处理长标识符、长行、大记录和大数据声明。<sup>[4](https://doi.org/10.4230/LIPIcs.ITP.2026.17)</sup>

实践者的比较沿着几条线索作出区分：

- **与 Idris 相比。** Idris 是一种基于依赖类型的通用编程语言，而非证明助手，是为编程而非定理证明而开发的。<sup>[8](https://cronfa.swan.ac.uk/Record/cronfa67283/Download/67283__31024__387fadf897e3425ea39a001cf20e5698.pdf)</sup> 在策略与证明助手领域，据报道 Agda 比 Idris 快得多也方便得多，因为它对隐式参数的处理更好，而 Idris 较弱的隐式处理常常在策略已经解决目标时仍强制要求额外参数。<sup>[9](https://whatisrt.github.io/dependent-types/2020/02/18/agda-vs-coq-vs-idris.html)</sup>

- **与 Coq 相比。** Coq 提供了大量策略和一个大型证明库，而 Agda 提供良好的元编程。<sup>[9](https://whatisrt.github.io/dependent-types/2020/02/18/agda-vs-coq-vs-idris.html)</sup> Coq 证明可以短得多，而 Agda 证明往往更可读，并且有时在 Agda 中编写同一个函数更容易，这可以转化为更容易的证明。<sup>[9](https://whatisrt.github.io/dependent-types/2020/02/18/agda-vs-coq-vs-idris.html)</sup>

- **与 Lean 相比。** 据报道 Lean 更多地与 Coq 竞争，而不是与 Agda 和 Idris 竞争，因此，不会选择 Coq 的读者出于同样的理由，也不太需要考虑 Lean。<sup>[9](https://whatisrt.github.io/dependent-types/2020/02/18/agda-vs-coq-vs-idris.html)</sup>

## Agda 中的形式化工作

Agda 已被用于在若干领域形式化数学和编程语言理论。一份 2019 年关于沃埃沃茨基（Voevodsky）单值基础（univalent foundations）的导论展示了如何在 Agda 中发展单值数学，在数论、分析、群论、拓扑学、范畴论和编程语言理论中写下定义、构造、定理和证明，并由系统检查逻辑与数学正确性。<sup>[10](https://arxiv.org/abs/1911.00580)</sup> 该语言的文档包含对立方类型论的专门支持，而立方类型论是这项工作大部分内容的基础。<sup>[3](https://agda.readthedocs.io/)</sup>

形式化也已延伸到语言学和逻辑学：兰贝克-格里申演算（Lambek-Grishin calculus）是一种类型逻辑语法，具有丰富的类型构造运算词汇，已在 Agda 中建模，并带有经过验证的切消过程，以及从该演算中的证明到 Agda 程序的 CPS 翻译（CPS translation）。<sup>[11](https://arxiv.org/abs/1709.00728)</sup>

**库覆盖范围。** 所报告的空白让人了解 Agda 的库相对于同类系统处于什么位置。一份 2022 年构造性分析综述指出，Agda 没有实数及其算术的形式化，尽管证明助手总体上已被用于验证重大定理的证明。<sup>[12](https://arxiv.org/abs/2205.08354)</sup> 一份 2020 年的形式化论文观察到，当时的 Agda 还没有范畴论的标准、可工作的形式化。<sup>[13](https://arxiv.org/abs/2005.07059)</sup>

## References

1. [What is Agda? — Agda 2.9.0 documentation](https://agda.readthedocs.io/en/latest/getting-started/what-is-agda.html?highlight=instance)
2. [History, The Agda Wiki, Chalmers](https://wiki.portal.chalmers.se/agda/Main/History)
3. [Welcome to Agda's documentation! — Agda 2.8.0.2 documentation](https://agda.readthedocs.io/)
4. [Panbench: A Comparative Benchmarking Tool for Dependently-Typed Languages, LIPIcs ITP 2026](https://doi.org/10.4230/LIPIcs.ITP.2026.17)
5. [NeurIPS 2024 conference paper on proof assistants and type theory](https://proceedings.neurips.cc/paper_files/paper/2024/file/77c87a15bbf0aad017c53995b832cf84-Paper-Conference.pdf)
6. [Trust in Proof Assistants: Opportunities, Cornell eCommons](https://ecommons.cornell.edu/bitstream/handle/1813/45093/aa755.pdf?sequence=1)
7. [Comparison between proof assistants for coinductive structures and proofs, Proof Assistants Stack Exchange](https://proofassistants.stackexchange.com/questions/899/comparison-between-proof-assistants-for-coinductive-structures-and-proofs)
8. [PhD thesis background chapter on proof assistants, Swansea University (cronfa67283)](https://cronfa.swan.ac.uk/Record/cronfa67283/Download/67283__31024__387fadf897e3425ea39a001cf20e5698.pdf)
9. [Agda vs. Coq vs. Idris, Meta-cedille blog](https://whatisrt.github.io/dependent-types/2020/02/18/agda-vs-coq-vs-idris.html)
10. [Introduction to Univalent Foundations of Mathematics with Agda, arXiv:1911.00580](https://arxiv.org/abs/1911.00580)
11. [Formalising Type-Logical Grammars in Agda, arXiv:1709.00728](https://arxiv.org/abs/1709.00728)
12. [Constructive Analysis in the Agda Proof Assistant, arXiv:2205.08354](https://arxiv.org/abs/2205.08354)
13. [Formalizing of Category Theory in Agda, arXiv:2005.07059](https://arxiv.org/abs/2005.07059)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/agda

English original: https://www.edgepedia.org/agda
