Automata



Finite automata and Regular Expressions
(Original Format is available in download tab)

PRELIMINARIES:
STRINGS, ALPHABETS AND LANGUAGES:
SYMBOL:
            Letters and digits are symbols.

STRING:
            String is a finite sequence of symbols.
            Example: a, b and c are symbols and abcb is a string.

LENGTH OF A STRING (w):
            It is denoted by |w|, is the number of symbols comparing the string.
            Example: abcb has length 4.

EMPTY STRING:
            Empty string is denoted by ε, is the string consisting of zero symbols. Therefore |ε|=0.

PREFIX:
            Prefix of a string is any number of leading symbols of that string.
            Example: For abc, ε, a, ab and abc are prefixes

SUFFIX:
            Suffix is any number of trailing symbols.
            Example: abc, has suffixes ε, c, bc and abc.

            A prefix or suffix of a string, other than the string itself, is called a proper prefix or suffix.

CONCATENATION:
            If x and y are strings, then xy is the string obtained by placing a copy of y immediately after a copy of x.

            X = a1a2…..ai                                y = b1b2……bj
             Xy = a1a2…..ai b1b2……bj

LANGUAGES:
            If Σ is an alphabet, and L is a subset of Σ* then L is a language.
            Example: 1. Set of legal English words.
                              2. Set of legal C program.
                           3. If Σ = {a,b} then Σ* = {ε, a, b, aa, ab, ba, bb,…}
                                    Then {ab, abab, aabb} is a language over Σ.
                                    Therefore its length is finite, it is a finite language.
                           4. L = {anbn : n≥0} is an infinite language, because it contains
                                an infinite string.
From the definition of languages, it is clear that it is a set. Operations like union, intersection and differences are true for this also.   

MATHEMATICAL INDUCTION:
ALPHABET:
            It is a finite set of symbols.

LANGUAGE:
            It is a set of strings of symbols from some one alphabet.

            Empty set φ and the set consisting of the empty string {ε} are languages.
1.                              The set of palindromes over the alphabet {0,1} is an infinite language.
Members are: ε, 0, 1, 00, 11, 010, 1101011, etc.
2.                              Set of all strings over a fined alphabet Σ which is denoted by Σ*.
If Σ = {a}

   Σ* = {ε, a, aa, aaa,…}

If Σ = {0,1}
   Σ* = {ε, 0, 1, 00, 11, 01, 10, 11, 000,…}


INDUCTIVE PROOFS:
            Consider we have a statement P(n) about a non-negative integer n.
                       
                                 
           
            The principle of mathematical induction is that P(G) follows from
·                                                         P(0) → basis
·                                                         P(n-1) => P(n) for n≥1 → Inductive step.

P(n-1) is called inductive hypothesis.

            Proof:
1)                                                      Substitute 0 for n in equation 1, we will get 0 on both sides.
2)                                                      Substitute n-1 for n in equation 1 and we have to prove equation 1. we must show for n≥1 that
         


SET NOTATION:
SET:
            It is a collection of objects. Finite set may be specified by listing their members between brackets.

            Example:
                 {0,1} denotes alphabet of symbols 0 and 1.
            Representation:
1.                                             {x / P(x)}             set of objects x such that P(x) is true.
2.                                             {x in A / P(x)}     set of x in set A such that P(x) is true.

Example:
    {i / i is an integer and their exists integer j such that i = 2j} is a way of specifying even integers.

A  B, since A is a member of B
A  B, since A is a member of B and A≠B, that is some member of B not in A.

OPERATIONS ON SETS:
1.                  A  B, Union: {x / x is in A or x is in B}
2.                  A ∩ B, Intersection: {x / x is in A and x is in B}
3.                  A – B, Difference: {x / x is in A and x is not in B}
4.                  A * B, Cartesian Product: Set of ordered pairs (a,b) such that a is in A and b is in B.
5.                  2A, Powerset of A, is the set of all subsets of A.
Example:
            A = {1,2}               B = {2,3}
            A U B = {1,2,3}     A ∩ B = {2}    A – B = {1}
            A * B = {(1,2),(1,3),(2,2),(2,3)}
            2A = {φ, {1},{2},{1,2}}

FINITE AUTOMATA AND REGULAR EXPRESSIONS:
FINITE STATE SYSTEMS:
AUTOMATON:
            Automata is the plural of the word ‘Automaton’ which simply means any machine.

DEFINITION:
            It is a black-bon into which some input is fed, and as a result some output comes out. The relationship between the input and the output depends on the particular machine in hand.
            The machine seems to comprise:
