Skip to content

klaeufer/TLAPlusExamples

 
 

Repository files navigation

TLA+ Examples

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 file. You can search this file for examples exhibiting a number of features, like:

  • Specs (.tla files) including pluscal, proof, or action composition (the \cdot operator)
  • Specs intended for trace generation (generate), simulate, or checked symbolically with Apalache (symbolic)
  • Models (.cfg files) using the symmetry, view, alias, state constraint, or ignore deadlock features
  • Models failing in interesting ways, like deadlock failure, safety failure, liveness failure, or assumption failure

Examples Included Here

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

Name Author(s) Beginner TLAPS Proof PlusCal TLC Model Apalache
Teaching Concurrency Leslie Lamport โœ” โœ” โœ” โœ”
Loop Invariance Leslie Lamport โœ” โœ” โœ” โœ”
Learn TLAโบ Proofs Andrew Helwer โœ” โœ” โœ” โœ”
Boyer-Moore Majority Vote Stephan Merz โœ” โœ” โœ”
Proof x+x is Even Stephan Merz โœ” โœ” โœ”
The N-Queens Puzzle Stephan Merz โœ” โœ” โœ”
The Dining Philosophers Problem Jeff Hemphill โœ” โœ” โœ”
The Car Talk Puzzle Leslie Lamport โœ” โœ”
The Die Hard Problem Leslie Lamport โœ” โœ”
The Prisoners & Switches Puzzle Leslie Lamport โœ” โœ”
Specs from Specifying Systems Leslie Lamport โœ” โœ”
The Tower of Hanoi Puzzle Markus Kuppe, Alexander Niederbรผhl โœ” โœ”
Missionaries and Cannibals Leslie Lamport โœ” โœ”
Stone Scale Puzzle Leslie Lamport โœ” โœ”
The Coffee Can Bean Problem Andrew Helwer โœ” โœ”
EWD687a: Detecting Termination in Distributed Computations Stephan Merz, Leslie Lamport, Markus Kuppe โœ” (โœ”) โœ”
The Boulangerie Algorithm Leslie Lamport, Stephan Merz โœ” โœ” โœ”
Misra Reachability Algorithm Leslie Lamport โœ” โœ” โœ”
Byzantizing Paxos by Refinement Leslie Lamport โœ” โœ” โœ”
EWD840: Termination Detection in a Ring Stephan Merz โœ” โœ”
EWD998: Termination Detection in a Ring with Asynchronous Message Delivery Stephan Merz, Markus Kuppe โœ” (โœ”) โœ”
The Paxos Protocol Leslie Lamport โœ” โœ”
Asynchronous Reliable Broadcast Thanh Hai Tran, Igor Konnov, Josef Widder โœ” โœ”
Distributed Mutual Exclusion Stephan Merz โœ” โœ”
Two-Phase Handshaking Leslie Lamport, Stephan Merz โœ” โœ”
Paxos (How to Win a Turing Award) Leslie Lamport โœ” โœ”
Dijkstra's Mutual Exclusion Algorithm Leslie Lamport โœ” โœ”
The Echo Algorithm Stephan Merz โœ” โœ”
The TLC Safety Checking Algorithm Markus Kuppe โœ” โœ”
Transaction Commit Models Leslie Lamport, Jim Gray, Murat Demirbas โœ” โœ”
The Slush Protocol Andrew Helwer โœ” โœ”
Minimal Circular Substring Andrew Helwer โœ” โœ”
Snapshot Key-Value Store Andrew Helwer, Murat Demirbas โœ” โœ”
Chang-Roberts Algorithm for Leader Election in a Ring Stephan Merz โœ” โœ”
MultiPaxos in SMR-Style Guanzhou Hu โœ” โœ”
Einstein's Riddle Isaac DeFrain, Giuliano Losa โœ”
Resource Allocator Stephan Merz โœ”
Transitive Closure Stephan Merz โœ”
Atomic Commitment Protocol Stephan Merz โœ”
SWMR Shared Memory Disk Paxos Leslie Lamport, Giuliano Losa โœ”
Span Tree Exercise Leslie Lamport โœ”
The Knuth-Yao Method Ron Pressler, Markus Kuppe โœ”
Huang's Algorithm Markus Kuppe โœ”
EWD 426: Token Stabilization Murat Demirbas, Markus Kuppe โœ”
Sliding Block Puzzle Mariusz Ryndzionek โœ”
Single-Lane Bridge Problem Younes Akhouayri โœ”
Software-Defined Perimeter Luming Dong, Zhi Niu โœ”
Simplified Fast Paxos Lim Ngian Xin Terry, Gaurav Gandhi โœ”
Checkpoint Coordination Andrew Helwer โœ”
Finitizing Monotonic Systems Andrew Helwer, Stephan Merz, Markus Kuppe โœ” โœ”
Multi-Car Elevator System Andrew Helwer โœ”
Nano Blockchain Protocol Andrew Helwer โœ”
The Readers-Writers Problem Isaac DeFrain โœ”
Asynchronous Byzantine Consensus Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Folklore Reliable Broadcast Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
The Bosco Byzantine Consensus Algorithm Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Consensus in One Communication Step Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
One-Step Consensus with Zero-Degradation Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Failure Detector Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Asynchronous Non-Blocking Atomic Commit Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Asynchronous Non-Blocking Atomic Commitment with Failure Detectors Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
Spanning Tree Broadcast Algorithm Thanh Hai Tran, Igor Konnov, Josef Widder โœ”
The Cigarette Smokers Problem Mariusz Ryndzionek โœ”
Conway's Game of Life Mariusz Ryndzionek โœ”
Chameneos, a Concurrency Game Mariusz Ryndzionek โœ”
PCR Testing for Snippets of DNA Martin Harrison โœ”
RFC 3506: Voucher Transaction System Santhosh Raju, Cherry G. Mathew, Fransisca Andriani โœ”
Yo-Yo Leader Election Ludovic Yvoz, Stephan Merz โœ”
TCP as defined in RFC 9293 Markus Kuppe โœ”
TLAโบ Level Checking Leslie Lamport
Condition-Based Consensus Thanh Hai Tran, Igor Konnov, Josef Widder
Buffered Random Access File Calvin Loncaric โœ”
Disruptor Nicholas Schultz-Mรธller โœ”

