SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Another NFA Example




                 0
            q0       q1         0, 1 q2
                 1
                     
Fall 2004            COMP 335             1
Language accepted

            L(M ) = {λ, 10, 1010, 101010, ...}
                  = {10}*
                       0
               q0          q1         0, 1 q2
                       1                        (redundant
                                                 state)
                           
Fall 2004                  COMP 335                          2
Remarks:
            •The  symbol never appears on the
             input tape

            •Simple automata:

                M1                        M2
                q0                         q0

            L(M1 ) = {}               L(M 2 ) = {λ}
Fall 2004                  COMP 335                   3
•NFAs are interesting because we can
        express languages easier than DFAs


              NFA     M1               DFA   M2        a
                                                  q2
            q0    a    q1
                                                   a
                                        q0    a   q1

            L( M1 ) = {a}               L( M 2 ) = {a}
Fall 2004                   COMP 335                       4
Formal Definition of NFAs

                    M  Q, ,  , q0 , F 

            Q : Set of states, i.e. q0 , q1, q2 
             : Input aphabet, i.e. a, b
            :     Transition function

            q0 :   Initial state

            F : Final states
Fall 2004                      COMP 335              5
Transition Function 


                  q0 , 1  q1


                    0
            q0              q1      0, 1 q
                                          2
                     1
                           
Fall 2004                COMP 335             6
 (q1,0)  {q0 , q2}


                  0
            q0           q1      0, 1 q
                                       2
                  1
                        
Fall 2004             COMP 335             7
 (q0 ,  )  {q0 , q2}


                   0
            q0            q1      0, 1 q
                                        2
                   1
                         
Fall 2004              COMP 335             8
 (q2 ,1)  


                   0
            q0            q1      0, 1 q
                                        2
                   1
                         
Fall 2004              COMP 335             9
Extended Transition Function  *


                   * q0 , a   q1


                   q4         q5
                        a a
             q0    a    q1       b   q2      q3
                             
Fall 2004                COMP 335                  10
 * q0 , aa   q4 , q5


                     q4         q5
                          a a
            q0      a     q1       b   q2        q3
                               
Fall 2004                  COMP 335                    11
 * q0 , ab  q2 , q3 , q0 


                   q4         q5
                        a a
            q0    a     q1       b   q2       q3
                             
Fall 2004                COMP 335                   12
Formally
q j   * qi , w : there is a walk from qi to q j
                       with label     w

            qi               w                 qj



                      w  1 2  k
                 1   2                  k
            qi                                 qj

Fall 2004                  COMP 335                 13
The Language of an NFA M
F  q0 ,q5
                    q4            q5
                         a a
              q0   a      q1          b   q2      q3
                                  


  * q0 , aa   q4 , q5               aa  L(M )
                           F
Fall 2004              COMP 335                         14
F  q0 ,q5
                    q4            q5
                         a a
             q0    a      q1          b   q2      q3
                                  


 * q0 , ab   q2 , q3 , q0    ab LM 
                                F
 Fall 2004             COMP 335                         15
F  q0 ,q5
                     q4            q5
                          a a
              q0    a      q1          b    q2      q3
                                   


 * q0 , abaa   q4 , q5               abaa L(M )
                                F
Fall 2004               COMP 335                          16
F  q0 ,q5
                      q4            q5
                             a a
               q0    a       q1         b     q2      q3
                                    


     * q0 , aba   q1                  aba  LM 
                             F
Fall 2004                COMP 335                           17
q4            q5
                        a a
            q0    a      q1          b   q2      q3
                                 

            LM   ab*  {ab}*{aa}

Fall 2004             COMP 335                         18
Formally
The language accepted by NFA             M is:
                 LM   w1, w2 , w3 ,...



where        * (q0 , wm )  {qi , q j ,..., qk ,}


and there is some         qk  F (final state)
Fall 2004                   COMP 335                  19
w LM                     * (q0 , w)
                                qi
                 w

            q0
                                qk        qk  F
                 w
                     w          qj



Fall 2004            COMP 335                      20
NFA accept Regular Languages




Fall 2004               COMP 335           21
Equivalence of FA

Definition:

An FA       M1   is equivalent to FA   M2

if LM1   LM 2 
that is if both accept the same language.



