Section 8.2: Finite-State Machines

Abstract:

We model a machine as a set of states, inputs which lead to a change in state, a clock to synchronize the machine world, and outputs, which result from a particular state. We use tables and graphs to describe how the inputs relate to changes in state and the outputs of each state, then practice creating simple finite-state machines.

Finite-state machines can be used to recognize input, and we will look at the kinds of input that can be recognized, as well as construct the machines that recognize given input. Furthermore, some machines are overly complicated, in that we can simplify them and get the same operation. We will examine some ways in which we can ``minimize'' a finite-state machine.

Finite-State Machines

Definition: A finite-state machine M is a structure tex2html_wrap_inline389 where

   table105
Table: Elements of a finite-state machine.

The machine is initialized to start in state tex2html_wrap_inline405 , and the machine operates deterministically (meaning there is no randomness associated with its operation given a sequence of inputs).

We assume discrete times, synchronized by a clock, so that

displaymath383

and that

displaymath384

We represent tex2html_wrap_inline407 and tex2html_wrap_inline409 by

A summary of these elements for Example 16, p. 545/619:

   table128
Table: Elements of finite-state machine of Example 16, p. 545/619.

Example: Practice 34, p. 546/620 . (First, create the state table from the state graph: what are tex2html_wrap_inline389 in this example?)

Example: Practice 36, p. 546/620

Example: Exercise 4, p. 563/637

Construction of a machine: the Binary Adder

In section 7.2 we saw how one might create a logic network in hardware for the addition of binary numbers. We now consider how this can be incorporated into a finite-state machine which is analogous (p. 547/621).

We must specify the five elements of a finite-state machine: tex2html_wrap_inline389 . What is the set of states, what the set of inputs, what the set of outputs, and how are the functions tex2html_wrap_inline407 and tex2html_wrap_inline409 defined?

Example: Practice 37, p. 547/621

Example: Practice 38, p. 548/622

Now let's try something a little different:

Example: Exercise 15(a), p. 565/638 This is a modification, in some sense, of the binary adder. First of all, recognize that only one bit is being stored: the author intends in this problem that the first bit in the output sequence is the output of state tex2html_wrap_inline405 , in which the machine started. We need to ``carry'' the bit which we will write next time, and write the current bit. We'll solve this in two ways: in a sloppy way first, and then in a better way - illustrating the need to be able to minimize a finite-state machine.

Recognition

Definition: Finite-State Machine Recognition A finite-state machine M with input alphabet I recognizes a subset S of tex2html_wrap_inline449 (the set of finite-length strings over the input alphabet I) if M, beginning in state tex2html_wrap_inline405 and processing an input string tex2html_wrap_inline457 , ends in a final state (a state with output 1) if and only if tex2html_wrap_inline459 .

Example: Practice 40, p. 550/624

Notes:

What kinds of input can a finite-state machine recognize? Regular expressions. Regular expressions over I are defined recursively by

  1. the symbol tex2html_wrap_inline471 and the symbol tex2html_wrap_inline473 ;
  2. the symbol i for any tex2html_wrap_inline477 ; and
  3. the expressions (AB), tex2html_wrap_inline481 , and tex2html_wrap_inline483 if A and B are regular expressions.

Kleene's Theorem assures us that a finite-state machine can recognize a set S of input strings if and only if the set S is a regular set (that is, a set represented by a regular expression).

Since some very reasonable sets are not regular (e.g. tex2html_wrap_inline493 , where tex2html_wrap_inline495 stands for n copies of a), finite-state machines are obviously not sufficient to understand all of computation.

Examples of regular sets given by regular expressions:

Example: Exercise 19/23(e), p. 566/639 - recognition and minimization motivation

Machine Minimization

Unreachable States

One obvious way in which a machine can be minimized is if there is an unreachable state: if so, then that state can certainly be trimmed from the machine without any consequences (from the standpoint of output). For example: Table 8.3, p. 552/626; and Figure 8.7, p. 553/627.

Example: Practice 43, p. 553/627

Equivalent States

It would be nice if we had some general way of minimizing a machine, however. It turns out that we can find a minimized machine by using the idea of equivalent states. The idea is that several redundant states might operate in such confusing fashion that it appears there's lots going on, when there's not!

In the first step, the unreachable states are removed. That's the easy part! Then we define

Equivalent States: two states tex2html_wrap_inline511 and tex2html_wrap_inline513 of M are equivalent if, for any tex2html_wrap_inline517 , tex2html_wrap_inline519 where by the awful notation tex2html_wrap_inline521 we mean the sequence of output which occurs given that we start in state s and receive input tex2html_wrap_inline457 .

(There is no way that our author should have used notation which seems to imply that tex2html_wrap_inline409 is somehow both a function from tex2html_wrap_inline529 and a function from tex2html_wrap_inline531 , except that she's proving herself a computer scientist and an object-oriented one at that, and overloading the function tex2html_wrap_inline409 ...).

In order to find equivalent states, we define the notion of k-equivalency: two states are k-equivalent if the machine matches output on an input of k symbols to the two states.

  1. States having the same output symbol are 0-equivalent.
  2. For 1-equivalency, we check two 0-equivalent states to see that the next-states under all input symbols (of length 1) are 0-equivalent.
  3. For 2-equivalency, we check 1-equivalent states to see that the next-states under all input symbols (of length 1) are 1-equivalent - and hence equivalent for strings of length 2, total.
  4. Etc.!
We iteratively step through equivalencies (from 0 on up): as soon as the states do not change, from k-equivalency to (k+1)-equivalency, then we have minimized our machine.

Best to look at an example!

Example: Exercise 41/53, p. 570/644

The set of states is divided up into subsets of the initial set which have for their union the entire set S, and no common intersections. This is called a partition of the set S. As we progress from 0-equivalency on up, each subset can be divided, but none ever coalesce. There can be partition refinement (finer partition) only.



Wed Nov 28 15:21:34 EST 2007