Review

Spaced review

Cards come back after 1, 3, 7 and 21 days. Rate each one honestly; there are no streaks.

Today

The review queue needs JavaScript. Every card is listed below.

All cards

00-01-a from Predict the balance

In transfer(), what must happen for the final balance to be wrong?

Show answer

Both transfers read the balance before either one writes it back. Then both compute from the same old value, and the second write erases the first.

00-01-b from Predict the balance

Why can a suite of sequential tests never see this race?

Show answer

Each test runs one call to completion before starting the next, so two calls are never in flight at once, and the bad orders of steps never happen.

00-02-a from Every interleaving

What is the difference between a state and an interleaving?

Show answer

A state is a snapshot of every variable's value. An interleaving is one order of all the steps of a run; running it passes through a sequence of states. Many interleavings can pass through the same state.

00-02-b from Every interleaving

Most interleavings of the two transfers are bad. Why is the bug still rare in real runs?

Show answer

Interleavings do not happen equally often. The bad ones need the other thread to reach its Read inside the short gap between this thread's Read and Debit, on one core or several, so they are common in the count and rare in time.

00-03-a from Your first TLC run

A TLC trace lists states numbered 1 to k. How many steps does it contain?

Show answer

k - 1. The first state is where the run starts, before any step, like the first post of a fence.

00-03-b from Your first TLC run

What is the difference between a TLC error and a violation?

Show answer

A violation means TLC found a reachable state where your invariant is false, and it shows a trace to it (so does a deadlock, a reachable state where no step is possible). An error means TLC could not evaluate, parse or configure something, so there is no verdict.

00-04-a from How this course works

What is the one question this course asks of any piece of evidence?

Show answer

Could this check have failed? A check that cannot fail on the bug you care about tells you nothing about it.

00-04-b from How this course works

Where may you use AI tools in this course, and where not?

Show answer

Allowed for explanations and for Warm-up and Core practice. Not allowed for gate specs, gate properties, checkpoints or mastery drills. From chapter 14 it becomes part of the workflow, with you owning the spec.

01-01-a from A state is a snapshot

What is a state?

Show answer

A value for every variable of the model, all at one instant. Two states are the same only if every variable has the same value in both.

01-01-b from A state is a snapshot

A program reaches two different lines with exactly the same data. Is that one state or two?

Show answer

Two. Where the program is, its program counter, is one more variable, and it differs. What can happen next differs too.

01-02-a from Steps and the state graph

What is a step, and how is it different from an action?

Show answer

A step is a pair of states, before and after: one arrow in the state graph. An action is a rule that allows a set of steps, so one action can appear as many arrows.

01-02-b from Steps and the state graph

Why can a system reach fewer states than the number of combinations of its variables' values?

Show answer

The state graph holds only the states reachable from an initial state by allowed steps. Some combinations are good snapshots that no sequence of steps leads to.

01-03-a from Behaviors are infinite

A print job reaches done, and nothing more can happen to it. What is the next state of its behavior?

Show answer

Done again, and again forever. Every behavior is infinite, so a system that stops still has a next state: the same one. The step from done to done changes nothing and is called a stuttering step.

01-03-b from Behaviors are infinite

Why does TLA+ make every behavior infinite, even for a system that finishes?

Show answer

So that there is one shape for everything. Stopping is a final state repeated forever, and claims about "always" and "eventually" need no special case for the end.

01-04-a from A spec is a filter

A spec made only of an initial condition and actions is a filter on behaviors. What are its two meshes?

Show answer

The first state must be an initial state, and every step must be allowed by one of the actions or change nothing. A behavior that passes both is allowed.

01-04-b from A spec is a filter

The traffic light has a Walk action. Must every behavior contain a Walk step?

Show answer

No. An action allows a step; it never requires one. Behaviors that never walk are allowed. Saying that something must eventually happen takes more than a list of allowed steps (chapters 09 and 10).

02-01-a from Primes

In an action, what does a primed variable such as hour' stand for?

Show answer

The variable's value in the new state of a step. The unprimed hour is its value in the old state. The action is a true-or-false claim about that pair of states, not an instruction.

02-01-b from Primes

hour' = e and e = hour' are the same formula. Why does TLC accept only the first?

Show answer

TLC reads an action left to right and gives hour' a value only when it reaches hour' = e, hour' \in S or UNCHANGED hour with hour' still unset. Any earlier use of hour', such as e = hour', or a test like hour' > 0 written first, is evaluated, finds no value, and stops TLC with an error. In the logic the order does not matter.

02-02-a from UNCHANGED and the frame

An action never mentions the variable alarm. In the logic, what may alarm be after a step of that action?

Show answer

Anything at all. An action constrains only what it says, so with no conjunct about alarm', every value makes it true. UNCHANGED alarm, which means alarm' = alarm, is how you say it stays.

02-02-b from UNCHANGED and the frame

What does TLC do with an action that leaves a variable without a value, and how do you spot the variable?

Show answer

It stops with "Successor state is not completely specified" and names the variable. In the trace's last state that variable is shown as null. TLC never tries every value.

02-03-a from Or means "may"

What does \/ do inside an action?

Show answer

It lists the ways a step may go. A pair of states satisfies the action if it satisfies any disjunct, so when several are true the spec allows each, and TLC explores every one. Nothing is chosen.

02-03-b from Or means "may"

Why does each disjunct of an action need to settle every variable that its shared part does not?

Show answer

Each disjunct is a complete description of one way the step can go. A disjunct that leaves a variable without a value allows anything for it in the logic, and TLC stops on that branch with "not completely specified".

02-04-a from Just enough logic

Read /\ and \/ as filters on candidate states or steps. What does each do?

Show answer

