Chapter

12

Taming the state space, choosing your evidence

Part IV · Abstraction

  • 6 lessons
  • 4 h 23 min of core lessons
  • Skills: evidence, abstraction

Lessons

About

Two-phase commit with two, three and four participants. Predict how many states each model has before you run it. Then the harder question: TLC checked three participants, and your cluster has five. What do you know?

This chapter opens TLC up, teaches the tools that make an enormous or infinite model checkable and the price each one charges, and shows how to word a claim a sceptical teammate can check. Then it goes past model checking: inductive invariants, Apalache and TLAPS.

Before you start

  • Chapters 09 to 11: liveness, fairness and refinement. The liveness checks here assume you can read a lasso.
  • Chapter 03, lesson 04: what distinct, generated and depth mean.
  • Time: the chapter page shows the estimate, generated from the lessons.

What else is here

  • specs/: the models the lessons run, with inputs for the optional tools in proofs/ (TLAPS) and apalache/. The course shows those inputs and never their output.
  • review/ (12-review): a teammate's commit timer, and a bound that was not free.
  • ai/1-faster-and-wrong/ (12-ai1): an assistant's speed-up that makes a known bug disappear.
  • gate/ (12-gate): a lock service TLC cannot finish; gate/twin/ (12-gate-twin): a primary handoff. Each asks for sound reductions, a claim, and an inductive invariant.

Run it

From the repository root:

shell
./tla check 12-01
./tla check 12-review
./tla check --gate 12

Skills

evidence (knowing what a piece of evidence covers), abstraction (choosing what a model leaves out).

Elsewhere

  • Web version: https://indicogni.com/learn/tla-plus/12-state-space-and-evidence/
  • Recaps: CONCEPTS.md. Hints and explanation checks: HINTS.md. Predictions without answers: PREDICT.md.
  • Solutions: solutions/chapters/12-state-space-and-evidence/, including the gate references and their mutants.
  • Further reading and sources (Lamport's hour clock, Jim Gray's two-phase commit, Peterson's algorithm): CONCEPTS.md. These versions, their names and their constants are the course's own.

Beyond the lessons

  • 12-review Review a teammate’s spec · chapters/12-state-space-and-evidence/review/ · ./tla check 12-review
  • 12-ai1 AI item · chapters/12-state-space-and-evidence/ai/1-faster-and-wrong/ · ./tla check 12-ai1
  • 12-gate Gate · ./tla check --gate 12

    Hints

    Hint 1

    Start with the reductions. Which variable makes the state space infinite, and does any action or property read it? Then ask whether any constant, action or property names a particular node. If your cfg breaks WithinBudget, it keeps more states than the protocol has once the counter and the node names stop mattering; if it misses ReleaseWhileAllWait, something in it cuts the search or merges states that differ.

    Hint 2

    For Safety, run the grader with Safety == OneHolder and read the counterexample to induction. Its first state has a combination of pc, server and messages that the protocol could never produce. For one node, list the places the lock can be while that node has it or is about to: then ask what server says during each, and which of those places can exist at the same time.

    Hint 3 (nearly the answer; opening it marks a pass as "passed with help")

    For a node n, the lock can be in three places: pc[n] = "holding", GrantMsg(n) \in net, ReleaseMsg(n) \in net. Your Safety says something about server for each of them. The reductions use events and Nodes.

  • 12-gate-twin Gate twin, another domain · ./tla check --gate 12 --twin

    Hints

    Hint 1

    The counter makes the state space infinite; does anything read it? Do the initial states, the actions or OnePrimary single out a replica? If your cfg breaks WithinBudget, it keeps more states than the protocol has once the counter and the replica names stop mattering; if it misses HandoffToWithdrawn, something in it cuts the search or merges states that differ.

    Hint 2

    For Safety, start with OnePrimary and read the counterexample to induction. Its first state has a combination of roles, directory and messages that no handoff could produce. For one replica, list the places the primary role can be while that replica has it or is about to: then ask what directory says during each, and which of them can exist at the same time.

    Hint 3 (nearly the answer; opening it marks a pass as "passed with help")

    For a replica r, the primary role can be in two places: role[r] = "primary" and HandoffMsg(r) \in net. Your Safety says something about directory for each of them. The reductions use changes and Replicas.

  • CP3 Checkpoint CP3 follows this chapter: mixed items from every chapter so far, with no hints.