Version 5 of Finite State Machine

Updated 2003-04-09 18:44:00

Page by Theo Verelst

The mathematical model for a Finite State Machine is a mapping where

 from (Din,Dstate) |--> to (Rout,Rstate)
 FSM(in,state) --> (out,new state)

schematically the machine applies the mapping like:

           |----|
  in    -->|    |--> out
           |    |
  state -->|    |--> next state
           |----|

Or machinewise

  clock ------    or 'trigger new state'
             |
             V
           |----|
  in    -->|    |--> out
           |    |
  state -->|    |--> next state
        |  |----| |
        |         |
        -<---------

The mappings from (in,state) to out and another to next_state are functions acting on domains which are respectively all possible inputs and all states (possibly minus the first or last), and which have ranges of all possible output values and all possible new state values.

From straigtforward reasoning one may take it that it holds that

 Domain(state) is subset of Range(newstate) minus newstate(initial)

Surely you rather meant to write

 Dstate is superset of Rstate union initial_states

or something to that effect? - Lars H

{Lets see, the domain of the variable state is a subset (or equal to) of the Range for newstate (because the last state need not be in the domain of the newstate function), except that the initial state need not be in the range for newstate. Maybe nicer put, the domain for the variable state and range for the function newstate are the same except not necessarily for the initial state and the final state}

and it makes most sense practically to take

 Domain(state) equals range Range(newstate) except for state(inital) and state(final)

The sequence of states which are traversed by starting from a given input and initial state is predictable and known when the model is no ill-defined. It can be a repeating sequence, or, by a changing input, infinite sequence without repetition, for instance by taking as states range and domain the decimal numbers 0 to 9 mapped to the some random output and a newstate equal to the previous input, and feeding the input with the decimals of PI.

See also eigenvalues and electronics and bwise applications and examples for an example on what logical functions can act as building block for remembering the state, this page has the same block and the bwise code:

 http://195.241.128.75//Diary/ldiary6.html#bwise

This page is an example of how many bytes of source code Finite State Machines can be used to encode the number of states which often would fit in a byte, and the transitions could probably be coded pretty shortly as well. Then again, an assembly program is usually much bigger than the resulting object code.

I think after rereading the math notation is not all clear though things are overseeable, the first def line above means that the machine is defined by a function mapping of two variables to two new variables with certain domains and ranges. Actually the functions have ranges, they don't need variables added to hold the values, as in normal math. In fact, the only variable which is not a function argument is the state variable, which needs to be given an initial value. Though it is mathematically possible to define the machine as deriving its first 'stored' state from the initial input, or to define the state only after a cycle of the machine.


Category Concept