# TLA+

**TLA+**（Temporal Logic of Actions plus，动作时序逻辑增强版）是一种形式化规约语言，基于集合论、一阶逻辑和动作时序逻辑（TLA），用于设计、建模、编写文档和验证系统，尤其是并发系统和分布式系统。<sup>[1](https://lamport.azurewebsites.net/pubs/spec-book-chap.pdf)</sup><sup> • </sup><sup>[2](https://arxiv.org/abs/2411.13722)</sup> 它由莱斯利·兰波特（Leslie Lamport）创造，这位计算机科学家以分布式系统和时序逻辑方面的工作而闻名，他在20世纪80年代末提出了TLA，并在其基础上构建了TLA+作为一门完整的语言。<sup>[3](https://lamport.org/pubs/lamport-spec-tla-plus.pdf)</sup> TLA+规约不是程序：它是关于一个无限状态序列的谓词，其中状态是对变量取值的一种赋值。<sup>[4](https://docs.tlapl.us/creating%3Aactions)</sup> 该语言及其工具旨在消除根本性的设计错误——这类错误难以发现，在代码中修正的代价高昂。<sup>[5](https://lamport.org/tla/tla.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 基础 | 集合论、一阶逻辑和动作时序逻辑（TLA）<sup>[1](https://lamport.azurewebsites.net/pubs/spec-book-chap.pdf)</sup> |
| 起源 | TLA由莱斯利·兰波特于20世纪80年代末提出；TLA+在为各种不同系统编写规约的过程中逐步完善<sup>[3](https://lamport.org/pubs/lamport-spec-tla-plus.pdf)</sup> |
| 参考书 | 《Specifying Systems》（面向硬件与软件工程师的TLA+语言与工具），Addison-Wesley，2002年6月<sup>[6](https://www.microsoft.com/en-us/research/publication/specifying-systems-the-tla-language-and-tools-for-hardware-and-software-engineers/?msockid=3cae1959e034604f038d0f92e10e61d1)</sup> |
| 语言稳定性 | TLA+语言自2006年以来未再改动<sup>[7](https://lamport.azurewebsites.net/tla/future.pdf)</sup> |
| 主要工具 | TLC显式状态模型检查器（Yu等，1999）、TLAPS证明系统（1.4.5版）和Apalache符号模型检查器<sup>[8](https://docs.tlapl.us/using%3Atlc%3Astart)</sup><sup> • </sup><sup>[9](https://proofs.tlapl.us/)</sup><sup> • </sup><sup>[10](https://apalache-mc.org/)</sup> |
| 规范规约形式 | `Init /\ [][Next]_vars /\ Fairness`，即初始谓词、方框动作公式和公平性条件<sup>[11](https://lingenic.com/en/Knowledge_Base/Logic/Formal_Logical_Systems/Applications/Verification/TLA%2B)</sup> |
| 工业用户 | 英特尔、微软（Azure、Cosmos DB）、亚马逊云科技、谷歌、甲骨文云基础设施（自2015年起）、MongoDB等<sup>[12](https://foundation.tlapl.us/industry/)</sup><sup> • </sup><sup>[13](https://foundation.tlapl.us/industry/index.html)</sup> |

## 规约、状态与动作

TLA+规约将一个系统描述为一组行为，即无限的状态序列。每个可模型检查的规约都声明一组固定的变量，状态之间的迁移写为动作，即包含撇号运算符的表达式，该运算符表示变量在下一状态中的值。例如，一个要求`x = 0`且`x' = x + 1`的动作仅在`x`为0的状态下启用，并描述一个`x`为1的后继状态。<sup>[4](https://docs.tlapl.us/creating%3Aactions)</sup>

从语义上说，动作是关于一对状态的谓词——当前状态和下一状态；它不赋值也不生成状态，它只是对一对状态为真或为假。模型检查器从动作的结构中恢复出后继状态，这只对以特定的撇号变量表达式惯用法写成的规约有效。<sup>[4](https://docs.tlapl.us/creating%3Aactions)</sup> 标准规约形式组合了初始谓词、方框动作公式`[][Next]_vars`和公平性条件；TLC只能检查写成方框动作公式的动作性质。<sup>[11](https://lingenic.com/en/Knowledge_Base/Logic/Formal_Logical_Systems/Applications/Verification/TLA%2B)</sup><sup> • </sup><sup>[14](https://learntla.com/core/action-properties.html)</sup>

TLA规约的大部分内容由普通的、非时序的数学构成，时序逻辑主要用于它擅长描述的性质，如活性。兰波特引入了书写长公式的记号，并从编程语言中借鉴了模块化的思想，因为真实系统的规约可能长达数十页乃至数百页。<sup>[3](https://lamport.org/pubs/lamport-spec-tla-plus.pdf)</sup> TLA+是TLA在纯语法层面的扩展，在语义上没有任何新东西。<sup>[15](https://lamport.org/pubs/lamport-actions.pdf)</sup>

## 工具

**TLC**是主要的模型检查器。它是一个显式状态模型检查器，最初由Yuan Yu及其同事于1999年编写，检查的是TLA+中现实系统常用到的那部分子集，最典型的是有限系统，运行于Java 11之上。配置文件（`.cfg`）指定规约谓词、为常量赋值，并列出要检查的不变式和时序性质；`CONSTRAINT`等小节限制所探索的状态空间，`SYMMETRY`则去除对称状态，不过使用对称性时无法检查活性性质。<sup>[8](https://docs.tlapl.us/using%3Atlc%3Astart)</sup><sup> • </sup><sup>[16](https://docs.tlapl.us/using%3Atlc%3Aconfig_file)</sup> TLC默认检查死锁，当终止状态是有意为之的时候可以关闭该检查。<sup>[17](https://learning.tlapl.us/intro/tlc-config/)</sup>

**TLAPS**，即TLA+证明系统，以机械化的方式检查TLA+证明。它的证明语言是声明式的、分层的，可扩展到大型规约，并对后端验证器提供一致的抽象：默认情况下，它尝试SMT求解器（判定逻辑公式可满足性的程序）Z3，超时5秒；基于语义表的 一阶证明器Zenon，超时10秒；以及Isabelle的`auto`策略，超时30秒。当前版本1.4.5不进行时序推理，也不处理某些TLA+特性，但适合验证非平凡算法的安全性性质。它是BSD许可证下的自由软件，作为微软研究院—Inria巴黎联合中心的“证明工具”项目的一部分开发。<sup>[9](https://proofs.tlapl.us/)</sup><sup> • </sup><sup>[18](https://proofs.tlapl.us/doc/web/content/Documentation/Tutorial/Tactics.html)</sup>

**Apalache**是一个符号模型检查器，将TLA+翻译为SMT求解器（如微软Z3和CVC5）所支持的逻辑。TLC枚举规约行为所产生的状态，而Apalache则将验证问题翻译为逻辑约束。它支持长度至多k的随机符号执行、对所有长度至多k的执行进行有界模型检查，以及对所有执行进行归纳性检查。它还为其他工具提供后端：Quint语言使用Apalache作为后端模型检查器，Solarkraft用于Soroban智能合约的运行时监控，Atomkraft用于Cosmos去中心化应用的基于模型的测试，它们也都使用Apalache。<sup>[10](https://apalache-mc.org/)</sup><sup> • </sup><sup>[19](https://github.com/apalache-mc/apalache/blob/main/docs/src/apalache/index.md)</sup>

工具生态还包括TLA+工具箱IDE和Visual Studio Code扩展，后者为TLA+和PlusCal提供语法高亮，运行PlusCal到TLA+的翻译器，并可从编辑器中启动TLC。<sup>[20](https://github.com/tlaplus/vscode-tlaplus)</sup> PlusCal是一门算法语言，可翻译为TLA+规约，然后对其正确性进行证明。<sup>[21](https://proofs.tlapl.us/doc/web/content/Documentation/Tutorial/The_example.html)</sup>

## 工业应用

TLA+最早在工业界被英特尔用于硬件建模，那里的工程师有动力在将设计实现为硅片之前消除缺陷。<sup>[12](https://foundation.tlapl.us/industry/)</sup> 微软将其应用于Azure网络的多项工作，包括Azure DNS记录传播、RingMaster分布式复制与检查点协调、分布式减载以及Macsec密钥轮换编排；在RingMaster中，一份描述期望行为的TLA+规约迅速定位到一个曾以间歇性单元测试失败形式出现的缺陷。Azure Cosmos DB团队使用TLA+设计分布式算法，并用规约明确该服务提供的五种一致性模型各自的保证，并将这些规约发布给用户；在设计多区域写入能力时，团队在编写任何代码之前就在TLA+规约中发现了一个关键的安全性缺陷。<sup>[12](https://foundation.tlapl.us/industry/)</sup>

在谷歌，TLA+与TLAPS证明系统一起用于形式化验证Jayanti–Tarjan并发并查集数据结构的正确性，该结构支撑着跨数百亿数据点的大规模聚类。<sup>[12](https://foundation.tlapl.us/industry/)</sup> 甲骨文云基础设施自2015年起使用TLA+验证存储系统和关键的低层服务，并于2022年报告称，在验证一个硬盘自动化系统时，在缺陷进入生产环境之前发现了其中的细微缺陷，没有数据丢失，节省了数千个运维工时；甲骨文的一位首席工程师在2024年报告称，OCI已编写了数百份TLA+规约，覆盖数十项云服务，包括用于拥有数十万行代码的现有系统。<sup>[13](https://foundation.tlapl.us/industry/index.html)</sup> MongoDB使用TLA+进行基于模型的踪迹检查以及分布式事务的模块化规约与验证，并在VLDB和NSDI上发表了成果。<sup>[13](https://foundation.tlapl.us/industry/index.html)</sup> 2024年发表的一篇关于工业界TLA+实践的系统性文献综述识别出的用户包括亚马逊云科技（S3和DynamoDB）、阿里巴巴集团、eBay、华为云、Informal Systems和泰雷兹，并发现过去十年间工业环境中关于TLA+的出版物有所增长，尽管只有16篇论文符合该综述的入选标准。<sup>[2](https://arxiv.org/abs/2411.13722)</sup>

**弥合模型与代码之间的鸿沟。** 规约也可以对照运行中的代码进行检查。一项关于Apache分布式协调系统ZooKeeper的研究使用TLA+编写了细粒度规约，对非原子动作和局部并发进行建模，以及混合粒度规约，将粗粒度的协议模型与代码级细节相结合。模型检查在ZooKeeper中发现了六个严重缺陷，包括数据丢失和数据同步失败；除一个之外，其余都需要细粒度建模才能发现，而借助规约粗化的帮助，所有缺陷都在不到两分钟内被发现。<sup>[22](https://arxiv.org/abs/2409.14301)</sup>

## 语言设计与治理

TLA+语言自2006年以来未再改动，兰波特、Stephan Merz和Chris Newcombe在2024年的一篇短文中主张，改动需要有正当理由，因为改动可能使现有规约变为非法、使语言复杂化，或需要改动工具。他们拒绝了用户最常见的请求——让TLA+更像一门编程语言——理由是使用TLA+的原因恰恰在于它是数学而不是编程语言。<sup>[7](https://lamport.azurewebsites.net/tla/future.pdf)</sup> TLA+基金会是一个独立的非营利组织，如今推动该语言在工业界、学术界和教育界的采用，并资助工具开发，包括TLAPS证明管理器的工作，以及关于无限状态或参数化规约的归纳不变式组合式推断的研究。<sup>[23](https://foundation.tlapl.us/)</sup><sup> • </sup><sup>[24](https://foundation.tlapl.us/blog/2025-06-dev-update/index.html)</sup>

## References

1. [7.1 Overview of TLA+, from *Specifying Systems*, Leslie Lamport](https://lamport.azurewebsites.net/pubs/spec-book-chap.pdf)
2. [A Systematic Literature Review on a Decade of Industrial TLA+ Practice, Bögli, Lerena, Tsigkanos, Kehrer, arXiv:2411.13722 (2024)](https://arxiv.org/abs/2411.13722)
3. [Specifying Concurrent Systems with TLA+, Leslie Lamport](https://lamport.org/pubs/lamport-spec-tla-plus.pdf)
4. [Variables, States, and Actions, TLA+ Wiki](https://docs.tlapl.us/creating%3Aactions)
5. [The TLA+ Home Page, Leslie Lamport](https://lamport.org/tla/tla.html)
6. [Specifying Systems: The TLA+ Language and Tools for Hardware and Software Engineers, Microsoft Research](https://www.microsoft.com/en-us/research/publication/specifying-systems-the-tla-language-and-tools-for-hardware-and-software-engineers/?msockid=3cae1959e034604f038d0f92e10e61d1)
7. [The Future of TLA+, Leslie Lamport, Stephan Merz, and Chris Newcombe (9 July 2024)](https://lamport.azurewebsites.net/tla/future.pdf)
8. [TLC Model Checker, TLA+ Wiki](https://docs.tlapl.us/using%3Atlc%3Astart)
9. [TLA+ Proof System](https://proofs.tlapl.us/)
10. [Apalache: The Symbolic Model Checker for TLA+](https://apalache-mc.org/)
11. [TLA+ Knowledge Base, Lingenic](https://lingenic.com/en/Knowledge_Base/Logic/Formal_Logical_Systems/Applications/Verification/TLA%2B)
12. [Industrial Use of TLA+, TLA+ Foundation](https://foundation.tlapl.us/industry/)
13. [Industrial Use of TLA+, TLA+ Foundation (index)](https://foundation.tlapl.us/industry/index.html)
14. [Action Properties, Learn TLA+](https://learntla.com/core/action-properties.html)
15. [The Temporal Logic of Actions, Leslie Lamport, ACM TOPLAS](https://lamport.org/pubs/lamport-actions.pdf)
16. [TLC Config Files, TLA+ Wiki](https://docs.tlapl.us/using%3Atlc%3Aconfig_file)
17. [TLC Configuration, TLA+ By Example](https://learning.tlapl.us/intro/tlc-config/)
18. [Tactics, TLAPS Documentation](https://proofs.tlapl.us/doc/web/content/Documentation/Tutorial/Tactics.html)
19. [Apalache Getting Started, GitHub](https://github.com/apalache-mc/apalache/blob/main/docs/src/apalache/index.md)
20. [vscode-tlaplus: TLA+ language support for Visual Studio Code, GitHub](https://github.com/tlaplus/vscode-tlaplus)
21. [The Example, TLAPS Tutorial](https://proofs.tlapl.us/doc/web/content/Documentation/Tutorial/The_example.html)
22. [Multi-Grained Specifications for Distributed System Model Checking and Verification, arXiv:2409.14301](https://arxiv.org/abs/2409.14301)
23. [TLA+ Foundation](https://foundation.tlapl.us/)
24. [June 2025 Monthly Development Update, TLA+ Foundation](https://foundation.tlapl.us/blog/2025-06-dev-update/index.html)

---
*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: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › Formal logic and foundations › Logical calculi and logical syntax › Modal and temporal logic › Temporal logic

Copyright 2026 Edgepedia

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

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

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