Chapter

09

Eventually

Part III · Time

  • 5 lessons
  • 3 h 38 min of core lessons
  • Skills: intent, counterexamples

Lessons

About

Here is a finite log from a server: a request, then nothing. Can it show that the server will never respond?

It cannot, and the reason opens the second half of the course. Every invariant you have written so far says that something bad never happens, and a finite trace can show the bad thing. This chapter is about the other kind of claim: that something good eventually happens. No finite trace can refute that, so TLC shows you an infinite behavior instead, drawn as a lasso. And it turns out that a spec allows the system to do nothing at all, which is why "eventually" always needs an assumption.

The goals: safety and liveness, defined precisely; the operators [], <>, []<>, <>[] and ~>; reading lasso counterexamples; PROPERTY and the separate liveness cfg; and three things that are easy to confuse: deadlock, termination and liveness.

Before you start

  • Chapters 03 and 04: TLC, invariants, and stuttering.
  • Chapter 06 helps for the review and for one practice item.
  • Time: the chapter page shows the estimate, generated from the lessons.

What else is here

  • specs/: TrafficLight, Lighthouse, Elevator, BoundedBuffer, and the one-change variants the lessons run. Every spec but the lighthouse has a safety cfg and, where it matters, a .live.cfg; the lighthouse has one cfg per property, for the table in 09-02.
  • review/ (09-review): a teammate's nightly backup, with deadlock checking on and a reason it never fires.
  • ai/1-guarantees-progress/ (09-ai1): an AI-written dispatcher and a message claiming "this guarantees progress".
  • gate/ (09-gate): a three-floor dumbwaiter; gate/twin/ (09-gate-twin): a ticket queue at a deli counter. You write the liveness property and the assumption it needs.

Run it

From the repository root:

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

Skills

intent (stating intent as properties), counterexamples (reading them).

Elsewhere

  • Web version: https://indicogni.com/learn/tla-plus/09-eventually/
  • Recaps: CONCEPTS.md. Hints and explanation checks: HINTS.md. Predictions without answers: PREDICT.md.
  • Solutions: solutions/chapters/09-eventually/, including the gate references and their mutants.

Beyond the lessons

  • 09-review Review a teammate’s spec · chapters/09-eventually/review/ · ./tla check 09-review
  • 09-ai1 AI item · chapters/09-eventually/ai/1-guarantees-progress/ · ./tla check 09-ai1
  • 09-gate Gate · ./tla check --gate 09

    Hints

    Hint 1

    Write TypeOK, Init, Call and Close first, with the cfg, and run it after each. Then Open, then the three movements. Write Liveness before you add the assumption to Spec, and watch it fail.

    Hint 2

    Up and Down each need four conditions: the direction, a closed hatch, no call at the car's own floor, and a waiting floor ahead. Turn needs waiting floors, none at the car's floor, and none ahead in the current direction.

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

    Safety relates hatch and car. Liveness is about every floor, and about calls and hatch; lesson 09-02's table has the operator for "whenever this, later that". Spec gets the assumption from lesson 09-04.

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

    Hints

    Hint 1

    Write TypeOK, Init, TakeTicket and ShutWindow first, with the cfg, and run it after each. Then OpenWindow, then the three movements. Write Liveness before you add the assumption to Spec, and watch it fail.

    Hint 2

    StepRight and StepLeft each need four conditions: the heading, a shut window, no ticket at the clerk's own station, and a waiting station ahead. TurnAround needs waiting stations, none at the clerk's station, and none ahead.

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

    Safety relates window and clerk. Liveness is about every station, and about tickets and window; lesson 09-02's table has the operator for "whenever this, later that". Spec gets the assumption from lesson 09-04.