Examples Elsewhere

Here is a list of specs stored in locations outside this repository, including submodules. They are not covered by CI testing so 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.

Spec Details Author(s) Beginner TLAPS Proof TLC Model PlusCal Apalache
Blocking Queue BlockingQueue Markus Kuppe โœ” โœ” โœ” (โœ”)
IEEE 802.16 WiMAX Protocols 2006, paper, specs Prasad Narayana, Ruiming Chen, Yao Zhao, Yan Chen, Zhi (Judy) Fu, Hai Zhou
On the diversity of asynchronous communication 2016, paper, specs Florent Chevrou, Aurรฉlie Hurault, Philippe Quรฉinnec
Caesar Multi-leader generalized consensus protocol (Arun et al., 2017) Giuliano Losa โœ” โœ”
CASPaxos An extension of the single-decree Paxos algorithm to a compare-and-swap type register (Rystsov) Tobias Schottdorf โœ”
DataPort Dataport protocal 505.89PT, only PDF files (Biggs & Noriaki, 2016) Geoffrey Biggs, Noriaki Ando
egalitarian-paxos Leaderless replication protocol based on Paxos (Moraru et al., 2013) Iulian Moraru โœ”
fastpaxos An extension of the classic Paxos algorithm, only PDF files (Lamport, 2006) Leslie Lamport
fpaxos A variant of Paxos with flexible quorums (Howard et al., 2017) Heidi Howard โœ”
HLC Hybrid logical clocks and hybrid vector clocks (Demirbas et al., 2014) Murat Demirbas โœ” โœ”
L1 Data center network L1 switch protocol, only PDF files (Thacker) Tom Rodeheffer
leaderless Leaderless generalized-consensus algorithms (Losa, 2016) Giuliano Losa โœ” โœ”
losa_ap The assignment problem, a variant of the allocation problem (Delporte-Gallet, 2018) Giuliano Losa โœ” โœ”
losa_rda Applying peculative linearizability to fault-tolerant message-passing algorithms and shared-memory consensus, only PDF files (Losa, 2014) Giuliano Losa
m2paxos Multi-leader consensus protocols (Peluso et al., 2016) Giuliano Losa โœ”
mongo-repl-tla A simplified part of Raft in MongoDB (Ongaro, 2014) Siyuan Zhou โœ”
MultiPaxos The abstract specification of Generalized Paxos (Lamport, 2004) Giuliano Losa โœ”
naiad Naiad clock protocol, only PDF files (Murray et al., 2013) Tom Rodeheffer โœ”
nfc04 Non-functional properties of component-based software systems (Zschaler, 2010) Steffen Zschaler โœ”
raft Raft consensus algorithm (Ongaro, 2014) Diego Ongaro โœ”
SnapshotIsolation Serializable snapshot isolation (Cahill et al., 2010) Michael J. Cahill, Uwe Rรถhm, Alan D. Fekete โœ”
SyncConsensus Synchronized round consensus algorithm (Demirbas) Murat Demirbas โœ” โœ”
Termination Channel-counting algorithm (Kumar, 1985) Giuliano Losa โœ” โœ” โœ” โœ”
Tla-tortoise-hare Robert Floyd's cycle detection algorithm Lorin Hochstein โœ” โœ”
VoldemortKV Voldemort distributed key value store Murat Demirbas โœ” โœ”
Tencent-Paxos PaxosStore: high-availability storage made practical in WeChat. Proceedings of the VLDB Endowment(Zheng et al., 2017) Xingchen Yi, Hengfeng Wei โœ” โœ”
Paxos Paxos โœ”
Lock-Free Set PlusCal spec of a lock-Free set used by TLC Markus Kuppe โœ” โœ”
ParallelRaft A variant of Raft Xiaosong Gu, Hengfeng Wei, Yu Huang โœ”
CRDT-Bug CRDT algorithm with defect and fixed version Alexander Niederbรผhl โœ”
asyncio-lock Bugs from old versions of Python's asyncio lock Alexander Niederbรผhl โœ”
Raft (with cluster changes) Raft with cluster changes, and a version with Apalache type annotations but no cluster changes George Pรฎrlea, Darius Foom, Brandon Amos, Huanchen Zhang, Daniel Ricketts โœ” โœ”
MET for CRDT-Redis Model-check the CRDT designs, then generate test cases to test CRDT implementations Yuqi Zhang โœ” โœ”
Parallel increment Parallel threads incrementing a shared variable. Demonstrates invariants, liveness, fairness and symmetry Chris Jensen โœ”
The Streamlet consensus algorithm Specification and model-checking of both safety and liveness properties of Streamlet with TLC Giuliano Losa โœ” โœ”
Petri Nets Instantiable Petri Nets with liveness properties Eugene Huang โœ”
CRDT Specifying and Verifying CRDT Protocols Ye Ji, Hengfeng Wei โœ”
Azure Cosmos DB Consistency models provided by Azure Cosmos DB Dharma Shukla, Ailidani Ailijiang, Murat Demirbas, Markus Kuppe โœ” โœ”
Microwave Simple microwave oven Konstantin 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.

About

A collection of TLAโบ specifications of varying complexities.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TLA 96.8%
  • TeX 2.2%
  • Other 1.0%