What a Traffic-Light Animation Must Never Do
Two traffic lights change colour on a screen. Green, amber, red; then the other side takes its turn. It looks convincing. A useful next question is slightly less comfortable: could both sides ever show green together?
Watching a successful cycle does not settle that question. It shows what happened on that run. My argument is that a worthwhile next step in a programming project is to identify one outcome that must never happen, then examine whether the design actually prevents it. A traffic-light model makes that distinction unusually visible. The forbidden outcome has a colour.
Imagine a hypothetical project with two approaches, A and B, sharing one narrow passage. Traffic can travel through it in either direction, but opposing streams must not enter together. For now, leave out pedestrians, turning vehicles and hardware failures. This is a teaching model, not equipment anyone should connect to a road.
One possible design gives each light its own repeating script: turn green, wait, turn amber, wait, turn red. The scripts could be timed to take turns. But the design explanation would still owe us an answer: what keeps those independent sequences coordinated? “They lined up when I pressed start” is an observation, not yet a reason they must remain safe.
A different design uses one phase selector: a stored value saying which part of the shared sequence is active. Both signals take their displayed colours from that value. The sequence could be: A green and B red; A amber and B red; both red for clearance; A red and B green; A red and B amber; both red for clearance; then repeat. Each phase has a defined successor. Neither light independently decides that it deserves a turn.
Now we can state a rule: A and B must never both be green. Computer scientists call a rule that must remain true while a program runs an invariant. Daniel Jackson’s MIT teaching notes use traffic signals to explain this reasoning: establish that the rule holds initially, then show that every permitted operation preserves it. These are course materials explaining a method, not research showing educational gains for children. [1]
In our hypothetical design, we would inspect every phase and every allowed transition. None of the listed phases contains two greens. If the program starts in a listed phase and can move only to another listed phase, the model excludes that combination. That explanation depends on the implementation respecting the design: an extra script that can independently set a signal green would need examination too. A diagram cannot supervise code it does not describe.
There is a more interesting fault hiding here. Suppose we remove the clearance phase and switch directly from A’s turn to B’s. The two snapshots might each satisfy “never both green”. Yet a vehicle admitted from A could still be inside the passage when B receives permission to enter. A safe-looking picture can be followed by another safe-looking picture through an unsafe change.
Real signal guidance addresses this timing problem. The UK Department for Transport describes an intergreen: the interval between one traffic movement losing green and the next conflicting movement receiving green. Its purposes include allowing traffic to clear. The guidance also calls for considering conflicting phase pairs rather than assuming only the usual sequence will occur. This is UK guidance, not a statement of Calgary’s requirements. [2]
Our model therefore needs a second requirement: enough clearance before the opposing green. For a hypothetical animation, we could assign vehicles a fixed speed and choose a clearance time consistent with that assumption. Then we should say the assumption aloud. If a vehicle can stop inside the passage, elapsed time alone no longer establishes that it has left. The real guidance requires on-site validation; our simplified model omits much of what a road-safety demonstration would need. [2]
There is also an extremely easy way to obey “never both green”: leave both lights red forever. Congratulations; the passage has become a car park. Jackson’s notes use an all-red deadlock to distinguish avoiding bad outcomes from allowing useful progress. Our design needs both questions: can conflicting traffic receive permission together, and will waiting traffic eventually get a turn? Satisfying the first does not answer the second. [1]
A parent might reasonably object that this is a heavy load to place on someone who has just made three circles change colour. I agree. A first working animation is a legitimate achievement. Asking a beginner to produce formal specifications and proofs could turn an inviting project into paperwork with sprites. The modest next challenge I would propose is one forbidden combination and a few arrows drawn between allowed phases. That is an educational judgement, not a measured finding: the sources here do not establish that this activity improves later programming performance.
There is a recent connection beyond beginner projects. In a November 5, 2026 account, Microsoft Research described PDD Kit, a research prototype combining specifications, checked proofs and tests for AI-written software. The authors explicitly acknowledge that a proof can establish agreement with a specification without establishing that the specification captures what people intended. Their demonstration concerns login logic in one application, with important components outside the proof. This is a vendor research account, not independent evidence of broad reliability. [4]
The traffic-light puzzle gives that limitation a concrete shape. We could carefully establish “never both green” and still forget clearance or leave everyone waiting forever. Before asking whether a program follows its rules, we need to ask whether we have written enough of the right rules. Beside the hypothetical animation, I would keep three questions on a scrap of paper: what is forbidden, what makes a change safe, and what ensures someone eventually gets through?