·                                                         Set of inputs
·                                                         Set of outputs
·                                                         Rules to produce output for the given input.

FINITE AUTOMATON:
            It is a mathematical model of a system with discrete inputs, discrete outputs and a finite number of memory configurations called states.
            It is used as a model for
·                                                         Software for designing digital circuits
·                                                         Lexical analyzer of a compiler
·                                                         Searching for keywords in a file or on the web

FINITE STATE SYSTEMS:
            The finite automation is a mathematical model of a system, with discrete inputs and outputs.
Commonly used programs such as text editors and the lexical analysers found in most compilers are often designed as finite state system.

DEFINITION:
            A finite automation (FA) consists of a finite set of states and a set of transitions from state to state that occur on input symbols chosen from an alphabet Σ.
            Initial state is denoted by q0. Transition diagram (directed graph) is associated with FA.
            Vertices represent states of FA.
 

Example:
                                 
 
                                    Fig: Transition diagram of a finite automation

·                                   Final state is indicated by double circle
·                                   Each 0 input causes control to cross the horizontal line a – b iff the input seen so far contains an even number of 0’s similarly 1-input causes control to cross the vertical line
     c – d.
·                                   Control is at q0, iff there are both an even number of 0’s and even number of 1’s in the output.
           

Example: 1. switching circuit on/off switch

                      Push
                                        Push

Example: 2. Computer itself
                                        State: is a CPU at any time is one of a very large but finite number of states.

DEFINITION:
            For each input symbol, if there is exactly one transition from each state, then the finite automata is said to be DFA. Otherwise it is called NFA.

REPRESENTATION:
                                       

FINITE CONTROL:
              It is a black-bon of FA, contains all the transition states either deterministic or non-deterministic.
              DFA has an input tape of cells, a reading head and finite control.

                            Input tape
0
1
1
0
0
0
1
1
0
0
1
1
1
0
0
       Read Head
                                                        cells

                       
            In one move, the FSA in state q and scanning the symbol ‘a’ enters δ(q,a) and moves its head one symbol to the right. If δ(q,a) is an accepting state, then FSA is said to have accepted the string on its input tape.

REPRESENTATION:
            FA is denoted by a 5-tuple (Q, Σ, δ, q0, F)
   Q = Finite set of states
   Σ = Finite input alphabet
   q0 in Q = Initial state
   F is a subset of Q = Set of final states
   δ = Transition function mapping Q* Σ → Q
            That is δ(q,a) is a state for each state q and input symbol.

   Example:
       Consider the above transition diagram. Here FA is denoted by M = (Q, Σ, δ, q0, F) where
Q = {q0,q1,q2,q­3}
 Σ = {0,1}
 F = {q0}
δ is shown below.
            
               
                                   
    
    


                                              Fig 2: δ(q,a) for the FA.

DETERMINISTIC FINITE AUTOMATA (DFA):
               For a given input string w and state q, there will be exactly one path labeled w starting at q.

NON-DETERMINISTIC FINITE AUTOMATA (NFA):
                   If the finite automata model allows zero, one or more transitions from a state on the same input symbol, then that model is called NFA.
                   A transition diagram for a NFA is shown in the following figure.

TRANSITION DIAGRAM:
                   A transition diagram associated with DFA is a directed graph whose vertices are the states of DFA.
* The edges of the graph are the transitions from one state to another state.
* Initial q0 by start.
* Final state by double circle.

Example:
                   M = (Q = {q0,q1,q2}, Σ = {a,b}, q0, δ, F = {q2}); where δ is defined as
                   δ(q0,a) = q1
                   δ(q1,a) = q2
                   δ(q2,b) = q1


REGULAR LANGUAGES:
·                                  A string n is accepted by FSA, M if δ(q0,x) = p for some P F.
·                                  The language accepted by M denoted by L(M) is the set
     {x : δ(q0,x)  F}.
·                                  L(M) is said to be regular if it is accepted by FSA.

TRANSITION TABLE:
                   The table which represents the list of transition rules (functions) of a FA is called transition table.

          Example: Find the language accepted by the DFA given in figure

                                                           
                                                            

                     δ(q0,11)= δ(δ(q0,1),1) = δ(q1,1) = q0.
                           Hence 11 € L(M). Similarly we find,
                           δ(q0,1010) = q0
                           δ(q0,110101) = q0
         Fig 3: The transition diagram for NFA

