Info 2950 FSM Part1
Info 2950 FSM Part1
Module Modeling Computation: Finite State Machines with Output Rosen, Chapter 12.2
1
Remember the general picture of a computer as being a transition function T:SI SO?
If the state set S is finite (not infinite), we call this system a finite state machine.
If the domain SI is reasonably small, then we can specify T explicitly by writing out its complete graph.
However, this is practical only for machines that have a very small information capacity.
Size of FSMs
The information capacity of an FSM is C = I[S] = log |S|.
Thus, if we represent a machine having an information capacity of C bits as an FSM, then its state transition graph will have |S| = 2C nodes.
E.g. suppose your desktop computer has a 512MB memory, and 60GB hard drive.
Its information capacity, including the hard drive and memory (and ignoring the CPUs internal state), is then roughly ~512223 + 60233 = 519,691,042,816 b. How many states would be needed to write out the machines entire transition function graph? 2519,691,042,816 = A number having >1.7 trillion decimal digits!
FSMs as Models
The FSM diagram of a reasonably-sized computer is more than astronomically huge.
Yet, we are able to design and build these computers using only a modest amount of industrial resources.
Why is this possible?
Answer: A real computer has regularities in its transition function that are not captured if we just write out its FSM transition function explicitly.
I.e., a transition function can have a small, simple, regular description, even if its domain is enormous.
How close in physical space is one bits worth of the machines information capacity to another?
How long does it take to communicate information from one part of the machine to another?
How much energy gets dissipated to heat when the machine updates its state?
How fast can the heat be removed, and how much does this impact the machines performance?
We can construct a state diagram and/or a state table by considering every possible input on every possible state.
SB S0 S1 S2 S3 S4 S0
5 n n n n n 5
SB n n n n n
Soda
FSM Definition
FSM Representations
As we have already seen, there are two common ways of representing finite-state machines
A state table is used to represent a finite-state machine by giving the values of the functions f and g. A state diagram is a directed graph representation of a finite-state machine.
State Tables
A state table is organized as follows
The rows are indexed by the states. The columns are split into two groups:
The first half are indexed by the inputs The entries in the table give the value of the function f that is the new states The second half are also indexed by the inputs The entries in the table give the value of the function g that is, the outputs.
Output Input 25 n 5 10 15 20 25 CB n n n n
Candy Candy,5
SB n n n n n
Soda
State Diagram
A state diagram is organized as follows The nodes in the graph represent the states. The edges in the graph represent the transitions. An edge (Si,Sj) occurs if some input causes a transition from Si to Sj Each edge is labeled with a pair (x,y), where x is the input which (along with
the state) causes the transition
Output Input 0 0 1 0 1 0 1 0
The problem is we need a carry bit. In fact, our computation needs to know the carry bit at each step (so we compute xi+yi+ci at each step), and be able to give it to the next step. We can take care of this by using states to represent the carry bit.
Since when we begin the computation, there is no carry, we can use S0 as the start state, So, how does which state we are in affect the output? If we are in state S0 (we have a carry of 0)
If (xi+yi)=0, we output 0, and stay in state S0 If (xi+yi)=1, we output 1, and stay in state S0 If (xi+yi)=2, we output 0, and go to state S1
Next State
Output
Construct a state table for the finite-state machine in Fig. 3. Input, output
Find the output string for the input 101011 Answer: 001000 Output of 101011? 001000
Language Recognizer
We want to construct an FSM that outputs 1 iff the string read so far has 111.
S0 this state remembers that the previous input value (if it exists) was not a 1 S1 this state remembers that the previous input value was a 1, but the input before (if it exists) was not a 1 S2 this state remembers that the previous two input values were 1
26
Language Recognizer
0,0
S0 S1
1,0
S2
1,1
0,0
1,0 0,0
S0 this state remembers that the previous input value (if it exists) was not a 1 S1 this state remembers that the previous input value was a 1, but the input before (if it exists) was not a 1 S2 this state remembers that the previous two input values were 1
This finite-state machine recognizes the set of bit strings that end in 111.
27
Definition: Let M=(S, I, O, f, g, S0) be a FSM and L I*. We say that M recognizes (or accepts) L, iff for any input string x that belongs to L, M produces a 1 as an output
Finite Automata
29