Docstoc

Languages and Finite Automata_1_

Document Sample
Languages and Finite Automata_1_ Powered By Docstoc
					            Another NFA Example




Fall 2004          COMP 335       1
            Language accepted




                                (redundant
                                 state)



Fall 2004          COMP 335                  2
Remarks:
            •The     symbol never appears on the
             input tape

            •Simple automata:




Fall 2004                   COMP 335               3
       •NFAs are interesting because we can
        express languages easier than DFAs


            NFA                   DFA




Fall 2004              COMP 335               4
            Formal Definition of NFAs



            Set of states, i.e.

            Input aphabet, i.e.
            Transition function

            Initial state

            Final states
Fall 2004                  COMP 335     5
            Transition Function




Fall 2004          COMP 335       6
Fall 2004   COMP 335   7
Fall 2004   COMP 335   8
Fall 2004   COMP 335   9
            Extended Transition Function




Fall 2004               COMP 335           10
Fall 2004   COMP 335   11
Fall 2004   COMP 335   12
             Formally
            : there is a walk from   to
              with label




Fall 2004       COMP 335                  13
            The Language of an NFA




Fall 2004            COMP 335        14
Fall 2004   COMP 335   15
Fall 2004   COMP 335   16
Fall 2004   COMP 335   17
Fall 2004   COMP 335   18
                    Formally
The language accepted by NFA            is:




where



and there is some                (final state)

Fall 2004             COMP 335                   19
Fall 2004   COMP 335   20
            NFA accept Regular Languages




Fall 2004               COMP 335           21
              Equivalence of FA

Definition:

An FA         is equivalent to FA

if
that is if both accept the same language.



Fall 2004             COMP 335              22
            Example of equivalent FA
                                 NFA




                                 DFA




Fall 2004             COMP 335         23
                    We will prove:


        Languages
                                     Regular
        accepted
                                     Languages
        by NFA
                                     Languages
                                     accepted
                                     by DFA
That is, NFA and DFA have
the same computation power
Fall 2004                 COMP 335               24
                    Step 1


        Languages
                                  Regular
        accepted
                                  Languages
        by NFA

  Proof: Every DFA is trivially an NFA


            Any language     accepted by a DFA
            is also accepted by an NFA
Fall 2004              COMP 335                  25
                    Step 2


        Languages
                                  Regular
        accepted
                                  Languages
        by NFA

 Proof: Any NFA can be converted into an
        equivalent DFA

             Any language accepted by an NFA
             is also accepted by a DFA
Fall 2004              COMP 335                26
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      27
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      28
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      29
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      30
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      31
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      32
            Convert NFA to DFA
NFA




DFA




Fall 2004          COMP 335      33
            NFA to DFA: Remarks

We are given an NFA



We want to convert it
into an equivalent DFA



That is,

Fall 2004           COMP 335      34
If the NFA has states




Then the DFA has states in the powerset




Fall 2004          COMP 335               35
                  Procedure NFA to DFA



1.          Initial state of NFA:




            Initial state of DFA:



Fall 2004                    COMP 335    36
            Example
NFA




DFA




Fall 2004    COMP 335   37
                Procedure NFA to DFA
   2. For every DFA’s state

            Compute in the NFA




            Add the following transition to the DFA


Fall 2004                  COMP 335               38
            Example
NFA




 DFA




Fall 2004    COMP 335   39
            Procedure NFA to DFA



Repeat step 2 for all symbols in the alphabet
 ∑, until no more transitions can be added.




Fall 2004           COMP 335                40
            Example
NFA




DFA




Fall 2004    COMP 335   41
                Procedure NFA to DFA
   3. For any DFA state:


            If some     is a final state in the NFA



            Then,
            is a final state in the DFA


Fall 2004                  COMP 335                   42
            Example
NFA




DFA




Fall 2004    COMP 335   43
                  Theorem
  Take NFA


Apply the procedure to obtain DFA



  Then,     and   are equivalent:




Fall 2004           COMP 335        44
            Proof




            AND




Fall 2004   COMP 335   45
   First we show:



            Take arbitrary string :


            We will prove:




Fall 2004                    COMP 335   46
Fall 2004   COMP 335   47
 We will show that if




Fall 2004           COMP 335   48
  More generally, we will show that if in   :

       (arbitrary string)




Fall 2004                   COMP 335            49
               Proof by induction on


      The basis case:




Fall 2004               COMP 335       50
      Induction hypothesis:




Fall 2004              COMP 335   51
 Induction Step:




Fall 2004          COMP 335   52
 Induction Step:




Fall 2004          COMP 335   53
 Therefore if




Fall 2004       COMP 335   54
       We have shown:




        We also need to show:


               (proof is similar)




Fall 2004               COMP 335    55

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:8/14/2013
language:
pages:55