← all environments 09 · Advanced · UML statechart · v0.1.1

Live State Machine

UML statechart

A traffic-signal controller drawn as a genuine UML state machine — initial pseudostate, three states, four guarded transitions. Firing an event (or letting the timer run) moves a live token: the active state glows, the taken transition pulses, and an event-trace log records the run. The diagram is not a picture of the machine; it is the machine.

4 components · 4 connections · event-driven finite-state executor

the aha

The boxes-and-arrows diagram is not documentation of the machine — run an event through it and it is the machine.

why it works
A finite-state machine is a transition function δ:S×ΣS\delta : S \times \Sigma \rightarrow S: given the current state ss and an event ee, it names exactly one next state — but only if the transition’s guard is satisfied. That is the whole of it. A traffic light is S={Red,Green,Yellow}S = \{\text{Red}, \text{Green}, \text{Yellow}\} and the events are timer expiries. What schemd lets you see, that a textbook cannot, is that the drawing and the behaviour are the same object: the token sitting on Red is the machine’s state, and firing t>Tredt > T_{red} literally advances δ\delta along the arrow you drew. Composability, unreachable states, and deadlocks stop being abstractions — they are places the token can or cannot go.
governing model
δ:S×ΣS    (s,e)snext if guard(e)\delta : S \times \Sigma \rightarrow S \;\cdot\; (s, e) \mapsto s_{\text{next}} \text{ if guard}(e)
structural inventory
  • initial pseudostate
  • Red / Green / Yellow states
  • 4 guarded transitions
  • event queue + trace log
boundaries
  • deterministic δ\delta
  • one active state
  • guarded, timed transitions
fault relay transition guard inverted (deadlock)
  1. Fire the timer events in sequence.

    Red → Green → Yellow → Red. The active state glows and each taken transition pulses; the trace log is the exact run δ(δ(δ(s0,e1),e2),)\delta(\delta(\delta(s_0, e_1), e_2), \dots).
  2. Try to fire an event with no matching transition.

    Nothing happens — and that nothing is meaningful. A well-formed machine simply has no arrow for an impossible input; the token holds.
  3. Invert a guard.

    Flip one transition’s condition and the machine reaches a state it can never leave — a deadlock. You are watching a liveness bug happen, not reading about one.
causal signal trace paused

Enter the machine Power-on follows the initial transition into Red.

step 1 / 4 Enter the machine

Loading Live State Machine model…