·                                                   In this example, there are two edges labeled 0 out of state q0 , one going back to state q0 and one going to state q3.
·                                                   An input sequence a1, a2 ,…an is accepted by a NFA if there exists a sequence of transitions, comparing to the input sequence, that leads from the initial state to some final state.
·                                                   For example, 01001 is accepted by above NFA, because there is a sequence of transitions through the states q0,q0,q3,q4,q4 labelled 0,1,0,0,1.
·                                                   Formally NFA is denoted by 5-tuple (Q, Σ, δ, q0, F) as in DFA, but δ is a map from Q* Σ to 2Q.
·                                                   The function δ for the NFA of above figure is given below:


 


                              
                                    
                                                                        
                              

                 Fig 4 : The mapping δ for the NFA of Fig 3
             Thus, 1010  L(M). So L(M) is the set of all strings with an even number of 0’s and 1’s.

Example 2:
            Describe the language accepted by DFA M whose transition diagram is given below:


 
                            

           
            Solution:
                    δ(q0,0) = q3, non accepting state
                        δ(q0,10) = δ(q1,0) = q3, non accepting state
                        δ(q0,11) = q2, accepting state
                        δ(q0,110*) = q2, accepting state
                        δ(q0,110*1*) = q2, accepting state

Hence the strings of 0 and 1 that begins with two 1’s are accepted by M.

Example 3:
            Design a DFA that accepts the strings having
i)                                Even no. of a’s
ii)                              Exactly one b over the input set {a,b}

          Solution:
              
     i)                 
Text Box: a                      
                 
                        Let Q = {q0, q1}
                               Σ = {a,b}
                               F = {q0}

ii)
                   
           
                        Let Q = {q0, q1}
                               Σ = {a, b}
                               F = {q1}

·                                                         Let the input be 01001
            δ(q0,0) = {q0,q3}
          δ(q0,01) = δ(δ(q0,0),1)
                            = δ({q0,q3},1)
                            = δ(q0,1) U δ(q3,1)
                            = {q0, q1}
·                                                         Similarly we compute
             δ(q0,010) = {q0,q3}
              δ(q0,0100) = {q0,q3,q4}
              δ(q0,01001) = {q0,q1,q4}

EQUIVALENCE OF DFA’S AND NFA’S:
            For every NFA, we can construct an equivalent DFA. The constructed DFA keeps track in its finite control of all states that the NFA could be in after reading the same input as the DFA has read.

THEOREM:
            Let L be a set accepted by a NFA. Then there exits a DFA that accepts L.

PROOF:
            Let M = (Q, Σ, δ, q0, F) be an NFA accepting L. Define a DFA,
M’ = (Q’, Σ, δ’, q0’, F’), as follows states of M’ are all the subsets of the set of states of M.
            That is, Q’ = 2Q
            M’ will keep track in its state of all the states could be in at any given time. F’ is the set of all states in Q’ containing a final state of M.
            An element of Q’ will be denoted by [q1, q2,..qi], where q1,q2,…qi are in Q. [q1,q2,…qi] is a single state of the DFA corresponding to a set of states of the NFA. Note that q0’ = [q0].

NFA:
            δ(q0,a) = {P1, P2,…..Pn} is that the non-deterministic machine, when in state q and scanning the symbol a, moves right and chooses any one of
P1, P2,…..Pn as its next state.

DEFINITION:
·                                                         A NFA m is a 5-tuple (Q, Σ, δ, q0, F)
Q = finite set of states
 Σ = finite set of input symbols
 q0  Q = initial state
                              δ = mapping of Q* Σ into 2Q
                                      F is a subset of Q = set of final states.
·                                                         A language is accepted by M if there exists some state in both F and δ(q0,w).
·                                                         That is T(M) = {w / δ(q0,w) ∩ F ≠ φ}

BASIS STEPS:
            We define
                δ ’([q1,q2,…qi],a) = [P1,P2,….Pj]
            iff
                δ({q1,q2,…qi},a) = {P1,P2,….Pj}
            That is, δ’ applied to an element [q1,q2,…qi] of Q’ is computed by applying δ to each state of Q represented by [q1,q2,…qi]. On applying δ to each of q1,q2,…qi had taking the union, we get some new set of states, P1,P2,….Pj. This new set of states has a representative [P1,P2,….Pj] in Q’, and that element is the value of δ’([q1,q2,…qi],a).
            It is easy to show by induction on the length of the input string x such that
            δ’(q0’,x) = [q1,q2,…qi]
     iff δ(q0,x) = {q1,q2,…qi}

