Friday, 23 November 2012

3.1.3 Finite State Machines

A Finite State Machine (FSM) is a machine which accepts an input and proccess an output.

There a 3 types of FSMs a Mealy Machine, a Moore Machine and a Finite State Automata.

A Finite State Automata (FSA) is a FSM which has a finishing state and only outputs a YES/NO answer based on which state the input string ends on.

A Mealy Machine is a FSM where the output is on the transistions opposed to the states.

A Moore Machine is a FSM where the output is on the states opposed to the transisitons.

A FSM/FSA can be represented in a variety of ways the most common is a State transition Diagram.

This is an example of a FSA as shown by a State Transition Diagram. The arrow with no number above it shows the Starting State. And the yellow circle around State 2 indicates that it's the state which will give an output of YES.
 A FSM can also be represented by a Transition Table.

Current State:    S1   S1   S2   S2   S3   S3
            Input:      0      1     0     1     0     1
   Next State:     S2    S3   S3   S3   S1   S1
         Output:      A      B    C     B    C     B

This table shows that in State 1 if you input 0 the FSM would be A and the next State would be Sate 2.


The third way to represent a FSM is as a Transition Function. These have the standard formula of (Input Symbol, Current State) -> (Output Symbol, Next State). For example (1, S3) -> (A, S2) would mean that if you are currently in State 3 and if you input 1 the FSM will output A and move to State 2.

Finally there are 2 types of FSM/FSA, Deterministic and Non-Deterministic. Deterministic means there is only 1 transition for each input while Non-Deterministic means there's more than one possible transition per input allowing for more than 1 route round a State Transition Diagram.

Oh and also a Halting State is a state with no outputs.