Finite State Machines

A finite state machine is defined by

As an example, let us describe the sequence of events which takes place when you answer the telephone. For this example, we will assume that you do not have an answering machine or services such as call waiting.

  1. We begin the process by waiting for the telephone to ring; during this time, we are in a wait state, which we will designate W.
  2. When the phone rings, you pick up the handset and change to the answer state (designated A).
  3. At this point, one of four things may happen:

  4. If the call is for you, you say hello and change to the talking state (designated T).
  5. If the call is for someone who is currently at home, you tell the person making the call to wait and move to a state where you are getting the person they desire (designated G).
  6. If the call is for someone who is currently not at home, you tell the caller and change to the state where you are taking a message (designated M).
  7. If it is a wrong number, you tell the caller and move to the state where the call is finishing (designated F).
  8. Once in the talking state, whenever the caller talks you reply and stay in the talking state.
  9. If however, the caller says goodbye, you say goodbye and move to the finish state.
  10. If you were in the state where you were getting someone else to come to the phone, when they arrive they say hello and enter the talking state.
  11. If you are taking a message and the caller says goodbye, you say goodbye and move to the finish state.
  12. Once in the finish state, when the caller hangs up, you hang up the handset and change to the wait state.

We represent this sequence as a finite state machine as follows:

We can represent this finite state machine as a labeled directed graph where

When a finite state machine is represented as a directed graph, the matrix representation is called a state table. Here, rows are labeled by states, the columns are labeled by inputs, and the matrix elements consist of the outputs and the next state to move to:

.ringfor youat home not at home wrong numbercomes to phonecaller talks goodbyehangup
wait (W)pick up, A........
answer (A).hello, Twait, Gtell them, Mtell them, F ....
talk (T)......reply, T goodbye, F.
get person (G).....hello, T ...
take msg (M).......goodbye, F .
finished (F)........ hang up, W

The finite state machine is a formal way to describe an algorithm; in this example, we have given an algorithm for answering the telephone. When the algorithm is applied to an actual series of inputs, we can construct a table which illustrates the sequence of states entered by the machine as it processes the algorithm. For instance, in the case of a wrong number, the sequence of inputs and states is

inputoutputnext state
ringpick up phoneA
wrong numbertell themF
hanguphang up phoneW
while in the case where the caller talks to someone other than the person who answers the sequence is
inputoutputnext state
ringpick up phoneA
at homeask them to waitG
comes to phonesay helloT
talksreplyT
talksreplyT
talksreplyT
says goodbyesay goodbyeF
hangs uphang up phoneW
These tables are often summarized in the form of a sequence of states, ie.:
A, F, W
and
A, G, T, T, T, T, F, W
respectively. They can also be summarized as a sequence of outputs:
pick up phone, tell them (it's a wrong number), hang up phone
and
pick up phone, ask them to wait, say hello, reply, reply, reply, say goodbye, hang up phone
respectively

When you learn about networking, you will find that the finite state machine is the common language for describing networking protocols, especially in TCP/IP, where our example in this section is very similar to the finite state machine which describes the establishment of a TCP connection.

The section concludes our discussion of graph theory. In the next chapter, we begin the quantitative measurement of computer capacities and performance with a discussion of units of measurement.


Go to:Title PageTable of ContentsIndex

©2002, Kenneth R. Koehler. All Rights Reserved. This document may be freely reproduced provided that this copyright notice is included.

Please send comments or suggestions to the author.