next up previous
Next: State Machines: Definitions of Up: No Title Previous: Some Metacomments

A Simple Example

Let's start with a simple example of a car and model it as a state machine:


This Car has a very short lifetime. It starts out in the initial state where it is off. When you perform the action of turning the key to start the car, it moves into the idle state. After you apply some gas, it moves into the accelerating state. If you apply the brake, it dies, ending up in the crashed state.

You can think of my Car as a black box whose interface to the outside world is a set of observable states (ovals above) and a set of actions (arrows above). Sometimes I'll want to focus on just the actions and thus depict the Car's interface as follows:


Imagine stuffing the Car's state transition diagram inside the box. In Section 7.1 I will discuss interfaces more.

Suppose in this Car example, I turn the key and I am unlucky: the car won't start. To model the possibility that the car goes from the off state to more than one possible next state (off and idle), I need to model nondeterministic behavior. Nondeterminism comes up naturally in the real world when you cannot predict what the next state of a machine will be given some event or action. Perhaps it's due to an internal choice made by the machine. For example, choosing an element from a set is a nondeterministic action; you know you're going to get some element of the set back, but you don't know which one.

Norman Papernick
Mon Mar 18 13:45:16 EST 1996