Docstoc

Chapter7 Finite State Machines

Document Sample
Chapter7 Finite State Machines Powered By Docstoc
					                   Finite State Machines

 Information processing machine
   It is a device that receives a set of input signals and produces a
   corresponding set of output signals.

 machines with memory and without memory.
   machine without memory: its output at any instance depends
     only on the input at that instant.
   machine with memory (it can remember what has happened
     in the past): its output at any instant depends on the input at
     that instant as well as on inputs at previous instant.
   state: A state represents a summary of the past history of the
    machine.
   finite state machine: A machine with a finite number of
    states.
   infinite state machine: A machine with an infinite number of
    states.

 A finite state machine is specified by
  1. A finite set of states S = { s0 , s1 , s2 , …}.
  2. A special element of the set S, s0 , referred to as the initial
     state.
  3. A finite set of input letters I = { i0 , i1 , i2 , …}.
  4. A finite set of output letters O = { o0 , o1 , o2 , …}.
  5. fs: A function f from ST to S, referred to as the transition
     function.
  6. fo: A function g from S to O, referred to as the output
     function.
 machine equivalent
   Two finite state machine are said to be equivalent if, starting
   from their respective initial states, they will produce the same
   output sequence when they are given the same input sequence.

 equivalent state
   In a finite state machine, two states s1 and s2 are said to be
   equivalent if for any input sequence the machine will produce
   the same output sequence whether it starts in s1 or s2.
                        state minimization

 How to determine whether two states are equivalent?
     0-equivalent :Two states are said to be 0-equivalent if they
      have the same output.
     1-equivalent :Two states are said to be 1-equivalent if they
      have the same output and if, for every input letter, their
      successors are 0-equivalent.
     k-equivalent :Two states are said to be k-equivalent if they
      have the same output and if, for every input letter, their
      successors are (k-1)-equivalent.
     Two states are equivalent if they are k-equivalent for all k.
     k-equivalent is a equivalent relation, and forms a partition
      of the set of states.
 M simulates M
    h: s  s            I*, s S
                         g() = g(h(s), ).
 Theorem 7.1 Two states are in the same block in Πk if and
  only if they are in the same block in k-1 and, for any input letter,
  their successors are in the same block in k-1.
  Proof:
    Let si and sj denote two states that are k-equivalent.
      According to the definition, they have the same output and,
      for any input letter, their successors are (k-1)-equivalent.
      Note that according to the definition, si and sj are also (k-1)-
      equivalent.
    Thus, we conclude that two states are k-equivalent if and
      only if they are (k-1)-equivalent and, for any input letter,
      their successors are also (k-1)-equivalent. Thus, the
      theorem follows immediately.                        Q.E.D.

 Two observations
     1. If k is equal to k-1, then m is equal to k-1 for all m  k.
     2. k is a refinement of k-1.
             Finite State Machines as Language
                          Recognizers

 O = {0,1}
     accepting state:A state is said to be an accepting state if
      its output is 1.
     rejecting state:A state is said to be an rejecting state if its
      output is 0.
     An input sequence is said to be accepted by the finite state
      machine if it leads the machine from the initial state to an
      accepting state. On the other hand, an input sequence is
      said to be rejected by the finite state machine if it leads the
      machine from the initial state to an rejecting state.

 finite state language
    A language is said to be a finite state language if there is a
    finite state machine that accepts exactly all sentences in the
    language.

 Theorem 7.2 Let L be a finite state language accepted by a
  finite state machine with N states. For any sequence α whose
  length is N or larger in the language, α can be written as uvw
  such that v is nonempty and uviw is also in the language for i≧
  0, where vi denotes the concatenation of i copies of the
  sequence v. (In other words, uw, uvw, uvvw, uvvvw, … are all in
  the language.)
Proof:
 Letα= a1a2a3…aN, without loss of generality.
 Let sj0, sj1, sj2, …, sjN denote the states the machine visits,
 where sj0 is the initial state and sjN is an accepting state.
 Among the N+1 states sj0, sj1, sj2, …, sjN there are two of them
 that are the same. Suppose that is state sk, we realize that the
 sequences uw, uvw, uvvw, uvvvw, …, uvIw, … will all lead the
 machine from the initial state sj0 to the accepting state sjN.




                                                         Q.E.D.
                                
               Finite State Language and Type-3
                           Languages
 A nondeterministic finite state machine is specified by
    1. A finite set of states S = {s0, s1, s2 , …}.
    2. A special element of the set S, s0 , referred to as the initial
       state.
    3. A finite set of input letters I = {i1, i2, …}.
    4. A finite set of output letters O = {o1, o2, …}.
    5. A function F from S×T to (S), referred to as the transition
       function.
    6. A function g from S to O, referred to as to output function.

It is a very useful abstract model as a language recognizer.

 Whether a nondeterministic finite state machine is more
   powerful than a deterministic finite state machine?
                                   NO!
 For any given nondeterministic finite state machine,
  there is a deterministic finite state machine that accepts
  exactly the same language.
      Let M be a nondeterministic finite state machine with
          1. {s0, s1, s2, …} being the set of states
          2. s0 be the initial state
          3. {i1, i2, …} being the set of input letters
          4. {0,1} being the set of output letters
          5. F from S×I to (S) being the transition function
          6. g from S to {0,1} being the output function.
  Construct a corresponding deterministic finite state
   machine M as follows. Let
     1. P(S) be the set of states
     2. s0 be the initial state
     3. {i1, i2, …} being the set of input letters
     4. {0,1} being the set of output letters
     5. F : P(S)×I (S)
            F ({ },iq) = {} for any input letter iq,
            F’(Sp, iq) =  F(sr, iq) for any Sp
                            s r s p
     6. g: P(S)  {0,1} output function, for any Sp  S
             g(Sp) = 1 if there exists sr in Sp  g(sr) = 1
                    = 0 otherwise.
 An example
                            M
       State         0             1     output
         A           B            B,C      0
         B          A,C            _       0
         C           A            B,C      1
                            M
       State         0             1     output
        {A}         {B}          {B,C}     0
        {B}        {A,C}           {}      0
        {C}         {A}          {B,C}     1
       {A,B}      {A,B,C}        {B,C}     0
       {A,C}       {A,B}         {B,C}     1
       {B,C}       {A,C}         {B,C}     1
      {A,B,C}     {A,B,C}        {B,C}     1
         {}          {}            {}      0
  Machine M and M accept exactly the same language, since
  an input sequence accepted by M will bring M to a state,
  which is a subset of M, in which there is at least one that is
  an accepting state in M.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:10
posted:5/28/2010
language:English
pages:7