INDUCTION:
            Suppose that the hypothesis is true for inputs of length m or less. Let xa be a string of length m+1 with a in Σ.
            Then δ’(q0’,xa) = δ’(δ’(q0’,x),a)
            By the inductive hypothesis,
                        δ’(q0’,x) = [P1,P2,….Pj]
                iff δ(q0,x) = {P1,P2,….Pj}
            But by definition of δ’,
                        δ’([P1,P2,….Pj],a) = [r1,r2,…rk]
                iff δ({P1,P2,….Pj},a) = {r1,r2,...rk}
            Thus,
                        δ’(q0’,xa) = [r1,r2,…rk]
                  iff δ(q0,xa) = {r1,r2,…rk},
            which establishes the inductive hypothesis.

EXAMPLE:
            Let  M = ({q0,q1}, {0,1}, δ, q0, {q1}) be an NFA where δ(q0,0) = {q0,q1}, δ(q0,1) = {q1}, δ(q1,0) = φ, δ(q1,1) = {q0,q1}.

DFA:
            M’ = (Q’,{0,1}, δ’, [q0], F’)
      Where, Q = {q0, q1} and denoting elements by [q0],[q1],[q0,q1] and φ.
Therefore, δ(q0,0) = {q0,q1}, we have
            δ’([q0],0) = [q0,q1]
Likewise,
            δ’([q0],1) = [q1],
            δ’([q1],0) = φ
            δ’([q1],1) = [q0,q1]
Naturally, δ’(φ,0) = δ’(φ,1) = φ.
Lastly, δ’([q0,q1],0) = [q0,q1]
Since, δ({q0,q1},0) = δ(q0,0) δ(q1,0)
                                     = {q0, q1}  φ     = {q0, q1}.
And δ’([q0,q1],1) = [q0,q1]
Therefore, δ({q0,q1},1) = δ(q0,1)  δ(q1,1)
                                     = {q1}  {q0, q1}.
                                     = {q0, q1}.

The set F’ of final states is { [q1], [q0,q1]}.


FINITE AUTOMATA WITH ε-MOVES:
            NFA model can be extended to include transitions on the empty input ε. The transition disagram of such an NFA which consists of any number of 0’s, followed by any number of 1’s followed by any number of 2’s is given in the following figure.
Fig 5: Finite automaton with ε-moves.

            Here, edges labeled ε may be included in the path, although the ε’s do not appear explicitly in the string w.

            Example:
       The word 002 is accepted by the NFA of figure by the path   q0, q0, q0, q1, q2, q2 with arcs labeled 0, 0, ε, ε, 2.
                        Formally, NFA with ε-moves is defined to be a quintuple
          (Q, Σ, δ, q0, F) with all components maps Q*(Σ U {ε}) to 2Q.
           
            TRANSITION FUNCTION OF FIGURE:


 
                      States       0         1          2           ε
                        q 0       {q0}      φ          φ        {q1}
                        q 1          φ       {q1}      φ        {q2}
                        q 2          φ       φ          {q2}        φ

                 Fig: δ(q,a) for the NFA of fig 5.
                  
        Now, we extend the transition function δ to a function ŝ that maps Q×Σ* to 2Q.
                  Our expectation is that ŝ(q,w) will be all states P such that one can go from q to P along a path labeled w, including edge labeled ε.
                   In constructing  it will be important to compute the set of states reachable from a given state q using ε transitions only. We use ε-closure(q) to denote the set of all vertices P such that there is a path from q to P labeled ε.

                        For example, in figure 5,
                                    Ε-closure(q0) = {q0,q1,q2}

                            That is, q0 to q0 with all arcs labeled ε.
                                           q0 to q1 with all arcs labeled ε.
                                           q0, q1, q2 with all arcs labeled ε.

            Let ε-closure(P), whose P is a set of states, be Uq in P ε-closure(q). Now, we define  as follows:
1. (q, ε) = ε-closure(q).
2. For w in Σ* and a in Σ,  (q, wa) = ε-closure(P), where P = {P / for some r in (q, w), P is in δ(r,a)}.
3. (R,a) = Uq in R (q, a)
4. (R, w) = Uq in R (q, w) for set of states R.

REGULAR EXPRESSIONS:
            The languages accepted by finite automata are easily described by simple expressions called regular expressions.
            Operations on sets of strings:
·         Let Σ be a finite set of symbols.
·         Let L, L1 and L2 be set of strings from Σ*.
·         Concatenation of L1 and L2 : L1L2 is the set  
     {xy / x is in L1 and y is in L2}

Example:
L1 = {10,1} and L2 = {011,11}
L1L2 = {10011,1011,111} [in all possible combinations]
·         Define L0 = {ε} and Li = LLi-1 for i≥1 kleene closure of L that is L*, is the set
                   