P /\ Q lets a candidate through only if both pass it, so adding a conjunct can only narrow the set. P \/ Q lets it through if either passes it, so adding a disjunct can only widen it. P => Q lets through every candidate that P rejects.

02-04-b from Just enough logic

Read \A w \in {a, b, c} : w \in 0..2 and \E w \in {a, b, c} : w = 2 as filters. What does each pass?

Show answer

\A is a long /\: it passes a state only if every wheel shows 0, 1 or 2. \E is a long \/: it passes a state if at least one wheel shows 2, whatever the others show. A quantifier is a query over a set: does every element pass, or does any one?

03-01-a from One command

What does SANY check, and what does it never do?

Show answer

It checks that the module is well formed, with every name defined and used correctly. It never computes a state.

03-01-b from One command

Name three things a cfg tells TLC that the module does not.

Show answer

The values of the constants, which formula is the system (SPECIFICATION, or INIT and NEXT), and which invariants to check.

03-02-a from Your first counterexample

Why does a TLC trace for an invariant violation stop at the bad state instead of showing a whole infinite behavior?

Show answer

Once a state breaks an invariant, nothing later can repair it, so the path to that state is all the evidence needed.

03-02-b from Your first counterexample

Why are the course's TLC traces always shortest ones?

Show answer

The course runs TLC with one worker, so the search is strictly breadth-first and the first violation found is at the smallest depth.

03-03-a from Break it on purpose

TLC reports no violation and zero distinct states. What has it shown about your invariants?

Show answer

Nothing. With no reachable states, every invariant holds vacuously.

03-03-b from Break it on purpose

How does ./tla check that the witness W is reachable?

Show answer

It checks ~W as an invariant in a wrapper module and expects a violation; the trace shows how W is reached.

03-04-a from Reading the numbers

TLC reports more states generated than distinct states. Did it count something twice by mistake?

Show answer

No. Generated counts every successor it computed, including repeats; distinct counts each state once.

03-04-b from Reading the numbers

What does the depth in TLC's summary line measure, and in what unit?

Show answer

The length of a shortest path from an initial state to the reachable state farthest from it, counted in states: an initial state is at depth one, so the farthest state is one step fewer than the depth away.

03-05-a from TypeOK, and the check you didn't configure

The cfg names only INVARIANT TypeOK, and TLC finds no violation. May you say the thermostat keeps the room comfortable?

Show answer

No, for two reasons. TLC never checked Comfortable, because the cfg did not name it. And even a cfg that names it gives "no violation found in this model": one finite model, not a proof.

04-01-a from The shape of every spec

Unpack [Next]_vars, and say which steps it allows.

Show answer

