Terminology

Control state

Control states are a piece of the internal state of a state machine that serves to determine the transitions to trigger in response to events. Transitions only occur between control states. Cf. base example illustration.

Extended state

A state machine may hold a piece of state that is updated when the machine processes an event, and that is accessible to any guards and may participate in the computation of the machine outputs. The state machine is then called an extended state machine, and the mentioned piece of state is called the extended state of that machine. That piece of internal state must be initialized upon creating the state machine. The extended state for a Kingly state machine takes the form of a regular JavaScript object. The shape of the extended state is largely application-specific.

Input

In the context of our library, we will use interchangeably input or events for the entities that are processed by the machine. An automaton receives inputs and generates outputs. However, as a key intended use case for this library is user interface implementation, inputs will often correspond to events generated by a user. We thus conflate both terms in the context of this documentation.

External event

External events are external and decoupled from the state machine at hand. Such events could be, in the context of a user interface, a user click on a button.

Internal event

Internal events are events coupled to a specific state machine. Depending on the semantics of a particular state machine, internal events may be generated to realize those semantics. In the context of our library, we only generate internal events to trigger automatic transitions.

Initial event

In the context of our library, the initial event (INIT_EVENT) is fired automatically upon starting a state machine. The initial event can be used to configure the initial machine transition that has as its target the initial control state. However, it is often simpler to directly configure an initial control state for the machine using Kingly’s API.

Automatic event

This is an internally triggered event that serves to trigger transitions from control states for which no triggering events are configured. Such transitions are called automatic transitions. Not firing an automatic event in such a control state would mean that the state machine would be forever stuck in that control state.

Transition

Transitions describe changes in the control state of a state machine in response to a triggering event. Transitions can be configured to be taken only when predefined conditions are fulfilled (guards). Transitions can be triggered by an event, or be automatic when no triggering event is specified.

Automatic transition

Transitions between control states can be automatically evaluated if there are no triggering events configured. The term is a bit confusing however, as it is possible in theory that no transition is actually executed if none of the configured guards is fulfilled. We forbid this case by contract, as failing to satisfy any such guard would mean that the machine never progresses to another state! In our CD player example, an automatic transition is defined for control state 3 (Closing CD drawer). According to the extended state of our machine, the transition can have as a target either the CD Drawer Closed or CD Loaded control states.

Self transition

Transitions can also have as origin and target the same control state. When that happens, the transition is called a self transition.

Transition evaluation

Given a machine in a given control state, and an external event occurring, the transitions configured for that event are evaluated. This evaluation results either in the identification of a valid transition, which is executed (taken) leading to a change in the current control state; or with no satisfying transition —- the machine then remains in the same control state, with the same extended state.

Guards

Guards associated with a transition are predicates that must be fulfilled for that transition to be executed. Guards play an important role in connecting the extended state of a machine to the control flow for the computation under specification. Guards should be pure functions and be computed at least from the triggering event and the extended state of the machine.

Action factory

This is a notion linked to the Kingly implementation of state machines. An action factory is a function which produces information about two actions to be performed upon executing a transition: the update of the encapsulated extended state of the machine, and the computation of the machine output.

Output

The state machine produces outputs from the inputs it processes. We will sometimes use the terms actions or commands instead of the generic term outputs. In the context of user interface specification, the outputs generated by a Kingly state machine will be commands to execute on the interfaced systems. The term action is quite overloaded and polysemic terms though, so we will try as much as possible to use the term outputs when necessary to avoid confusion.

Composite state

As previously presented, an hierarchical state machine may feature control states which may themselves be hierarchical state machines. When that occurs, such control states will be called composite states. In our CD player example, the control state CD loaded is a composite state.

Compound state

Exact synonym of composite state.

Nested state

A control state which is part of a composite state.

Atomic state

An atomic state is a control state which is not itself a state machine. In other words, it is a control state like in any standard state machine. In our base example, all states are atomic states. In our CD player example, the control state 5 is an atomic state. The CD loaded control state is not.

Transient state

Transient states are control states which are ephemeral. They are meant to be immediately transitioned from. Transient states thus feature no external triggering event (but necessitates of an internal automatic event) and may have associated guards. By contract, one of these guards, if it exists, must be fulfilled to prevent the machine from eternally remaining in the same control state. In our CD player example, the control state 3 is a transient state. Upon entering that state, the machine will immediately transition to either control state 1, or composite state CD loaded.

Terminal state

The terminal state is a control state from which the machine is not meant to transition from. This corresponds to a designed or anticipated end of a run of the state machine.

History state

Semantics for the history state may vary according to the intended application of hierarchical automata. In our restrictive context, the history state allows transitioning back to the previous control state that was previously transitioned away from. This makes sense mostly in the context of composite states, which are themselves state machines and hence can be in one of several control states. In our CD player example, there are a few examples of history states in the CD loaded composite state. For instance, if while being paused (atomic control state 6), the user requests the previous CD track, then the machine will transition to… the same control state 6. The same is true if prior to the user request the machine was in control state 4, 5, or 7. History state avoids having to write individual transitions to each of those states from their parent composite state.

Entry point

Entry points are the target of transitions that are taken when entering a given composite state. This naturally only applies to transitions with origin a control state not included in the composite state and destination a control state part of the composite state. A history state can also be used as an entry point. In our CD player example, control state 1 is an entry point for the composite state No CD loaded. The same stands for H (history state) in CD Loaded composite state. Similarly, a transition from No CD loaded to CD loaded will result in the machine ending in control state 4 (CD stopped) by virtue of a chain of entry points leading to that control state.