L* =  Li = L0  L1  L2 ……
           
Example:
L* {10,11}* = {ε,10,11,1010,1011,1110,1111..}
·               Positive closure of L, L+ is the set
       L+ =  Li = L* - L0 = L* - {ε}

{10,11}+ = {10,11,1010,1011,1110,1111…}

DEFINITION:
            Let Σ be an alphabet. The regular expressions over Σ and the sets that they denote are defined recursively as follows:
i)              φ is a regular expression and denotes the empty set.
ii)            Ε is a regular expression and denotes the set {ε}.
iii)          For each a € Σ, ‘a’ is a regular expression and denotes the set {a}.
iv)          If ‘r’ and ‘s’ are regular expressions denoting the languages R and S, then
(r+s) denotes the set R  S
(rs) denotes the set RS
(r*) denotes the set R*

PRECEDENCE:
                                    High
                                                      *
                                                   concatenation
                                                      +
                                    Low    

               Example: 01*+0 ó ((0(1*)) + 0)

EXAMPLE:
1.      (0 + 1)*: all strings of 0’s and 1’s. ie.  010101….
2.      (0 + 1)* 00 (0 + 1)*: all strings of 0’s and 1’s with atleast two consecutive 0’s.
3.      (1 + 10)*: al strings of 0’s and 1’s beginning with 1 and not having two consecutive 0’s. ie.110..
4.      0* 1* 2*: any number of 0’s, followed by any number of 1’s followed by any number of 2’s.
5.      00* 11* 22* 0+ 1+ 2+: like 0* 1* 2* with atleast one of each symbol.

EXAMPLE:
            Construct a NFA for the regular expression 01* + 1.

Solution:

·         It is of the form r1 + r2
r1 = 01*
r2 = 1
·         Automation for r2 is

                    
·         We express r1 = 01*
                  = r3 r4*
              Where, r3 = 0
                           r4 = 1*

·         Automaton for r3 is
                                                                                             
·         Now r4 = r5* where r5=1
·         Automation for r5 is
                  
·         r5* is
                                                       ε                                                                       
                                                     ε 
·         r1 = r3 r4*
          = r3 r5*                                                                                      ε 
             
                                                                                                          ε 
·         r = r1 + r2
                             

TWO WAY FINITE AUTOMATA:
            Allow the tape head to move left as well as right.
           
            A two-way deterministic finite automaton (2 DFA) is a quintuple M = (Q, Σ, F, δ, q0), where Q, Σ, F and q0 are as before, and δ is a map from a×Σ to Q×{L,R}.
            If δ(q,a) = (P,L), then in state q, scanning input symbol a, the 2 DFA enters state P and moves its head left one square.
            Same for δ(q,a) = (P,R)

INSTANTANEOUS DESCRIPTION (ID) OF A 2 DFA:
            This describes the input string, current state and current position of the input head.
            The relation ├m on ID’s such that I1 m I2 iff M can go grom the ID1 to ID2 in one move.
            In ID of M is a string in Σ* Q Σ*.

Example:
            wqx, where w and n are in Σ* and q is in Q.
i)              wn is the input string.
ii)            q is the current state.
iii)          The input head is scanning the first symbol of x.
If x = ε, then the input head has moved off the right end of the output.
We define the relation ├m of just Г if M is understood, by
1.      a1 a2….ai-1 q ai…an ├ a1 a2….ai-1 P ai-1 …. an  whenever δ(q,ai) = (P,R) and
2.  a1 a2….ai-2 q ai…an ├ a1 a2….ai-2 P ai-1 …. an whenever δ(q,ai) = (P,L) and i>1.
·         i>1 prevents moving off to the left end of the tape.
·         We define L(M) = {w / q0w├* wp for some p in F}
                                       * reflexive / transitive closure of ├.

            W is accepted by M if, starting in state q0 with w on the input tape and the head at the left end of w, M eventually enters a final state at the same time it falls off the right end of the input tape.

MOORE MACHINE AND MEALY MACHINE
           
            Consider the automaton in which the output is chosen from some other alphabet.
If the output function depends only on the present state, the automaton is called Moore machine.
            If the output function depends only on the present state and present input, the automaton is called mealy machine.

MOORE MACHINE:
            A Moore machine M = (Q, Σ, O, f, δ, q0)

Q - Finite set of states
Σ - Input alphabet
O - Output alphabet
δ - Q* Σ à Q is the transition function
f - Output function mapping f: Q à O
q0 - Initial state
EXAMPLE

            Consider the machine defined by the table