Next \/ (vars' = vars): every Next step, plus every step that leaves all the variables in vars unchanged (a stuttering step).

04-01-b from The shape of every spec

What does <<A>>_v mean, and why is <<Rest>>_vars false of every step when Rest is UNCHANGED vars?

Show answer

A /\ (v' # v), an A step that really changes v. A Rest step never changes vars, so no step is both.

04-02-a from Stuttering steps

A step of the minute clock takes min from 7 to 8 and leaves hr unchanged. Is it a stuttering step?

Show answer

For the hour clock's spec, subscript hr, yes: hr is unchanged. For the minute clock's spec, subscript << hr, min >>, no: min changed. Stuttering is always relative to a subscript.

04-02-b from Stuttering steps

A clock whose hand never moves satisfies Init /\ [][Advance]_hr when Init holds in its first state. Why?

Show answer

Every step of its behavior leaves hr unchanged, and the box allows every such step. A formula of this shape says which steps are allowed, never that a step must happen.

04-03-a from Why the subscript

Why does SANY reject Spec == Init /\ []Next?

Show answer

[] cannot be applied to a bare action. The only action form allowed under [] is [A]_v, which always permits steps that leave v unchanged. That keeps every TLA formula stuttering invariant.

04-03-b from Why the subscript

WatchesBoth == [][HourNext]_<< hr, min >> fails on the minute clock, and WatchesHour == [][HourNext]_hr holds. Why?

Show answer

A minute tick changes min. For WatchesBoth that is a change it watches, and the tick is not an HourNext step. For WatchesHour it is a stuttering step: hr is unchanged.

04-04-a from The frame-rate test and the shadow

What is stuttering invariance, and which piece of syntax makes every TLA formula have it?

Show answer

Adding or removing steps that leave a formula's variables unchanged never changes whether the formula is true. The subscript in [A]_v, since the box always allows those steps; and TLA has no temporal "next" operator that could count them: a primed variable may appear only inside an action.

04-04-b from The frame-rate test and the shadow

The minute clock satisfies the hour clock's spec. What exactly was checked?

Show answer

That every behavior of the minute clock, with only hr kept (its shadow), is a behavior the hour clock's spec allows, stuttering included: Spec => HourSpec. Nothing about how hr lines up with min.

05-01-a from Sets and quantifiers as queries

In GuardedSeatBooking, what does the guard ~\E h \in Guests : (the pair of s and h) \in bookings ask, in words?

Show answer

Whether no guest holds seat s. The \E part is a query over the set of pairs, true as soon as one guest h is paired with s; the ~ negates it.

05-01-b from Sets and quantifiers as queries

The teammate's guard asked whether the pair of s and g was missing from bookings. Why did TLC find a double booking?

Show answer

The guard asks whether this guest has this seat, not whether anyone does. A second guest passes it for a seat that is already sold.

05-02-a from Functions are total maps

How many functions does [S -> T] contain, for finite sets S and T?

Show answer

|T| to the power |S|: one independent choice of value from T for each element of S.

05-02-b from Functions are total maps

Why does an action update a function with [f EXCEPT ![x] = v] and not with f'[x] = v?

Show answer

f'[x] = v only says what the new function is at x; it says nothing about the other points. EXCEPT names the whole new function: f everywhere, except v at x.

05-03-a from Records, sequences, SUBSET

List the elements of SUBSET {"read", "write"}.

Show answer

{}, {"read"}, {"write"} and {"read", "write"}. SUBSET includes the empty set and each element on its own.

05-03-b from Records, sequences, SUBSET

What is the difference between [a |-> S] and [a : S]?

Show answer

[a |-> S] is one record whose field a holds S. [a : S] is the set of every record whose field a holds an element of S.

05-04-a from CHOOSE is deterministic

A spec models "a delivery of some size from 1 to 3" as CHOOSE n \in 1..3 : TRUE. What does TLC explore?

Show answer

Deliveries of one size only, the same every time: with constant arguments, CHOOSE denotes one fixed value. A choice the world makes needs \E n \in 1..3.

05-04-b from CHOOSE is deterministic

When is CHOOSE the right tool?

Show answer

When every element it could pick gives the same result, as when a recursive sum takes the bins in any order.

05-05-a from Constants and model values

A teammate's action writes 0 into a chart of guests. SANY accepts it and TLC runs. Why?

Show answer

TLA+ is untyped: any value can go anywhere. Only an invariant such as TypeOK, named in the cfg, says the 0 is wrong.

05-05-b from Constants and model values

How does an ASSUME differ from an invariant that mentions only constants?

Show answer

The ASSUME is part of the module, so TLC checks it under every cfg; the invariant is checked only when a cfg names it. A failed ASSUME means the cfg is wrong, not the system.

06-01-a from Productive failure

Why is "the if checks for a free seat before booking" not an argument that check-then-act code is safe?

Show answer

The check is true when it runs. Another process can change the data before the act, so the act relies on a fact that may be stale.

06-01-b from Productive failure

In a spec, what does Next == \E c \in Clients : Check(c) \/ Book(c) say about who runs next?

Show answer

Nothing fixed: every step is a step of some client, any client. So the behaviors include every interleaving of the clients' steps, and TLC visits every state any of them reaches.

06-02-a from Program counters by hand

When you model concurrent code by hand, which local variables must become part of the state?

Show answer

Every local variable whose value is set in one step and used in a later one. It carries a view of shared data across a gap where other processes can act.

06-02-b from Program counters by hand

What does pc[w] = "claim" say about the system?

Show answer

That worker w's next step is the claim. It says nothing about who runs next: any process may take the next step.

06-03-a from Atomicity is a choice

A model in which each balance update is one step passes. The code updates a balance with a read call and a write call. What has the pass shown about the code?

Show answer

Nothing. The model makes each update indivisible, which the code does not. The pass is evidence only about a program whose updates really are indivisible.

06-03-b from Atomicity is a choice

How big should each step of a concurrency model be?

Show answer

As big as the implementation's real indivisible operation: one atomic hardware instruction (such as compare-and-swap), one single-row SQL update or a transaction run at SERIALIZABLE isolation, one thread-safe call. Bigger hides interleavings; smaller reports races the system rules out.

06-04-a from Mutual exclusion

Raising your flag before waiting makes two flags safe. What does it break, and how does Peterson repair it?

Show answer

Both can raise their flags and then wait for each other for ever: a deadlock. Peterson adds a turn variable that each gives away after raising its flag; when both want in, the one who gave the turn away last waits.

06-04-b from Mutual exclusion

Mutual exclusion holds in a model. Name two things that pass has not shown about the real mutex.

Show answer

That a waiting process eventually gets in: no liveness property was checked, and one would hold only under a fairness assumption (chapters 09–10). And that the hardware runs the reads and writes in program order: most real CPUs and compilers reorder, so fences are needed.

06-05-a from Deadlock as TLC reports it

Is deadlock part of what a TLA+ spec says?

Show answer

No. Init /\ [][Next]_vars allows stuttering in every state, so no behavior is ever stuck. Deadlock is a check TLC adds: a reachable state where Next itself is not enabled. Two specs with the same behaviors can differ in whether TLC reports one, and it reports finished runs and jammed systems alike.

06-05-b from Deadlock as TLC reports it

Why mark a proper end with a guarded Finished step rather than CHECK_DEADLOCK FALSE?

Show answer

Finished silences the report only in the intended end state, so every other stuck state is still reported. CHECK_DEADLOCK FALSE hides them all.

07-01-a from Read the translation first

What does the PlusCal translator add to Next that a hand-written pc spec usually lacks, and why?

Show answer

A Terminating disjunct: once every process's pc is "Done", a step that changes nothing. It gives the final state a successor, so TLC does not report the normal end as a deadlock.

07-01-b from Read the translation first

Does the Terminating disjunct change which behaviors the spec allows?

Show answer

No. [Next]_vars already allows steps that change nothing. It changes only what TLC's deadlock check sees, and only in states where every process is done.

07-02-a from Labels are steps

In PlusCal, what is one step?

Show answer

Everything from one label to the next. The translator turns it into one action, so no other process can run in the middle of it.

07-02-b from Labels are steps

Why does the PlusCal translator insist on a label in front of every while loop?

Show answer

The loop jumps back to its test, and pc needs a value that means "at the test". The label provides it. Leaving the loop is one more step of that label.

07-03-a from Processes, await, either, with

What does await P become in the translation, and what does a process at a false await do?

Show answer

A conjunct P of the label's action. While P is false the action is not enabled, so the process takes no step at all; it does not spin.

07-03-b from Processes, await, either, with

A branch of an either can never run, and coverage says every action fired. Why, and what catches it?

Show answer

./tla's coverage line counts actions, and the whole either is inside one label's action. A witness that needs the branch catches it: ./tla reports the witness NOT reached.

07-04-a from Move a label, change the bugs

Two processes, and one more label in each. When does that label create a race?

Show answer

When the other process can see, between the two steps, a value that it then acts on, such as a check whose result is not yet recorded. A label after the decision is recorded only delays the rest.

07-04-b from Move a label, change the bugs

Every run of a PlusCal model ends with sold = printed, but TLC reports the invariant violated. How?

Show answer

Invariants are checked in every reachable state, including states between two labels of a process. There the sale is recorded and the ticket not yet printed.

07-05-a from Producer and consumer

A PlusCal consumer loops forever and the producer stops. Why does TLC report a deadlock, despite PlusCal's Terminating step?

Show answer

Terminating is one disjunct for the whole algorithm, enabled only when every process is "Done", and a while TRUE consumer never is; here the translator leaves Terminating out altogether. At the end, no process has an enabled step: a deadlock.

07-05-b from Producer and consumer

Delete the await in front of Head(buf). Does TLC report a violation or an error, and why?

Show answer

An error. Without the guard the step is enabled on an empty buffer, and TLC cannot compute Head of an empty sequence, so it stops instead of producing a state to check.

08-01-a from The network is a set

Why does a set of messages in flight model a network that reorders, without any reorder action?

Show answer

A set has no order, and the receive step may take any element of it, so every arrival order is a behavior of the spec.

08-01-b from The network is a set

Over a reordering network, what did the replica need in order to end with the newest version?

Show answer

It compares versions and drops a message older than what it holds, while still taking that message out of the network.

08-02-a from Loss and duplication for free

In a spec whose network is a set, how do you allow duplicate delivery?

Show answer

Leave the message in the set when it is received. Nothing then forbids receiving it again.

08-02-b from Loss and duplication for free

Why does adding an explicit Lose action never make an invariant about the sender and receiver fail?

Show answer

Any behavior with a lost message matches one where the message stays in the set and is never taken, with the same endpoint states. Loss matters for a property that mentions the network, and once fairness says messages must arrive.

08-03-a from Queues versus sets

A sender puts the same value into a set network twice before either is received. What does the set hold?

Show answer

One copy. A set cannot hold an element twice, so the second send changes nothing; use IDs, a bag or a sequence if copies must count.

08-03-b from Queues versus sets

Does modelling a channel as a sequence make it first-in, first-out?

Show answer

No. Reading only from the front does. A sequence read at any position reorders as freely as a set.

08-04-a from Alternating bit

Why is one bit enough for stop-and-wait over a channel that keeps order, but not over one that reorders?

Show answer

When both the data and the ack channels keep order, only copies of the current and the previous message, and acks for them, can arrive, and the bit tells those two apart. With reordering, a copy of any older message or ack can arrive, and a bit cannot tell it from a new one.

08-04-b from Alternating bit

Over a network that reorders, what does stop-and-wait need instead of an alternating bit?

Show answer

A sequence number on each message and each ack, compared with the next number the receiver expects and the number the sender is on.

08-05-a from Idempotent retries

Why must an idempotency key be chosen once per operation rather than once per attempt?

Show answer

The server deduplicates by key. A key per attempt makes every retry look like a new operation, so it is performed again.

08-05-b from Idempotent retries

The client sent a request and heard nothing back. What can it conclude?

Show answer

Nothing about the server: the request or the reply may have been lost or may still be in flight. A retry is safe only if the server recognises it as the same request, keeps its key for as long as a retry can arrive, and records the key in the same atomic step as the work.

09-01-a from The prefix judge

What makes a property a safety property, and what makes it a liveness property?

Show answer

Safety: every violating behavior has a finite prefix that already violates it, whatever comes next. Liveness: every finite prefix can still be continued into a behavior that satisfies it.

09-01-b from The prefix judge

"Every request is answered within three changes of state." Safety or liveness?

Show answer

Safety. The deadline makes a violation finite: three changes of state with no answer. Without the deadline it would be liveness.

09-02-a from Operators on lassos

On a lasso (a stem, then a loop), where must P hold for []<>P, and where for <>[]P?

Show answer

[]<>P: in at least one state of the loop. <>[]P: in every state of the loop. The stem does not matter to either.

09-02-b from Operators on lassos

What does P ~> Q abbreviate, and how is it read?

Show answer

[](P => <>Q), read "P leads to Q": whenever P holds, Q holds then or at some later state.

09-03-a from Why TLC shows you a lasso

PROPERTY P, where P is a state predicate with no temporal operator. What does TLC check?

Show answer

Only that P holds in the initial states. TLC warns about it. INVARIANT P, or PROPERTY []P, checks every reachable state.

09-03-b from Why TLC shows you a lasso

An AI assistant summarises a run as "TLC found no violation of PROPERTY Responds, so every request gets a response." Here Responds == req => <>resp. Is the summary accurate?

Show answer

No. With no [] in front, Responds is a claim about the first state only, and TLC gives no warning for it. The requirement is req ~> resp, which is [](req => <>resp).

09-04-a from Doing nothing is legal

Why does a spec of the form Init /\ [][Next]_vars satisfy no liveness property like <>Done?

Show answer

[][Next]_vars allows stuttering steps, so every behavior may stop at any point and repeat its state for ever. Unless Done already holds there, <>Done fails.

09-04-b from Doing nothing is legal

A liveness check's summary line ends "then stuttering forever". What do you look at first, and what can it mean?

Show answer

Whether a real step is possible in the last state. If one is, the spec is missing an assumption, such as WF_vars(Next). If none is, the system stopped for good: stuck in a deadlock, or at an end the spec allows before the property was met.

09-05-a from Deadlock, termination, liveness

A spec deadlocks in its goal state. Can it still satisfy a liveness property such as <>Done?

Show answer

Yes. A deadlock is about what can happen next in one state; <>Done is about what has happened in a behavior. A behavior that reaches Done and then stutters there for ever satisfies it, as HaltingBuffer does with deadlock checking off.

09-05-b from Deadlock, termination, liveness

A spec never deadlocks and has WF_vars(Next). Can a liveness property still fail? How would the trace end?

Show answer

Yes, with a loop: the system keeps taking steps that never reach the goal. The trace ends with "back to state k".

10-01-a from Be the scheduler

FairLock's Spec is Init /\ [][Next]_vars, with no fairness. Why can TLC show a behavior in which a waiting process never gets the lock?

Show answer

Spec only constrains each step. A behavior that stops and stutters for ever satisfies it, so nothing forces the step the waiting process needs.

10-01-b from Be the scheduler

What does WF_vars(Next) take away from a hostile scheduler, and what does it leave?

Show answer

It takes away stopping while some step is possible. It leaves favouritism: the scheduler can keep choosing other processes' steps for ever.

10-02-a from Weak fairness from a starvation trace

Write WF_v(A) in terms of ENABLED, <<A>>_v, [] and <>, and say it in words.

Show answer

<>[](ENABLED <<A>>_v) => []<><<A>>_v. If an A step that changes v is possible at every moment from some point on, such steps happen infinitely often.

10-02-b from Weak fairness from a starvation trace

FairLock under weak fairness on every Acquire(p) still lets a process starve. Which word in the definition of WF lets the scheduler do it?

Show answer

"Continuously". The other process keeps taking the lock, so the waiting process's Acquire is disabled once per round, and WF asks nothing of an action that is not continuously enabled.

10-03-a from When WF is not enough

What is the one difference between the definitions of WF_v(A) and SF_v(A)?

Show answer

The hypothesis. WF needs ENABLED <<A>>_v continuously (<>[]); SF needs it only infinitely often ([]<>). Both then demand <<A>>_v steps infinitely often.

10-03-b from When WF is not enough

FairLock reports the same number of distinct states with no fairness and with strong fairness. Why?

Show answer

Fairness does not change which states are reachable. It only changes which infinite paths through the graph count as behaviors of the spec.

10-04-a from Fairness hides liveness bugs, never safety bugs

A teammate adds strong fairness to every action to make a failing invariant pass. Can it work?

Show answer

No. Fairness on actions of Next only constrains the infinite tail of a behavior; any finite prefix that reaches the bad state can still be continued fairly. TLC does not even use fairness when it checks invariants.

10-04-b from Fairness hides liveness bugs, never safety bugs

An AI summary says "with strong fairness on every action, TLC finds no violation of NoStarvation, so the design is starvation-free." What should you check before accepting it?

Show answer

What each fairness conjunct promises and who keeps that promise. SF on a lock or on a user's action is an assumption the real system may not meet; under the fairness a real scheduler gives, the same design may starve.

10-05-a from Where fairness comes from

Give a real mechanism behind each: weak fairness on a worker's retry, and strong fairness on receiving a message that is resent.

Show answer

A timer that keeps firing while the task is open (broken by a crash or a retry budget). A network that drops copies at random rather than all of them for ever (random loss gives delivery with probability 1, which SF records as certain; broken by a partition that never heals).

10-05-b from Where fairness comes from

A set network leaves messages in the set, so loss is free. What happens to that loss when you add weak fairness on Receive?

Show answer

It disappears for every message that stays receivable: its receive stays enabled, so weak fairness forces it to happen. To keep a lossy network under fairness, add an explicit Lose action that takes the message out.

11-01-a from One system, three granularities

Why can AtomicKV not answer "was the client told the write is done?"

Show answer

The question is not a sentence about AtomicKV's variables. It has a store and nothing else: no client, no backup, no ack. A model answers only questions about what it contains.

11-01-b from One system, three granularities

Adding a backup crash to TwoCopyKV leaves its distinct count unchanged. What did the crash add?

Show answer

Behaviors, not states. Every state the crash reaches was already reachable without it; the crash only gives a new path to them.

11-02-a from The one-line intent

In a refinement check, which implementation steps must match an action of the abstract spec?

Show answer

Only the steps that change the shadow, the abstract state read off through the mapping. Every other step is a stuttering step of the abstract spec, which [Next]_vars allows.

11-02-b from The one-line intent

Why does a refinement check need a witness on the shadow, not only on the implementation?

Show answer

A mapping that never moves makes every step a stuttering step, so the refinement holds while saying nothing. A witness on the shadow shows that the mapped state really changes; the implementation can do all its work while a bad mapping looks away.

11-03-a from Refinement mappings

The implementation has no variable that matches an abstract variable. Is refinement still possible?

Show answer

Yes. A refinement mapping gives each abstract variable an expression over the implementation's variables, such as "the current message while the receiver has not delivered it, else empty". It is substitution, not renaming.

11-03-b from Refinement mappings

Why does a refinement check report the same distinct count as the implementation alone?

Show answer

The abstract spec has no state of its own in the check: every abstract variable is an expression over the implementation's state. TLC explores the implementation and evaluates the abstract step relation on each step.

11-04-a from Break the mapping, read the trace

How do you read a refinement counterexample?

Show answer

Compute the shadow, the abstract state the mapping reads off, in every state of the trace. The violating step is the first pair of shadows that is neither an abstract step nor a stutter. TLC prints only the implementation; the shadow is your job.

11-04-b from Break the mapping, read the trace

Why can no finer-grained implementation refine an abstract spec under a mapping that changes an abstract variable on every step?

Show answer

Then the abstract spec must take a step whenever the implementation does, so no implementation step can be an abstract stutter. An implementation that needs several steps per abstract step has nowhere to put the extra ones.

11-05-a from When no mapping exists

When does no refinement mapping exist, and what do you add?

Show answer

When two implementation states that are equal now need different abstract values because of their pasts: the implementation discarded information the abstract spec keeps. Add a history variable that records it, without letting any guard or update read it, and map to that.

11-05-b from When no mapping exists

An AI summary says "TLC confirms AlternatingBit refines ReliableChannel, so every message is eventually delivered." The cfg checked ChanInit and ChanStep on Spec. Is the summary accurate?

Show answer

No. Those properties are the safety half. The protocol's Spec has no fairness and allows it to stop, so delivery was not checked; checking Chan!Liveness on Spec fails. It passes only on a spec that adds enough of the protocol's own fairness, and the summary should say which.

12-01-a from Inside TLC

Why can TLC check an invariant the moment it computes a state, but not a liveness property?

Show answer

An invariant is a claim about one state. A liveness property is refuted by a loop of states, so TLC needs the graph's edges and a second search over the whole graph.

12-01-b from Inside TLC

An AI summary says "the liveness run reported the same distinct count as the safety run, so liveness checking is free here." Is it accurate?

Show answer

No. Both runs build the same state graph, so the counts agree. The liveness check then searches that graph for fair loops, which costs memory and time the summary line does not show.

12-02-a from Predict the growth curve

What is the difference between CONSTRAINT and VIEW in what they cost you?

Show answer

A constraint cuts behaviors: TLC stops exploring from states that break it, so violations further on are never found. A view merges states that agree on an expression; it loses nothing if the dropped variables cannot affect any action or property.

12-02-b from Predict the growth curve

A model with two participants has a few dozen states and one with three has about a hundred. Why is "a few hundred for four" a better guess than "about a hundred and seventy"?

Show answer

Each participant multiplies the number of reachable combinations by roughly the same factor. Growth per component is multiplicative, not additive.

12-03-a from Symmetry and its traps

When is a symmetry set over a set of model values sound for invariants?

Show answer

When permuting those values maps initial states to initial states, allowed steps to allowed steps, and leaves every checked property unchanged. A constant or property that singles one value out breaks it.

12-03-b from Symmetry and its traps

Why may a symmetry set that is sound for invariants make TLC miss a liveness violation?

Show answer

TLC searches the reduced graph, one state per orbit. A real loop that moves between states of one orbit can become a different loop, or none, in the reduced graph, so a fair loop that violates the property can disappear. TLC warns about it.

12-04-a from Simulation and honest claims

Simulation reports no violation after many thousands of states. What does that tell you?

Show answer

That none of the random behaviors it picked broke the invariant. It keeps no record of what it has seen, so it cannot say what fraction of the model it covered; read its coverage line.

12-04-b from Simulation and honest claims

What does the small-scope hypothesis claim, and what does it not?

Show answer

That many bugs show up in small instances, so small models are the right place to start. It is an empirical observation, not a proof: a bug that needs four of something cannot appear in a model with three.

12-05-a from Reachable versus inductive

What makes an invariant inductive, and how do you check that with TLC?

Show answer

It holds initially and every step from any state satisfying it leads to a state satisfying it. Define IndInit == TypeOK /\ Inv and check INIT IndInit, NEXT Next and INVARIANT Inv: a breadth-first search from every typed state that satisfies Inv. If Inv is inductive (and steps keep the types), every successor is one of those starting states, so the search ends after one step; if it is not, the violation is one step from the start.

12-05-b from Reachable versus inductive

An AI summary says "the induction check of Inv passes, so Inv describes exactly the reachable states." Is it accurate?

Show answer

No. An inductive invariant contains the reachable states and is closed under steps; it may contain unreachable states too. Peterson's Inv allows more states than Peterson reaches.

12-06-a from Choosing your evidence

For each of TLC breadth-first search, simulation, Apalache and TLAPS, name the bound it leaves.

Show answer

BFS: the constants, constraints and symmetry of one finite model. Simulation: coverage, which is unknown. Apalache: for a bounded run, behavior length and any constants it fixes; for a one-step induction check, only the constants it fixes. TLAPS: none in the claim, but only what the theorem states, about the spec as written.

12-06-b from Choosing your evidence

An AI summary says "Apalache found no violation with length 10, so MoneyConserved holds." Is it accurate?

Show answer

No. A bounded symbolic run covers behaviors of at most ten steps. It says nothing about longer behaviors; an induction check or a proof is needed for "holds".

13-01-a from 2PC and the coordinator crash

Why may a two-phase commit participant that voted yes not abort when the coordinator goes quiet?

Show answer

The coordinator may already have decided to commit and told another participant. Its yes vote was a promise to follow the decision, so it must wait.

13-01-b from 2PC and the coordinator crash

Under weak fairness on every step but the crash, TLC still finds a lasso where a participant never decides. Why can't fairness fix it?

Show answer

Weak fairness only forces steps that stay enabled, and in the blocked state no step that would help is enabled at all, so strong fairness would not help either. Liveness needs an assumption about recovery, stated as fairness on a Recover step.

13-02-a from Agree on one value

Two majorities of the same acceptors always share a member. Why is that not enough to keep two ballots from choosing different values?

Show answer

The shared acceptor's old vote must change what the new leader proposes. Without the rule that the leader adopts its quorum's newest vote, nobody listens to it.

13-02-b from Agree on one value

SingleDecree has no Crash action. How does the model cover acceptor crashes?

Show answer

A crashed acceptor is one that takes no more steps. The spec has no fairness, so a behavior in which an acceptor stops acting satisfies it, and its states are among those TLC checks. That covers crash-stop only; an acceptor that restarts with lost state is a different model.

13-03-a from Leader election, simplified

Why does a leader election over a real network allow two leaders at the same time?

Show answer

A leader of an old term keeps acting until a message from the newer term reaches it, and the network can delay that message. Without a bound on delay or clock drift, a protocol that can replace a leader it cannot reach can promise only "at most one leader per term".

13-03-b from Leader election, simplified

A leader of an old term still thinks it leads. How does a Raft-style system stay correct anyway?

Show answer

Everything is stamped with a term, and servers that have seen a newer term refuse anything older, so the old leader cannot get a majority to agree to anything.

13-04-a from Leases without wall clocks

A lease client starts its count Margin ticks short, and its clock can lose up to MaxDrift ticks per lease. What must hold for two clients never to act at once, and why?

Show answer

Margin >= MaxDrift. When the server's count reaches zero, a client that lost d ticks still has d - Margin left on its own count, so it has stopped exactly when Margin covers the worst drift.

13-04-b from Leases without wall clocks

Why does LeaseLock count time down to zero instead of keeping a variable now that grows on every tick?

Show answer

A growing now takes infinitely many values, so the reachable states never run out. A countdown keeps only the time a decision depends on, relative to the grant, and bounded.

13-05-a from Raft-lite log replication

In StaleVoteRaft every log matches every other log, yet a committed entry is lost. How can both be true?

Show answer

LogMatching is about the logs as they are now; the new leader overwrote the old entry everywhere, consistently. Only the history variable committed remembers the promise, which is why StateMachineSafety is stated over it.

13-05-b from Raft-lite log replication

TLC finds no violation in EagerCommitRaft with MaxTerm = 2, with full coverage and the witness reached. An AI summary says "EagerCommitRaft passes with full coverage, so the own-term condition is unnecessary." Accurate?

Show answer

No. The TLC result is accurate and the conclusion does not follow. With two terms EagerCommitRaft reaches the same states as RaftLite, so the condition never matters in that model; the bug it prevents needs more terms, as 13-05-ex3 shows.

14-01-a from What to log

The code logs an internal event, such as a buffer flush, that the spec has no action for. What should the TraceSpec do with that record?

Show answer

Match it with a step that changes none of the spec's variables and still advances l. A record with no matcher stops the replay there.

14-01-b from What to log

When should code write the log record for an operation, and what should the record carry?

Show answer

At the moment the effect becomes visible to others (for a put, when the client is told "ok"), carrying the parameters the spec's action needs and the outputs you want checked.

14-02-a from TraceSpec

Why is a TraceSpec's acceptance check an invariant that fails, TraceUnfinished == l < Len(Trace)?

Show answer

Acceptance asks whether some behavior reaches the end of the log, an existence question. TLC answers those through a counterexample: claim no behavior gets there, and a violation means one does.

14-02-b from TraceSpec

A replay finds no violation, and TLC's depth is k. Which record is the first divergence, and why?

Show answer

Record k. l starts at 0 and every step adds one, so the deepest states, at level k, have matched records 1 to k - 1, and nothing matches record k.

14-03-a from Validate a small key-value store, find the first divergence

A replay diverges at a read. Is that the record where the bug happened?

Show answer

Rarely. It is the first record the spec cannot explain. The defect and the damage come at or before it; read backwards to the last record that touched the same data.

14-04-a from What traces cannot see

A TraceSpec's MatchGet does not compare the value the code returned. What happens to a log in which the code read a lost value?

Show answer

It is accepted. A field the TraceSpec ignores is as good as unlogged; the replay can only catch what a matcher compares.

14-04-b from What traces cannot see

An AI summary says "Trace validation accepted the seed 1 log, so kv.py keeps every acknowledged put." Is the summary accurate?

Show answer

No. The seed 1 run lost an acknowledged put, invisibly, because the lost value equalled the durable one. An acceptance is a fact about one logged run, through what the matchers check.

14-05-a from What a contract contains

Name the three files of a contract in this course, and who owns the first two.

Show answer

The spec (what the system may do), the properties (what must always hold, over the spec's variables), and CONTRACT.md (scope, logging plan, acceptance, owners). The owner of the service owns the spec and the properties; implementers change implementation files only.

14-05-b from What a contract contains

Why is a property like [][\A c \in Clients : Renew(c) => Valid(c)]_vars useless when Renew already requires Valid(c)?

Show answer

It is true by Renew's own definition, so it constrains no step. State the requirement over the variables, the change a renewal makes, so that it applies whatever the actions say.

14-06-a from Three implementations, one contract

What is same-source failure, and what is the defence?

Show answer

An implementation and the check that accepts it, derived from the same understanding, so a misunderstanding passes both. The defence: the check comes from the owner (spec, properties, TraceSpec using the spec's own actions), and implementations never edit it.

14-06-b from Three implementations, one contract

An AI summary says "lease_c passed trace validation on seed 8, so it implements the contract." The TLC output shows seed 8 accepted. Is the summary accurate?

Show answer

No. One seed was accepted. lease_c grants a write after the writer's lease has run out, if a run ever asks for one, and seed 4 does: the replay rejects it. Acceptance covers the run that was logged.

15-01-a from How plausible specs fail

An AI's spec passes with every action firing and its witness reached. Name two configuration-side ways it can still be wrong.

Show answer

The model can be too small for the bug to fit (model-too-small), or the requirement may not be named in the cfg at all (property-not-configured); a CONSTRAINT or CHECK_DEADLOCK FALSE can also hide the failing behaviors.

15-01-b from How plausible specs fail

The assistant's retry queue passes with MaxAttempts = 1, and ./tla's coverage line says every action of Next fired. The assistant's summary adds: "so the requeue path was exercised." Is the summary accurate?

Show answer

No. The coverage line counts named actions of Next, not the branches inside them. Requeue is a branch inside Fail, which fired every time through DeadLetter; TLC's own coverage report in the raw log shows the Requeue lines never evaluated.

15-02-a from Hallucination clinic

In what order does the clinic check an AI-written spec, and why that order?

Show answer

SANY, the author's cfg, coverage and witnesses, mutation, and only then close reading. Each step is cheap and catches what the previous cannot, and reading last means you read with a question instead of the author's story.

15-02-b from Hallucination clinic

An AI item may be correct. What evidence shows it?

Show answer

Full coverage, witnesses that need the real work, and properties that kill the mutants which break the requirement, with every survivor explained.

15-03-a from Mutation as measurement

A property kills no mutant. Name three reasons it might not be worth keeping.

Show answer

It may restate TypeOK, it may mention no variable (an ASSUME, not an invariant), or it may be about a variable nothing writes. A property false of the real spec is a fourth kind: a different requirement.

15-03-b from Mutation as measurement

Why can no ordinary invariant kill a mutant that drops a disjunct of Next, and what can?

Show answer

Dropping an action only removes behaviors, and an invariant true of all reachable states is true of any subset (unless it uses ENABLED, which reads Next itself). A witness that needs the dropped action, coverage, or deadlock checking catches it.

15-04-a from False alarms

You replay a claimed trace on a spec. What do "runs out", "a property fails" and "deadlock" each mean?

Show answer

Runs out: this sequence of actions is possible; compare its states with the claim. A property fails: the behavior exists and breaks it. Deadlock: some step is not allowed from the state before it, so the claimed behavior does not exist, when each record fixes exactly one successor.

15-04-b from False alarms

Why replay a claimed trace on a model of the system as the claim describes it, as well as on the real spec?

Show answer

To check the script against the claim: there it must run to the end and finish in the claim's last state. A stuck replay means the spec refuses the claim only if the same script gets that far where the claimed behavior is allowed.

15-05-a from Specification gaming

Name the three places a check can be made to pass without fixing the system, with one example each.

Show answer

The property (weaken NoDoubleSpend), the model (a CONSTRAINT, constants too small, CHECK_DEADLOCK FALSE, a deleted INVARIANT line), and the environment (guards that make the network or clock too polite for the bug).

15-05-b from Specification gaming

Which gaming move do witness and coverage reruns miss, and what catches it?

Show answer

A weakened property: it leaves every behavior in the model, so every action fires and every witness is reached. The protected set catches it, by requiring a maintainer's review of any change to Props files, provided branch protection requires code-owner review.

16-01-a from The model is an oracle

An agent loop has weak fairness on Next and no budget. Why can TLC still find a run that never stops?

Show answer

Weak fairness only forces steps to keep happening. Calling the model and running a tool are steps, so a model that asks for a tool forever gives a fair run that never stops.

16-01-b from The model is an oracle

TLC passes EventuallyDone under SF_vars(ModelAnswers). An AI summary says "the agent is guaranteed to terminate". What is missing?

Show answer

The pass depends on an assumption about the model: that it cannot avoid answering forever. The summary must state that assumption and why it holds; a budget gives termination without assuming anything about what the model says.

16-02-a from AgentToolLoop

A teammate's agent passes its approval invariant with Budget = 1. Why might that pass mean nothing?

Show answer

With one model call, a session holds at most one risky request, so a design that approves once per session cannot differ from one that approves every request. The model is too small for the bug to exist.

16-02-b from AgentToolLoop

Why does AgentToolLoop record which call an approval was for, instead of a Boolean "approved"?

Show answer

A Boolean cannot tell a fresh approval from a stale one. Recording the call number lets the invariant demand that each risky run was approved for the request that asked for it.

16-03-a from At-most-once side effects

An agent keeps its idempotency key in memory and reuses it on every retry. What failure breaks at-most-once anyway?

Show answer

A crash and restart. The new process has the task but not the key, mints a new one, and the service sees a request it has never seen.

16-03-b from At-most-once side effects

TLC finds no violation of AtMostOnce in ToolEffects.cfg. An AI summary says "the agent charges exactly once". Is it accurate?

Show answer

No. The run shows at most one charge, in a model with one intent, two attempts and a service that deduplicates. It says nothing about exactly once, and the result depends on the service's deduplication, which is an assumption.

16-04-a from Untrusted output as adversary

Why does TaintRouting give each message an origin as well as a label, when the real harness only has labels?

Show answer

The requirement is about where content came from, which the harness cannot see. The origin is a ghost field: it lets the spec check that the labels the harness uses are sound for that requirement.

16-04-b from Untrusted output as adversary

TaintRouting passes NoUntrustedExec. A summary says "prompt injection cannot cause unapproved actions". What does the check not cover?

Show answer

It covers sound labels for the modelled steps only. It does not cover a trusted tool that returns web text, steps that copy content without keeping its label, or an approver who approves without reading.

16-05-a from A multi-agent task board

Why must the store, not the worker, check the fencing token?

Show answer

The worker's belief that it holds a lease can go stale between its check and its write. The store sees the token on the write at the moment it lands, so it can refuse a write from an expired lease.

16-05-b from A multi-agent task board

TaskBoard.symmetry.cfg finds no violation. A summary says "with symmetry, the result holds for any number of workers". What is wrong?

Show answer

Symmetry only merged states that differ by swapping the two workers' names, in a model with two workers and two tasks. It made one check cheaper; it says nothing about other sizes.