Fall 2004                COMP 335           22
Example of equivalent FA
                                      NFA       M1
LM1   {10} *                             0
                                 q0              q1
                                            1

                                      DFA   M2        0,1
LM 2   {10}*                  0
                     q0                q1       1     q2
                                 1
                                        0
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
        accepted                 Regular
                                  Languages
        by NFA

  Proof: Every DFA is trivially an NFA


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


        Languages
        accepted                 Regular
                                  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 M
                  a
      q    a    q 0
                     q   1         2
                               b


DFA         M
                 q0 


Fall 2004                COMP 335       27
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q       1                2
                                   b


DFA         M
                 q0    a
                                   q1, q2 


Fall 2004                    COMP 335              28
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q           1                2
                                       b


DFA         M
                 q0        a
                                       q1, q2 
                         b

                             
Fall 2004                        COMP 335              29
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q           1                2
                                       b

                                                       a
DFA         M
                 q0        a
                                       q1, q2 
                         b

                             
Fall 2004                        COMP 335                  30
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q           1                2
                                       b

                                                       a
DFA         M               b

                 q0        a
                                       q1, q2 
                         b

                             
Fall 2004                        COMP 335                  31
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q           1                2
                                       b

                                                       a
DFA         M               b

                 q0        a
                                       q1, q2 
                         b

                                           a, b
Fall 2004                        COMP 335                  32
Convert NFA to DFA
NFA M
                  a
      q    a    q 0
                     q           1                2

                                             LM   L(M )
                                       b
                                                       a
DFA         M               b

                 q0        a
                                       q1, q2 
                         b

                                           a, b
Fall 2004                        COMP 335                  33
NFA to DFA: Remarks

We are given an NFA       M


We want to convert it
into an equivalent DFA      M


That is,    LM   L(M )
Fall 2004              COMP 335    34
If the NFA has states

                  q0 , q1, q2 ,...

Then the DFA has states in the powerset


            , q0 , q1, q1 , q2 ,....


Fall 2004                COMP 335             35
Procedure NFA to DFA



1.          Initial state of NFA:        q0



            Initial state of DFA:       q0 


Fall 2004                    COMP 335           36
Example
NFA         M                    a
                 q0      a    q1            q2
                                    b


DFA         M
                 q0 


Fall 2004                     COMP 335            37
Procedure NFA to DFA
   2. For every DFA’s state {qi , q j ,..., qm}

            Compute in the NFA
                 * qi , a ,
                 * q j , a ,               {qi , qj ,..., qm}
                                                                 
                 ...
            Add the following transition to the DFA
             {qi , q j ,..., qm}, a   {qi , qj ,..., qm}
                                                            
Fall 2004                         COMP 335                            38
Example
NFA         M                   a
                q0      a       q1            q2
                                    b
                   * (q0 , a )  {q1, q2 }

 DFA        M
                q0        a
                                      q1, q2 

                  q0 , a   q1, q2 
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         M                    a
                 q0      a       q1               q2
                                       b

                                                        a
DFA         M               b

                 q0        a
                                       q1, q2 
                         b

                                           a, b
Fall 2004                        COMP 335                   41
Procedure NFA to DFA
   3. For any DFA state: {qi , q j ,..., qm}


            If some   qj   is a final state in the NFA



            Then, {qi , q j ,..., qm }
            is a final state in the DFA


Fall 2004                     COMP 335                   42
Example
NFA         M                    a
                 q0      a       q1               q2       q1  F
                                       b
                                                        a
DFA         M               b

                 q0        a
                                       q1, q2 
                         b                              q1, q2  F 
                                           a, b
Fall 2004                        COMP 335                          43
Theorem
  Take NFA      M


Apply the procedure to obtain DFA       M


  Then,     M and M  are equivalent:

                 LM   LM 

Fall 2004               COMP 335             44
Proof

                  LM   LM 



   L  M   L M     AND        L  M   L M  



Fall 2004               COMP 335                        45
First we show:        L  M   L M  


            Take arbitrary string : w L (M )


            We will prove:      w  L(M )



Fall 2004                    COMP 335           46
w L(M )




M:          q0               w              qf



                      w  1 2  k
                 1   2               k
 M:         q0                              qf