PRESENT STATE
NEXT STATE
OUTPUT
After i/p a
After i/p b
q 0
q 1
q 2
q 3
q 1
q 3
q 0
q 3
q 3
q 1
q 3
q 2
1
0
0
1


            The transition graph is given by
                                

Transition of states:

 Let w = abab be the input string
·         The machine starts with q0 whose output is 1
·         If ‘a’ is the input, the machine moves to q1 with output 0.
·         Then, if ‘b’ is the next input the machine remains in state q1 itself with output 0.
·         If ‘a’ is an input the machine reads ‘a’ and moves to q3 producing an input 1.
·         Next input is ‘b’. it moves from q2 and the output is 0.
·         The traced states are
                q0             q1        q1         q3         q2

MEALY MACHINE:

 A mealy machine M is represented by 6 tuple M = (Q, Σ, O, f, δ, q0)

Q - Finite set of states
Σ - Input alphabet
O - Output alphabet
δ - Q*Σ à Q is the transition function
f - Output function mapping f: Σ *Q à O
q0 - Initial state
EXAMPLE

            Consider the machine defined by the table

PRESENT STATE
NEXT STATE
After i/p a
After i/p b
State
o/p
State
o/p
q0
q1
q2
q3
q3
q2
q3
q0
0             1
1
1
q1
q3               q3
q3
0
1
0
1

            The transition graph is given by

Let w=bbbaa

·         The machine starts with q0. If ‘b’ is the input symbol, machine moves to q1 with output 0.
·         If again ‘b’ is the i/p symbol, the machine moves to q3 with output 1.
·         If ‘b’ is the i/p given, machine moves to itself with output 1.
·         If ‘a’ is i/p machine moves to q0 with o/p 1.
·         If ‘a’ is the i/p, machine moves to q3 with o/p 0.
·         Hence the o/p string is 01110.

NOTE:

·               In a mealy machine the number of characters in the o/p string is same to the number of letters in    i/p string.
·               In a moore machine the length of the o/p string is one more than the length of the input string.






THEOREM 1:

If M1 = (Q, Σ, O, f, δ, q0) is a Moore machine, then there is a Mealy machine M2 equivalent to M1

Proof:

        Let M2 = (Q, Σ, O, f ’, δ, q0) and defined f ’(q,a) = f(δ(q,a)) for all states q and input symbol ‘a’.
      Then, M1 and M2 enter the same sequence of states on the same input, and with each transition M2 emits the O/P that M1 associates with the states entered.

Example:
 
 Construct mealy machine equivalent to Moore machine given below

PRESENT STATE
NEXT STATE
OUTPUT
0
1
q0
q1
q2
q3
q1
q3
q2
q0
q2
q2
q1
q3
1
0
1
1

Solution :
 
   From theorem proof f ‘(q,a) = f(δ(q,a))
   Present states and output is given as
              q0         1
              q1         0
              q2         1
              q3         1

Therefore mealy machine table will be
PRESENT STATE
NEXT STATE
0
1
State
O/P
State
O/P
q0
q1
q2
q3
q1
q3
q2
q0
0
1
1
1
q2
q2
q1
q3
1               1
0
1










THEOREM 2:

If M1 = (Q, Σ, O, f, δ, q0) is a Mealy machine, then there is a Moore machine M2 equivalent to M1


Proof:

     Let M2 = (Q*O, Σ, O, f ‘, δ ‘, [q0, b0]), where b0 is an arbitrarily selected member of ‘O’. i.e., the states of M2 are pairs [q, b] consisting of a state of M1 and an output symbol. Define
                                     δ‘([q, b],a) = [δ[q, a], f(q, a)] and f ‘([q, a]) = b
If M1 enters states q0 , q1,…… qn on input a1,a2…..an and produces output b1,b2…bn then M2 enters states [q0,b0], [q1,b1]……….[qn,bn] and produces outputs b0,b1……bn.

EXAMPLE :
             Construct moore machine equivalent to mealy machine given below
Consider the mealy machine

PRESENT STATE
NEXT STATE
0
1
State
o/p
State
o/p
q1
q2
q3
q4
q3
q1              q2
q4
0
1
1
1
q2
q4
q1
q3
0              0
1               0









·    The states of Moore machine are Q*O

[q1, 1]   [q1, 0]
[q2, 1]   [q2, 0]
[q3, 1]   [q3, 0]
[q4, 1]   [q4, 0]
    
·    From the proof
                 
     δ‘([q, b],a) = [δ[q, a], f(q, a)]


