Unit 3 of 15 · about 4 hours · explain
Implementation versus specification refinement, nondeterminism and environment actions
Testing compares outputs; refinement compares behaviors. It is the only precise meaning of a protocol implementing a commit abstraction in this section.
You'll be able to
- Explain implementation as behavior inclusion: every visible behavior below is a behavior above, with internal steps as stuttering.
- Place nondeterministic choices and environment actions (loss, crash, abort) in the spec, and say what a check omits when they are missing.
- Read a refinement claim such as
TPSpec => TC!TCSpecand name which variables are hidden.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Lecture 8 part 2: how implementation worksTLA+ Video Course
Full part (12:13): what it means for one specification to implement another
- Lecture 10: refinement mappingsTLA+ Video Course
Part 1 (19:53): the general meaning of implementation; continue to part 2 at https://lamport.azurewebsites.net/video/video10b.html (21:26) for refinement mappings
- Lecture 15: Verification of distributed systems (IronFleet)MIT 6.5840 - Verification Lecture and Final Project
Refinement through Inductive invariants sections: IronFleet-style refinement, externally visible events, stuttering, transitivity, and why a wrong middle layer proves nothing
Focus on
- Refinement is behavior inclusion on visible state. The low-level spec may take internal steps; above, they look like stuttering.
- High-level nondeterminism is implementation freedom. TCommit lets a prepared transaction commit or abort; TwoPhase may always abort and still refine it.
- The environment is part of the model. TwoPhase has
RMChooseToAbortand spontaneousTMAbort; AB hasLoseMsg. A missing environment action is an unchecked assumption. - Refinement is transitive but garbage-preserving: the IronFleet lecture shows a wrong protocol layer gets stuck at the next refinement step, not excused by the one below.
Common mistakes · 3
- Proving impl-to-protocol and stopping. The IronFleet lecture's election-restriction question shows the stuck proof appears at the protocol-to-spec step.
- Calling a nondeterministic spec random. Nondeterminism is arbitrary choice explored by the checker, not a distribution the system samples.
- Hiding state the property reads.
tmPreparedandmsgscan hide becauseTCConsistentonly readsrmState; hidingrmStateitself would void the claim.
Try it yourself
Closed-book, before checking anything
TPSpec => TC!TCSpec: what it says, which variables the TCommit side sees (rmState only), and why always-abort still refines the abstract commit.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What does
TPSpec => TC!TCSpecassert?AnswerEvery behavior of the TwoPhase commit protocol is a behavior of the abstract Transaction Commit spec: 2PC implements commit, including the
TCConsistentinvariant that no two RMs decide in conflict.2.TwoPhase refines TCommit. May a conforming implementation abort every transaction?Answer
Yes. TCommit's
Decidepermits abort while nothing committed, so always-abort behaviors satisfy the abstract spec. Refinement permits useless but safe implementations.3.In the IronFleet lecture, where does a wrong protocol layer get caught?Answer
At the protocol-to-spec refinement step. Impl-to-protocol may still prove; the wrong middle layer gets stuck against the trusted top spec.
4.Why is the proof untrusted but the specification and the checker trusted?Answer
The checker mechanically re-verifies the proof, so a bad proof is caught. Nothing re-verifies the spec, so a wrong spec certifies a wrong system.
Practice
- TLA+ Examples: read the TwoPhase-to-TCommit refinement
The
TC == INSTANCE TCommitline andTHEOREM TPSpec => TC!TCSpec; list which variables each side readsPair with the AB
Spec => ABS!Spectheorem in video9b.zip; both hide channel and protocol state the abstract side never reads.
You're done when
You state two refinement claims from memory (TwoPhase-to-TCommit, AB-to-ABSpec), name the hidden variables in each, and place one environment action per spec.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 13 more in the section
- TLA+ Video CourseLeslie Lamport · primary
Complete lectures 1 to 10 (lectures 8, 9 and 10 have two parts each) and check the corrections page, while specifying a reduced transaction, workflow or replicated-log model from the capstone. Run TLC after every extension, report the model bounds with every result, and retain the first meaningful counterexample rather than polishing only the final model.
- MIT 6.5840 - Verification Lecture and Final ProjectMIT PDOS · required
Study the Spring 2026 verification lecture and IronFleet reading, then use the final-project guidance to frame a bounded real-system extension, evaluation and report. Course grading and staff review are unavailable to self-study, so use the roadmap defense rubric.
Also in this section
- TLA+ ExamplesTLA+ Foundation · support
Check
specifications/transaction_commit/(TCommit.tla,TwoPhase.tla,PaxosCommit.tlawith their.cfgfiles) with TLC alongside the lectures, and read the Paxos specifications for depth.specifications/TwoPhase/is a hardware handshake, not transaction commit. - Cambridge Concurrent and Distributed Systems Notes (Kleppmann) - CRDTs and CollaborationUniversity of Cambridge (Martin Kleppmann) · support
Use Section 8.1 (operation-based and state-based CRDTs, operational transformation) for the CRDT unit, and work Exercise 21 (prove the operation-based map CRDT converges) and Exercise 22 (its multi-value variant).
- A Comprehensive Study of Convergent and Commutative Replicated Data Types (Shapiro et al., 2011)INRIA report (Berkeley course copy) · support
Read Sections 1 to 3 (state-based and operation-based definitions, the semilattice and delivery conditions) and one example type for your implementation, not the whole catalog.
- Learn TLA+Hillel Wayne · support
Use the core lessons and the examples as a second explanation when a lecture stalls, and as the PlusCal reference if you write algorithms rather than raw actions.
- Hypothesis - Stateful TestingHypothesis · required
Use
RuleBasedStateMachineagainst a reference model for property-based state-machine tests of your extension, keep the failing seeds and shrunk examples, and plant a bug to show the machine detects it. - Jepsen - Consistency Models and AnalysesJepsen · required
Use the framework's generator, client, nemesis and checker roles to design the campaign, Knossos for single-register linearizability and Elle for transactional anomalies on recorded histories, and the public analyses for fault models. A simplified local checker must declare its object, model and completeness limits.
- Elle: Inferring Isolation Anomalies from Experimental Observations (Kingsbury and Alvaro)arXiv · required
Read how Elle infers version orders from list-append and register histories and detects cycles for G0 to G2. It needs complete histories, and a clean run is not a proof of serializability.
- How Amazon Web Services Uses Formal Methods (Newcombe et al., 2015)Amazon Science · support
Read it for why industrial teams specify designs in TLA+ and which bugs model checking found that testing missed. Its effort figures are anecdotes, not benchmarks.
- FoundationDB: A Distributed Unbundled Transactional Key Value Store (Zhou et al., 2021)FoundationDB · support
Read the simulation-testing section (deterministic single-threaded simulation, fault injection, seed replay) as the model for your own scheduler, and the architecture for unbundled transactions.
- DDIA 2e - Chapters 9, 10 and 14 ReviewMartin Kleppmann and Chris Riccomini · required
Revisit uncertainty, consistency, consensus and responsible system design while extracting the final contract. Use the book to challenge assumptions and alternatives, not to replace executable evidence.
- HLD Handbook - CRDTs, Multi-Region and Architecture Trade-offsHLD Handbook · support
Read the CRDT, multi-region, distributed SQL and relevant case-study chapters only after the formal core passes. Use its design prompts to prepare the final comparison and defense.
- CMU 15-721 - Selected Advanced Database Systems UnitsCarnegie Mellon Database Group · depth
Select at most one lecture group that informs your extension: #02 and #03 (data formats and encoding), #08 (scheduling and coordination) or #17 to #22 (system analyses such as BigQuery, Databricks, Snowflake, DuckDB and Redshift), with their papers. The course project needs a group, cloud credits and staff sign-off, so there is no runnable self-study project.
- Replicated Log and Stream Processor - Final CapstoneRoadmap-Final · support
Finish the protocol and invariant specification, deterministic fault campaign, bounded real-code extension, fallback, ablations, workload regions, negative result, operations dossier and independent reproduction package.