Fall 2004                  COMP 335              47
We will show that if             w L(M )

                      w  1 2  k
                 1   2                 k
  M:        q0                                 qf




                 1   2                 k
    M:
            {q0}                              {q f ,}
                      w  L(M )
Fall 2004                  COMP 335                      48
More generally, we will show that if in                        M:
       (arbitrary string)       v  a1a2 an
                       a1          a2                      an
     M:         q0           qi          qj          ql         qm




     M:
                      a1          a2                      an
               {q0}        {qi ,} {q j ,}        {ql ,} {qm ,}


Fall 2004                               COMP 335                      49
Proof by induction on          |v|

      The basis case:       v  a1


                                a1
                 M:       q0          qi


                 M:
                               a1
                        {q0}        {qi ,}



Fall 2004               COMP 335                    50
Induction hypothesis:                    1 | v | k
                          v  a1a2 ak
                    a1         a2                     ak
     M:      q0           qi         qj          qc        qd




     M:
                   a1          a2                     ak
            {q0}        {qi ,} {q j ,}        {qc ,} {qd ,}


Fall 2004                           COMP 335                      51
Induction Step:               | v | k  1
                   v  a1a2 ak ak 1  vak 1
                        
                          
                                    v

                    a1         a2                    ak
     M:      q0           qi         qj         qc        qd


                                         v
     M:
                   a1          a2                    ak
            {q0}        {qi ,} {q j ,}       {qc ,} {qd ,}


Fall 2004
                                         v
                                    COMP 335                     52
Induction Step:               | v | k  1
                   v  a1a2 ak ak 1  vak 1
                        
                          
                                    v

                    a1         a2                    ak        ak 1
     M:      q0           qi         qj         qc        qd           qe

                                         v
     M:
                   a1          a2                    ak        ak 1
            {q0}        {qi ,} {q j ,}       {qc ,} {qd ,}         {qe ,}


Fall 2004
                                         v
                                    COMP 335                                     53
Therefore if         w L(M )

                      w  1 2  k
                 1   2               k
  M:        q0                               qf




                 1   2               k
    M:
            {q0}                            {q f ,}
                      w  L(M )
Fall 2004                  COMP 335                    54
We have shown:      L  M   L M  



        We also need to show:      L  M   L M  

               (proof is similar)




Fall 2004               COMP 335                        55

Weitere ähnliche Inhalte

Was ist angesagt?

Theory of computing
Theory of computingTheory of computing
Theory of computing
Ranjan Kumar
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
lavishka_anuj
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
 

Was ist angesagt? (20)

Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
 
Turing machine by_deep
Turing machine by_deepTuring machine by_deep
Turing machine by_deep
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfg
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Theory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and ProblemsTheory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and Problems
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
Post Machine
Post MachinePost Machine
Post Machine
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Automata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfaAutomata theory -Conversion of ε nfa to nfa
Automata theory -Conversion of ε nfa to nfa
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
TOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite AutomataTOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite Automata
 

Andere mochten auch

Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
rawan_z
 

Andere mochten auch (20)

Nfa vs dfa
Nfa vs dfaNfa vs dfa
Nfa vs dfa
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwares
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Language translator
Language translatorLanguage translator
Language translator
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Code generation
Code generationCode generation
Code generation
 