Present states
Next states
Output
a = 0               a = 1
[q1,1]
[q1,0]
[q2,1]
[q2,0]
[q3,1]
[q3,0]
[q4,1]
[q4,0]

[q3,0]              [q2,0]
[q3,0]              [q2,0]
[q1,1]              [q4,0]
[q1,1]              [q4,0]
[q2,1]              [q1,1]
[q2,1]              [q1,1]
[q4,1]              [q3,1]
[q4,1]              [q3,0]

1
0
1
0
1
0
1
0


EQUIVALENCE OF NFA’S WITH AND WITHOUT ε-moves

THEOREM 3:

      If L is accepted by a NFA with ε-transition, then L is accepted by an NFA without ε-transition.

Proof:
        Let M = (Q, Σ, O, F, δ, q0) be an NFA with ε-transition.
Let M‘= (Q, Σ, O, F‘, δ ‘, q0)



 
                           F U {q0} if ε-closure(q0) contains a state in F
Where, F’ =       
                           F         otherwise



δ‘(q, a) = (q, a), q  Q, a  Σ

·                     Then M’ has no ε-transition. Note that δ‘ and ’ are same but δ and  are not same.
·                     We show by induction that
            δ‘{q0,w} = (q0,w) for any string w. Note that w = ε ,
δ‘(q0, ε) = {q0} and {q0, ε } = ε-closure{q0}. So, δ‘(q0, ε) ≠ (q0, ε)
So, the induction is not true for the string having length 0. We start our induction for the string having length 1.

BASICS STEPS:

  Let ‘a’ be a string of length 1. i.e., aΣ δ‘{q0,a} = (q0,a) by definition of δ ‘.

INDUCTION:
     Assume that δ‘(q0, x) = (q0,x) for any string x of length  n. Assume w is a string of length n+1. Let w = xa for some symbol a  Σ. Then,
        δ‘(q0, w) = δ‘(q0, xa)
                         = δ‘(δ‘(q0, x), a)
                         = δ‘( (q0, x), a)
                         = δ‘(p, a)
  Where p =  (q0,x) say
  We must show that
          
             δ‘(p, a) = (q0,xa)
  but δ‘(p, a) = U δ‘(q, a)  =  U (q, a)
                             qp                 qp
                            = ((q0, x), a)
                            = (q0, xa)
                            = (q0, w)
Hence δ‘(q0, w) = (q0, w)

·                     Lastly we show that δ‘(q0, w) contains a state of F’. If (q0, w) and only if contains the state of F’. If w = ε then,
   δ‘{q0, ε} = {q0} and (q0, ε) = ε-closure{q0}.

·                     Note that ε-closure{q0} contains a state (possibly q0) in F. Hence (q0, ε) contains a state in F. Converse is clear from definition of F’.

