ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and shared lessons, time-to-delivery measurement, a library of 140 verification techniques and 20 recipes, personal data kept outside the clone, and releases with rollback. Standard library only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2.8 KiB
2.8 KiB
id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
| id | title | answers | rung | section | languages | kinds | cost | detect | ran_here | verified |
|---|---|---|---|---|---|---|---|---|---|---|
| pluscal | PlusCal for algorithm-shaped designs, checked with TLC | Does this step-by-step algorithm with several processes keep its invariant under every interleaving? | 1 | design | any | concurrency, state-machine | high | test -f tla2tools.jar && java -version | yes | ran |
Use when
- The design reads like code: processes with sequential steps, shared variables, loops, locks. PlusCal writes that directly and a translator produces the TLA+.
- You want to show a race (lost update, double-spend, check-then-act) exists or does not.
- The reader of the spec is a programmer who would find raw TLA+ actions harder to follow.
Do not use when
- The design is a set of independent events rather than processes. Raw
tlaplusis clearer. - You need fine control of fairness or refinement. Drop to TLA+.
Set up
Same tla2tools.jar as tlaplus (it contains the translator, pcal.trans). Java 11 or newer.
Minimal example
Counter.tla: two workers each read a shared counter then write it plus one. Each label (Read:, Write:) is one atomic step.
---- MODULE Counter ----
EXTENDS Integers
(*--algorithm Counter
variables x = 0;
process w \in 1..2
variable t = 0;
begin
Read: t := x;
Write: x := t + 1;
end process;
end algorithm; *)
\* BEGIN TRANSLATION
\* END TRANSLATION
BothDone == (\A self \in 1..2 : pc[self] = "Done") => x = 2
====
Translate, then write Counter.cfg with SPECIFICATION Spec and INVARIANT BothDone.
Run
java -cp tla2tools.jar pcal.trans Counter.tla
java -cp tla2tools.jar tlc2.TLC -config Counter.cfg Counter.tla
Re-run the translator after every edit of the algorithm; TLC checks the generated text, not the comment.
Passing looks like: exit 0 and No error has been found. This example fails on purpose: TLC exits 12 with Invariant BothDone is violated and a trace where both workers read 0 (the lost update). Make Read and Write one label to fix it.
As a contract check
{"id": "design-counter-pluscal", "claim": "Two concurrent increments always leave the counter at 2", "kind": "concurrency", "rung": 1, "cmd": "java -cp tla2tools.jar pcal.trans Counter.tla && java -cp tla2tools.jar tlc2.TLC -config Counter.cfg Counter.tla", "expect": {"exit": 0, "stdout_contains": "No error has been found"}, "tier": "deep", "timeout_s": 900}
Note that pcal.trans also rewrites Counter.cfg if it does not exist; keep your own .cfg committed.
What a pass does not prove
- Everything under
tlaplusapplies: it checks the model, only the constants in the.cfg, and nothing about the code. - A label is one atomic step. Putting too much in one label hides races; split steps to match what the real code does atomically.
- If the translator is not re-run, TLC checks stale text and the pass means nothing.