Dfa vs nfa

  • 1. Another NFA Example 0 q0 q1 0, 1 q2 1  Fall 2004 COMP 335 1
  • 2. Language accepted L(M ) = {λ, 10, 1010, 101010, ...} = {10}* 0 q0 q1 0, 1 q2 1 (redundant state)  Fall 2004 COMP 335 2
  • 3. Remarks: •The  symbol never appears on the input tape •Simple automata: M1 M2 q0 q0 L(M1 ) = {} L(M 2 ) = {λ} Fall 2004 COMP 335 3
  • 4. •NFAs are interesting because we can express languages easier than DFAs NFA M1 DFA M2 a q2 q0 a q1 a q0 a q1 L( M1 ) = {a} L( M 2 ) = {a} Fall 2004 COMP 335 4
  • 5. Formal Definition of NFAs M  Q, ,  , q0 , F  Q : Set of states, i.e. q0 , q1, q2   : Input aphabet, i.e. a, b : Transition function q0 : Initial state F : Final states Fall 2004 COMP 335 5
  • 6. Transition Function   q0 , 1  q1 0 q0 q1 0, 1 q 2 1  Fall 2004 COMP 335 6
  • 7.  (q1,0)  {q0 , q2} 0 q0 q1 0, 1 q 2 1  Fall 2004 COMP 335 7
  • 8.  (q0 ,  )  {q0 , q2} 0 q0 q1 0, 1 q 2 1  Fall 2004 COMP 335 8
  • 9.  (q2 ,1)   0 q0 q1 0, 1 q 2 1  Fall 2004 COMP 335 9
  • 10. Extended Transition Function  *  * q0 , a   q1 q4 q5 a a q0 a q1 b q2  q3  Fall 2004 COMP 335 10
  • 11.  * q0 , aa   q4 , q5 q4 q5 a a q0 a q1 b q2  q3  Fall 2004 COMP 335 11
  • 12.  * q0 , ab  q2 , q3 , q0  q4 q5 a a q0 a q1 b q2  q3  Fall 2004 COMP 335 12
  • 13. Formally q j   * qi , w : there is a walk from qi to q j with label w qi w qj w  1 2  k 1 2 k qi qj Fall 2004 COMP 335 13
  • 14. The Language of an NFA M F  q0 ,q5 q4 q5 a a q0 a q1 b q2  q3   * q0 , aa   q4 , q5 aa  L(M ) F Fall 2004 COMP 335 14
  • 15. F  q0 ,q5 q4 q5 a a q0 a q1 b q2  q3   * q0 , ab   q2 , q3 , q0  ab LM  F Fall 2004 COMP 335 15
  • 16. F  q0 ,q5 q4 q5 a a q0 a q1 b q2  q3   * q0 , abaa   q4 , q5 abaa L(M ) F Fall 2004 COMP 335 16
  • 17. F  q0 ,q5 q4 q5 a a q0 a q1 b q2  q3   * q0 , aba   q1 aba  LM  F Fall 2004 COMP 335 17
  • 18. q4 q5 a a q0 a q1 b q2  q3  LM   ab*  {ab}*{aa} Fall 2004 COMP 335 18
  • 19. Formally The language accepted by NFA M is: LM   w1, w2 , w3 ,... where  * (q0 , wm )  {qi , q j ,..., qk ,} and there is some qk  F (final state) Fall 2004 COMP 335 19
  • 20. w LM   * (q0 , w) qi w q0 qk qk  F w w qj Fall 2004 COMP 335 20
  • 21. NFA accept Regular Languages Fall 2004 COMP 335 21
  • 22. Equivalence of FA Definition: An FA M1 is equivalent to FA M2 if LM1   LM 2  that is if both accept the same language. Fall 2004 COMP 335 22
  • 23. Example of equivalent FA NFA M1 LM1   {10} * 0 q0 q1 1 DFA M2 0,1 LM 2   {10}* 0 q0 q1 1 q2 1 0 Fall 2004 COMP 335 23
  • 24. 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
  • 25. Step 1 Languages accepted  Regular Languages by NFA Proof: Every DFA is trivially an NFA Any language L accepted by a DFA is also accepted by an NFA Fall 2004 COMP 335 25
  • 26. Step 2 Languages accepted  Regular 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
  • 27. Convert NFA to DFA NFA M a q a q 0  q 1 2 b DFA M q0  Fall 2004 COMP 335 27
  • 28. Convert NFA to DFA NFA M a q a q 0  q 1 2 b DFA M q0  a q1, q2  Fall 2004 COMP 335 28
  • 29. Convert NFA to DFA NFA M a q a q 0  q 1 2 b DFA M q0  a q1, q2  b  Fall 2004 COMP 335 29
  • 30. Convert NFA to DFA NFA M a q a q 0  q 1 2 b a DFA M q0  a q1, q2  b  Fall 2004 COMP 335 30
  • 31. Convert NFA to DFA NFA M a q a q 0  q 1 2 b a DFA M b q0  a q1, q2  b  Fall 2004 COMP 335 31
  • 32. Convert NFA to DFA NFA M a q a q 0  q 1 2 b a DFA M b q0  a q1, q2  b  a, b Fall 2004 COMP 335 32
  • 33. Convert NFA to DFA NFA M a q a q 0  q 1 2 LM   L(M ) b a DFA M b q0  a q1, q2  b  a, b Fall 2004 COMP 335 33
  • 34. NFA to DFA: Remarks We are given an NFA M We want to convert it into an equivalent DFA M That is, LM   L(M ) Fall 2004 COMP 335 34
  • 35. If the NFA has states q0 , q1, q2 ,... Then the DFA has states in the powerset , q0 , q1, q1 , q2 ,.... Fall 2004 COMP 335 35
  • 36. Procedure NFA to DFA 1. Initial state of NFA: q0 Initial state of DFA: q0  Fall 2004 COMP 335 36
  • 37. Example NFA M a q0 a q1  q2 b DFA M q0  Fall 2004 COMP 335 37
  • 38. Procedure NFA to DFA 2. For every DFA’s state {qi , q j ,..., qm} Compute in the NFA  * qi , a ,  * q j , a ,  {qi , qj ,..., qm}  ... Add the following transition to the DFA  {qi , q j ,..., qm}, a   {qi , qj ,..., qm}  Fall 2004 COMP 335 38
  • 39. Example NFA M a q0 a q1  q2 b  * (q0 , a )  {q1, q2 } DFA M q0  a q1, q2   q0 , a   q1, q2  Fall 2004 COMP 335 39
  • 40. 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
  • 41. Example NFA M a q0 a q1  q2 b a DFA M b q0  a q1, q2  b  a, b Fall 2004 COMP 335 41
  • 42. Procedure NFA to DFA 3. For any DFA state: {qi , q j ,..., qm} If some qj is a final state in the NFA Then, {qi , q j ,..., qm } is a final state in the DFA Fall 2004 COMP 335 42
  • 43. Example NFA M a q0 a q1  q2 q1  F b a DFA M b q0  a q1, q2  b q1, q2  F   a, b Fall 2004 COMP 335 43
  • 44. Theorem Take NFA M Apply the procedure to obtain DFA M Then, M and M  are equivalent: LM   LM  Fall 2004 COMP 335 44
  • 45. Proof LM   LM  L  M   L M   AND L  M   L M   Fall 2004 COMP 335 45
  • 46. First we show: L  M   L M   Take arbitrary string : w L (M ) We will prove: w  L(M ) Fall 2004 COMP 335 46
  • 47. w L(M ) M: q0 w qf w  1 2  k 1 2 k M: q0 qf Fall 2004 COMP 335 47
  • 48. We will show that if w L(M ) w  1 2  k 1 2 k M: q0 qf 1 2 k M: {q0} {q f ,} w  L(M ) Fall 2004 COMP 335 48
  • 49. More generally, we will show that if in M: (arbitrary string) v  a1a2 an a1 a2 an M: q0 qi qj ql qm M: a1 a2 an {q0} {qi ,} {q j ,} {ql ,} {qm ,} Fall 2004 COMP 335 49
  • 50. Proof by induction on |v| The basis case: v  a1 a1 M: q0 qi M: a1 {q0} {qi ,} Fall 2004 COMP 335 50
  • 51. Induction hypothesis: 1 | v | k v  a1a2 ak a1 a2 ak M: q0 qi qj qc qd M: a1 a2 ak {q0} {qi ,} {q j ,} {qc ,} {qd ,} Fall 2004 COMP 335 51
  • 52. Induction Step: | v | k  1 v  a1a2 ak ak 1  vak 1     v a1 a2 ak M: q0 qi qj qc qd v M: a1 a2 ak {q0} {qi ,} {q j ,} {qc ,} {qd ,} Fall 2004 v COMP 335 52
  • 53. Induction Step: | v | k  1 v  a1a2 ak ak 1  vak 1     v a1 a2 ak ak 1 M: q0 qi qj qc qd qe v M: a1 a2 ak ak 1 {q0} {qi ,} {q j ,} {qc ,} {qd ,} {qe ,} Fall 2004 v COMP 335 53
  • 54. Therefore if w L(M ) w  1 2  k 1 2 k M: q0 qf 1 2 k M: {q0} {q f ,} w  L(M ) Fall 2004 COMP 335 54
  • 55. We have shown: L  M   L M   We also need to show: L  M   L M   (proof is similar) Fall 2004 COMP 335 55