·                     If w ≠ ε, then w = xa for some symbol ‘a’. If (q0, w) contains the same state in F’. Conversely, If δ‘(q0, w) contains the state in F’ other than q0, q0  F, then = ε-closure (δ((q0,x),a) the state in ε-closure(q0).

THEOREM 4: (CONVERSION OF REGULAR EXPRESSION TO FSA)

    For every regular expression ‘r’ there exists a NFA with ε-transition that    accepts L(r).

Proof:
 
    We prove by induction on the number of operators in the regular expression r* that there is an NFA. M with ε-transition having on final state and no transition out of this final states such that T(M) = L(r).

Basics steps:
 
          Suppose ‘r’ is ε, φ or a for some a  Σ. Then NFA in figure clearly satisfies condition.
      r = ε                                               r = φ                                          r = a  




Induction steps:
  
   Assume the theorem is true for ‘r’ having fewer than i operators, i  1. Let ‘r’ have i operators. We discuss three case on the form of ‘r’.

Case1:
    
·                     Let r = r1 + r2. Both r1 and r2 must have fewer than i operators. Thus, there are NFA’s
                   M1 = (Q1, Σ1, {f1}, δ1, q1) and   
                   M2 = (Q2, Σ2, {f2}, δ2, q2) with T(M1) = L(r1) and T(M2) = L(r2).

·                     Assume Q1 and Q2 are disjoint. Let q0 be a new initial state and f0 a new final state. Construct
                    M = (Q1 U Q2 U {q0, f0}, Σ1 U Σ2, δ, q0, {f0})
    Where δ is defined by
 1.     δ{q0, ε } = {q1,q2}
 2.     δ{q, a } = δ1{q, a} if q  Q1 – {f1}, aΣ1 U {ε}
                      = δ2 {q, a} if q  Q2 – {f2}, a  Σ2 U {ε}
3.         δ1(f1, ε) = δ2(f2, ε) = {f0}

·                     All the moves of M1 and M2 are present in M. The construction of M is depicted in figure. Any path in the transition diagram of M from q0 to f0 must be going to either q1 or q2 on ε and follow any path in M1 or in M2 corresponding by and reaches f0 along the path ε.


·                     These are the only paths from q0 to f0. There is a path labeled x in M from q0 to f0 if and only if there is a path labeled x in M1 from q1 to f1 or a path in M2, from q2 to f2. Hence T(M) = T(M1) U T(M2).

    Case 2:

·                     r = r1r2. Let M1 and M2 be as in case 1. Construct
        M = (Q1 U Q2, Σ1U Σ2, δ, {q1}, {f2})
 Where δ is given by

1.  δ{q, a } = δ1{q, a } if q  Q1 – {f1}, a € Σ1- {ε}
2.  δ1(f1, ε) = {q2}
3.  δ{q, a } = δ2{q, a } if qQ2, a  Σ2U{ε}

·                     Every path in M from q1 to f2 is a path labeled by some string x from q1 to f1 followed by the edge from f1 to q2 labeled ε, followed by a path labeled by some string y from q2 to f2.
·                     T(M) = {xy : x  T(M1), y  T(M2) } Hence
·                     T(M) = T(M1)T(M2)

 Case 3:
 
·                     r =( r1)*. Let M1 = (Q1, Σ1, {f1}, δ1, q1) and T(M1) = r1. Construct
M = (Q1 U {q0, f0}, Σ, δ, q0, {f0})
Where δ is given by
1.      δ{q0, ε } = δ{f1, ε } = {q1,fo}
2.      δ{q, a} = δ1{q, a}  for q  Q1 – {f1}, a  Σ1 U { ε }
 
·                     Any path from q0 to f0 consists either of a path from q0 to f0 on ε or a path from q0 to q1 on ε followed by some number of paths from q1 to f1, then back to q1 on ε. There is a path in M from q0 to f0 labeled x if and only if we write x = x1, x1,…….xj for some jc such that xT(M1). Hence T(M) = T(M1)*.

APPLICATIONS:

·                     All though we stress the abstract and mathematical nature of formal languages and automata, these concepts have wide spread applications in computer science.
·                     Formal languages and grammars are used widely in connection with programming languages.
·                     In most of our programming, we work with more or less intuitive understanding of the language in which we write though it is unfamiliar, we refer to description such as syntax diagrams.
·                     If we wrote a compiler on to reason about correctness of program, a precise description of the languages needed at almost every step.
·                     Among the ways in which programming languages can be defined precisely, grammars are perhaps the most widely used.



Example:


0
1
0
0                                       
No carry
1
No carry
1
1
No carry
0
carry

·                     A binary adder is an integral of any general purpose computer. Such an adder takes two bit strings representing numbers and produces their sum as output.
·                     Let us assume that we are dealing only with the integers and that we use a representation in which
              X = a0a1……an
         Stands for the integer
                       n 
           V(x) = Σ   ai 2i
                    λ=0    
      This is the usual binary representation in reverse.
·                     A serial adder processes two numbers. X = a0a1….an and y=b0b1….bn, bit by bit. Starting at the left end each bit addition creates a digit for the sum as well as a carry digit for the next higher position. A binary addition table in figure summarizes the process.
·                     The figure tells us that an adder is a box that accepts two bits and produces their sum bit and the possible carry.
·                     It describes what an adder does and explains about its internal working. An automaton can makes this much more explicit.                                                                                                                                                                                                   
                               
                                                                   CARRY
Example 2:
·   The input to the transducer are the list pairs (ai,l,i), the output will be the sum list di.
·   Again we represent the automation by a graph, now labeling the edges (ai,bi)/di.
·   The carry from one step to two internal states labeled “Carry” & “no carry”.
·   Initially, the transducer will be in state “no carry”.
·   It will remain in this state until a but pair (1, 1) is encountered.
·   This will generate a carry is then taken into account when it takes the automation into “carry state”.
·   The presence of a carry is thn taken into account when the next but pair is read.
·   As this example (2) indicates, the automation serves as a bridge between the very high-level, functional description of a circuit and its logical implementation through transistors, gates & flip flops.
·   The automation clearly shows (ex 2) the decision logic, yet it is formal enough to lend itself to precise mathematical manipulation.
·   For this reason, digital design methods rely heavily on concepts from automata theory.


No comments:

Post a Comment