TLA+ Examples

April 25, 2026 · View on GitHub

Gitpod ready-to-code Validate Specs & Models

This is a repository of TLA+ specifications and models covering applications in a variety of fields. It serves as:

  • a comprehensive example library demonstrating how to specify an algorithm in TLA+
  • a diverse corpus facilitating development & testing of TLA+ language tools
  • a collection of case studies in the application of formal specification in TLA+

All TLA+ specs can be found in the specifications directory. To contribute a spec of your own, see CONTRIBUTING.md.

The table below lists all specs and indicates whether a spec is beginner-friendly, includes an additional PlusCal variant (✔), or uses PlusCal exclusively. Additionally, the table specifies which verification tool—TLC, Apalache, or TLAPS—can be used to verify each specification.

Space contraints limit the information displayed in the table; detailed spec metadata can be found in the manifest.json files in each specification's directory. You can search these files for examples exhibiting a number of features, either using the GitHub repository search or locally with the command ls specifications/*/manifest.json | xargs grep -l $keyword, where $keyword can be a value like:

  • pluscal, proof, or action composition (the \cdot operator)
  • Specs intended for trace generation (generate), simulate, or checked symbolically with Apalache (symbolic)
  • Models failing in interesting ways, like deadlock failure, safety failure, liveness failure, or assumption failure

