Chapter

02

Actions are formulas

Part I · Behaviors before syntax

  • 4 lessons
  • 2 h 59 min of core lessons
  • Skills: intent

Lessons

About

Is x' = x + 1 an assignment? Commit to an answer before you read on.

In chapter 01 you described systems with tables of guards and updates. Here you write them in TLA+, and the first thing to unlearn is the equals sign. An action is not a command that changes a variable. It is a formula that is true or false of a pair of states, an old one and a new one. Everything in this chapter follows from taking that literally: what an action says about a variable it never mentions, what \/ means in a step, and why TLC sometimes refuses a formula that is perfectly good mathematics.

The goals: read primed variables as the next state; write the frame with UNCHANGED; read disjunction as nondeterminism; and read /\, \/, =>, \E and \A as filters.

Before you start

  • Chapter 01: states, steps, behaviors, and the state-graph builder.
  • A working ./tla doctor (see START.md).
  • Time: the chapter page shows the estimate, generated from the lessons.

TLC runs in this chapter, but you only read its verdicts and errors. Every exercise comes with its cfg; writing cfgs is chapter 03.

What else is here

  • specs/: HourClock, AlarmClock, TrafficLight, DialLock, and the small variants the lessons run beside them, some that pass and some that fail.
  • review/ (02-review): a teammate's junction lights. Every check passes; find the bad edge in the state graph.
  • ai/1-spot-the-hallucination/ (02-ai1): eight snippets written in the style of AI output (provenance: curated). Six are flawed in ways SANY or TLC catch; two are correct and look suspicious.

There is no gate in this chapter. Gates start in chapter 03.

Run it

From the repository root:

shell
./tla check 02-01
./tla check 02-review
./tla check 02-ai1

Skills

intent (stating intent as formulas: actions now, properties from chapter 03).

Elsewhere

  • Web version: https://indicogni.com/learn/tla-plus/02-actions-are-formulas/
  • Recaps: CONCEPTS.md. Hints and explanation checks: HINTS.md. Predictions without answers: PREDICT.md.
  • Solutions: solutions/chapters/02-actions-are-formulas/, including the review's fix and the AI item's answer.

Beyond the lessons

  • 02-review Review a teammate’s spec · chapters/02-actions-are-formulas/review/ · ./tla check 02-review
  • 02-ai1 AI item · chapters/02-actions-are-formulas/ai/1-spot-the-hallucination/ · ./tla check 02-ai1