It is also helpful to consult model files using specific TLC features. For this, run ls specifications/*/*.cfg | xargs grep -l $keyword, where $keyword can be a feature like SYMMETRY, VIEW, ALIAS, CONSTRAINT, or DEADLOCK.

Validated Examples Included Here

Here is a list of specs included in this repository which are validated by the CI, with links to the relevant directory and flags for various features:

NameAuthor(s)BeginnerTLAPS ProofPlusCalTLC ModelApalache
Teaching ConcurrencyLeslie Lamport
Loop InvarianceLeslie Lamport
Learn TLA⁺ ProofsAndrew Helwer
Boyer-Moore Majority VoteStephan Merz
Proof x+x is EvenMartin Riener
The N-Queens PuzzleStephan Merz
The Dining Philosophers ProblemJeff Hemphill
The Car Talk PuzzleLeslie Lamport
The Die Hard ProblemLeslie Lamport
The Prisoners & Switches PuzzleLeslie Lamport
The Prisoners & Switch PuzzleFlorian Schanda
Specs from Specifying SystemsLeslie Lamport
The Tower of Hanoi PuzzleMarkus Kuppe, Alexander Niederbühl
Missionaries and CannibalsLeslie Lamport
Stone Scale PuzzleLeslie Lamport
The Coffee Can Bean ProblemAndrew Helwer
EWD687a: Detecting Termination in Distributed ComputationsStephan Merz, Leslie Lamport, Markus Kuppe(✔)
The Moving Cat PuzzleFlorian Schanda
The Boulangerie AlgorithmLeslie Lamport, Stephan Merz
Misra Reachability AlgorithmLeslie Lamport
Byzantizing Paxos by RefinementLeslie Lamport
Barrier SynchronizationJarod Differdange
Peterson Lock Refinement With Auxiliary VariablesJarod Differdange
EWD840: Termination Detection in a RingStephan Merz
EWD998: Termination Detection in a Ring with Asynchronous Message DeliveryStephan Merz, Markus Kuppe(✔)
The Paxos ProtocolLeslie Lamport(✔)
Asynchronous Reliable BroadcastThanh Hai Tran, Igor Konnov, Josef Widder
Distributed Mutual ExclusionStephan Merz
Two-Phase HandshakingLeslie Lamport, Stephan Merz
Paxos (How to Win a Turing Award)Leslie Lamport(✔)
Finitizing Monotonic SystemsAndrew Helwer, Stephan Merz, Markus Kuppe
Dijkstra's Mutual Exclusion AlgorithmLeslie Lamport
The Echo AlgorithmStephan Merz
The TLC Safety Checking AlgorithmMarkus Kuppe
Transaction Commit ModelsLeslie Lamport, Jim Gray, Murat Demirbas
The Slush ProtocolAndrew Helwer
Minimal Circular SubstringAndrew Helwer
Snapshot Key-Value StoreAndrew Helwer, Murat Demirbas
Chang-Roberts Algorithm for Leader Election in a RingStephan Merz
MultiPaxos in SMR-StyleGuanzhou Hu
Einstein's RiddleIsaac DeFrain, Giuliano Losa
Resource AllocatorStephan Merz
Transitive ClosureStephan Merz
Atomic Commitment ProtocolStephan Merz
SWMR Shared Memory Disk PaxosLeslie Lamport, Giuliano Losa
Span Tree ExerciseLeslie Lamport
The Knuth-Yao MethodRon Pressler, Markus Kuppe
Huang's AlgorithmMarkus Kuppe
EWD 426: Token StabilizationMurat Demirbas, Markus Kuppe
Sliding Block PuzzleMariusz Ryndzionek
Single-Lane Bridge ProblemYounes Akhouayri
Software-Defined PerimeterLuming Dong, Zhi Niu
Simplified Fast PaxosLim Ngian Xin Terry, Gaurav Gandhi
Checkpoint CoordinationAndrew Helwer
Multi-Car Elevator SystemAndrew Helwer
Nano Blockchain ProtocolAndrew Helwer
The Readers-Writers ProblemIsaac DeFrain
Asynchronous Byzantine ConsensusThanh Hai Tran, Igor Konnov, Josef Widder
Folklore Reliable BroadcastThanh Hai Tran, Igor Konnov, Josef Widder
The Bosco Byzantine Consensus AlgorithmThanh Hai Tran, Igor Konnov, Josef Widder
Consensus in One Communication StepThanh Hai Tran, Igor Konnov, Josef Widder
One-Step Consensus with Zero-DegradationThanh Hai Tran, Igor Konnov, Josef Widder
Failure DetectorThanh Hai Tran, Igor Konnov, Josef Widder
Asynchronous Non-Blocking Atomic CommitThanh Hai Tran, Igor Konnov, Josef Widder
Asynchronous Non-Blocking Atomic Commitment with Failure DetectorsThanh Hai Tran, Igor Konnov, Josef Widder
Spanning Tree Broadcast AlgorithmThanh Hai Tran, Igor Konnov, Josef Widder
The Cigarette Smokers ProblemMariusz Ryndzionek
Conway's Game of LifeMariusz Ryndzionek
Chameneos, a Concurrency GameMariusz Ryndzionek
PCR Testing for Snippets of DNAMartin Harrison
RFC 3506: Voucher Transaction SystemSanthosh Raju, Cherry G. Mathew, Fransisca Andriani
Yo-Yo Leader ElectionLudovic Yvoz, Stephan Merz
TCP as defined in RFC 9293Markus Kuppe
B-treesLorin Hochstein
TLA⁺ Level CheckingLeslie Lamport
Condition-Based ConsensusThanh Hai Tran, Igor Konnov, Josef Widder
Buffered Random Access FileCalvin Loncaric
DisruptorNicholas Schultz-Møller
DAG-based ConsensusGiuliano Losa

Other Examples

Here is a list of specs stored in locations outside this repository or not validated by the CI, such as submodules. Since these specs are not covered by CI testing it is possible they contain errors, the reported details are incorrect, or they are no longer available. Ideally these will be moved into this repo over time.

SpecDetailsAuthor(s)BeginnerTLAPS ProofTLC ModelPlusCalApalache
Blocking QueueBlockingQueueMarkus Kuppe(✔)
IEEE 802.16 WiMAX Protocols2006, paper, specsPrasad Narayana, Ruiming Chen, Yao Zhao, Yan Chen, Zhi (Judy) Fu, Hai Zhou
On the diversity of asynchronous communication2016, paper, specsFlorent Chevrou, Aurélie Hurault, Philippe Quéinnec
CaesarMulti-leader generalized consensus protocol (Arun et al., 2017)Giuliano Losa
CASPaxosAn extension of the single-decree Paxos algorithm to a compare-and-swap type register (Rystsov)Tobias Schottdorf
DataPortDataport protocal 505.89PT, only PDF files (Biggs & Noriaki, 2016)Geoffrey Biggs, Noriaki Ando
egalitarian-paxosLeaderless replication protocol based on Paxos (Moraru et al., 2013)Iulian Moraru
fastpaxosAn extension of the classic Paxos algorithm, only PDF files (Lamport, 2006)Leslie Lamport
fpaxosA variant of Paxos with flexible quorums (Howard et al., 2017)Heidi Howard
HLCHybrid logical clocks and hybrid vector clocks (Demirbas et al., 2014)Murat Demirbas
L1Data center network L1 switch protocol, only PDF files (Thacker)Tom Rodeheffer
leaderlessLeaderless generalized-consensus algorithms (Losa, 2016)Giuliano Losa
losa_apThe assignment problem, a variant of the allocation problem (Delporte-Gallet, 2018)Giuliano Losa
losa_rdaApplying peculative linearizability to fault-tolerant message-passing algorithms and shared-memory consensus, only PDF files (Losa, 2014)Giuliano Losa
m2paxosMulti-leader consensus protocols (Peluso et al., 2016)Giuliano Losa
mongo-repl-tlaA simplified part of Raft in MongoDB (Ongaro, 2014)Siyuan Zhou
MultiPaxosThe abstract specification of Generalized Paxos (Lamport, 2004)Giuliano Losa
naiadNaiad clock protocol, only PDF files (Murray et al., 2013)Tom Rodeheffer
nfc04Non-functional properties of component-based software systems (Zschaler, 2010)Steffen Zschaler
raftRaft consensus algorithm (Ongaro, 2014)Diego Ongaro
SnapshotIsolationSerializable snapshot isolation (Cahill et al., 2010)Michael J. Cahill, Uwe Röhm, Alan D. Fekete
SyncConsensusSynchronized round consensus algorithm (Demirbas)Murat Demirbas
TerminationChannel-counting algorithm (Kumar, 1985)Giuliano Losa
Tla-tortoise-hareRobert Floyd's cycle detection algorithmLorin Hochstein
VoldemortKVVoldemort distributed key value storeMurat Demirbas
Tencent-PaxosPaxosStore: high-availability storage made practical in WeChat. Proceedings of the VLDB Endowment(Zheng et al., 2017)Xingchen Yi, Hengfeng Wei
PaxosPaxos
Lock-Free SetPlusCal spec of a lock-Free set used by TLCMarkus Kuppe
ParallelRaftA variant of RaftXiaosong Gu, Hengfeng Wei, Yu Huang
CRDT-BugCRDT algorithm with defect and fixed versionAlexander Niederbühl
asyncio-lockBugs from old versions of Python's asyncio lockAlexander Niederbühl
Raft (with cluster changes)Raft with cluster changes, and a version with Apalache type annotations but no cluster changesGeorge Pîrlea, Darius Foom, Brandon Amos, Huanchen Zhang, Daniel Ricketts
MET for CRDT-RedisModel-check the CRDT designs, then generate test cases to test CRDT implementationsYuqi Zhang
Parallel incrementParallel threads incrementing a shared variable. Demonstrates invariants, liveness, fairness and symmetryChris Jensen
The Streamlet consensus algorithmSpecification and model-checking of both safety and liveness properties of Streamlet with TLCGiuliano Losa
Petri NetsInstantiable Petri Nets with liveness propertiesEugene Huang
CRDTSpecifying and Verifying CRDT ProtocolsYe Ji, Hengfeng Wei
Azure Cosmos DBConsistency models provided by Azure Cosmos DBDharma Shukla, Ailidani Ailijiang, Murat Demirbas, Markus Kuppe
Simple Microwave OvenSpec of a microwave ovenKonstantin Läufer, George K. Thiruvathukal

Contributing a Spec

See CONTRIBUTING.md for instructions.

License

The repository is under the MIT license and you are encouraged to publish your spec under a similarly-permissive license. However, your spec can be included in this repo along with your own license if you wish.

Support or Contact

Do you have any questions or comments? Please open an issue or send an email to the TLA⁺ mailing list.