SlideShare a Scribd company logo
Theory of Automata
         &
 Formal Languages



                     1
BOOKS
Theory of computer Science: K.L.P.Mishra &
                           N.Chandrasekharan

Intro to Automata theory, Formal languages and
  computation:            Ullman,Hopcroft
                         Motwani

Elements of theory of computation Lewis &
                               papadimitrou

                                                 2
Syllabus
Introduction
Deterministic and non deterministic Finite
  Automata, Regular Expression,Two way
  finite automata,Finite automata with
  output,properties of regular sets,pumping
  lemma, closure properties,Myhill nerode
  theorem

                                              3
Context free Grammar: Derivation
 trees, Simplification forms
Pushdown automata: Def, Relationship
 between PDA and context free
 language,Properties, decision algorithms
Turing Machines: Turing machine
 model,Modification of turing
 machines,Church’s
 thesis,Undecidability,Recursive and
 recursively enumerable languages Post
 correspondence problems recursive
 functions
                                            4
Chomsky Hierarchy: Regular
 grammars, unrestricted grammar, context
 sensitive language, relationship among
 languages




                                           5
temporary memory

                   input memory
        CPU
                   output memory

 Program memory


                             6
temporary memory
                                                 3
                                f ( x)       x
        z 2*2 4
      f ( x) z * 2 8
                             input memory
                                 x       2
             CPU
                             output memory
Program memory
      compute    x x
      compute
                     2
                 x       x                   7
Automaton
temporary memory

Automaton
                   input memory
            CPU
                   output memory

  Program memory


                             8
temporary memory



                   input memory
  Finite
  Automaton
                   output memory




                             9
Different Kinds of Automata
Automata are distinguished by the temporary memory


  • Finite Automata:     no temporary memory


  • Pushdown Automata:   stack


  • Turing Machines:     random access memory


                                            10
Pushdown Automaton
          Stack             Push, Pop




                                input memory
              Pushdown
              Automaton
                               output memory


Programming Languages (medium computing power)
                                          11
Turing Machine

         Random Access Memory



                                input memory
              Turing
              Machine
                               output memory


Algorithms    (highest computing power)
                                          12
Power of Automata



Finite         Pushdown        Turing
Automata       Automata        Machine




                                        13
Power sets
A power set is a set of sets

S = { a, b, c }


Powerset of S = the set of all the subsets of S

2S = {   , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} }


Observation: | 2S | = 2|S|           ( 8 = 23 )

                                                        14
Cartesian Product
        A = { 2, 4 }              B = { 2, 3, 5 }


A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 4) }


                   |A X B| = |A| |B|


         Generalizes to more than two sets


                     AXBX…XZ
                                                       15
RELATIONS
R = {(x1, y1), (x2, y2), (x3, y3), …}


xi R yi


e. g. if R = „>‟: 2 > 1, 3 > 2, 3 > 1




In relations xi can be repeated
                                        16
Equivalence Relations
• Reflexive:       xRx
• Symmetric:       xRy        yRx
• Transitive:      x R Y and y R z      xRz


Example: R = „=„
•x=x
•x=y                y=x
• x = y and y = z          x=z
                                              17
Equivalence Classes
For equivalence relation R
      equivalence class of x = {y : x R y}


Example:
    R = { (1, 1), (2, 2), (1, 2), (2, 1),
           (3, 3), (4, 4), (3, 4), (4, 3) }


Equivalence class of 1 = {1, 2}
Equivalence class of 3 = {3, 4}               18
Example of Equivalence relation
Let Z = set of integers
R be defined on it as:
R= {(x,y)| x Z, y Z and
                        (x - y)is divisible by 5}
This relation is known as
” congruent modulo 5”


                                                19
The equivalence classes are
[0]R= {…-10, -5, 0, 5,10,…}
[1]R = {…..,-9, -4, 1, 6, 11, 16….}
[2]R= {….-8, -3,2,7,12,17…..}
[3]R = {….-7, -2, 3, 8 ,13,…}
[4]R = {….-6,-1,4,9,14,19,….}
Z/R ={[0]R, [1]R, [2]R, [3]R, [4]R}



                                      20
PROOF TECHNIQUES

• Proof by induction


• Proof by contradiction




                           21
Induction

We have statements P1, P2, P3, …

If we know
       • for some k that P1, P2, …, Pk are true
       • for any n >= k that
            P1, P2, …, Pn imply Pn+1
Then
       Every Pi is true
                                                  22
Trees
                root



                          parent

        leaf

                               child


Trees have no cycles


                                       23
Proof by Induction
• Inductive basis
     Find P1, P2, …, Pk which are true


• Inductive hypothesis
     Let‟s assume P1, P2, …, Pn are true,
     for any n >= k


• Inductive step
     Show that Pn+1 is true                 24
root
              Level 0



                 Level 1
leaf                          Height 3

                    Level 2



                    Level 3
                                         25
Binary Trees




               26
Example
Theorem: A binary tree of height n
            has at most 2n leaves.

Proof:
         let l(i) be the number of leaves at level i

                                        l(0) = 0




                                        l(3) = 8       27
Induction Step


 Level
      n             hypothesis: l(n) <= 2n

n+1




                                      28
We want to show: l(i) <= 2i


• Inductive basis
        l(0) = 1     (the root node)


• Inductive hypothesis
        Let‟s assume l(i) <= 2i for all i = 0, 1, …, n


• Induction step
        we need to show that l(n + 1) <= 2n+1      29
Induction Step


 Level
      n                             hypothesis: l(n) <= 2n

n+1


          l(n+1) <= 2 * l(n) <= 2 * 2n = 2n+1


                                                      30
Proof by Contradiction

We want to prove that a statement P is true


     • we assume that P is false
     • then we arrive at an incorrect conclusion
     • therefore, statement P must be true




                                              31
Example
Theorem:         2   is not rational


Proof:
     Assume by contradiction that it is rational

             2   = n/m
           n and m have no common factors


     We will show that this is impossible
                                               32
2   = n/m                2 m 2 = n2



                                         n is even
Therefore,   n2   is even
                                         n=2k


                                             m is even
2 m2 = 4k2            m2 = 2k2
                                             m=2p


  Thus, m and n have common factor 2

        Contradiction!                               33
Basic Terms
Alphabet: A finite non empty set of elements.

             ={a,b,c,d,…z}




                                            34
• String: A sequence of letters

   –       Examples: “cat”, “dog”, “house”, …

   –       Defined over an alphabet:
                         a, b, c,, z

 Language: It is a set of strings on some
alphabet
                                                35
Alphabets and Strings
• We will use small alphabets:      a, b
• Strings    a
             ab                  u ab
             abba                v bbbaaa
             baba        w abba
             aaabbbaabab
                                           36
String Operations
w a1a2 an                    abba
v b1b2 bm                    bbbaaa


             Concatenation

wv   a1a2 anb1b2 bm        abbabbbaaa

                                       37
w a1a2 an               ababaaabbb



               Reverse

    R
w       an  a2 a1       bbbaaababa

                                  38
String Length
       w a1a2 an
       w    n

• Length:
            abba   4

• Examples:
            aa 2
            a 1
                            39
Recursive Definition of Length
                 a       1

For any letter: wa        wa    w 1
                         abba   abb 1
For any string       :
                                ab 1 1
Example:                        a 1 1 1
                                1 1 1 1
                                4         40
Length of Concatenation
             uv   u     v

        u    aab, u     3
        v    abaab, v       5
• Example:

        uv    aababaab 8
        uv    u   v   3 5 8
                                41
Proof of Concatenation Length
     uv     u    v
• Claim:                              v

• Proof: By induction on the length
                     v 1

  – Induction basis:
  –     From definition of length:
                 uv    u   1    u     v   42
uv    u     v

– Inductive hypothesis:           v 1,2,, n
    •                     for


                                   uv       u   v
– Inductive step: we will prove
–
–                         for
                                  v     n 1
                                                43
Inductive Step
      v    wa                   w    n, a            1

• Write           ,   where    uv    uwa         uw 1
• From definition of length:   wa    w 1

                                uw       u       w
• From inductive hypothesis:


     uv
• Thus:       u       w 1 u         wa       u   v
                                                     44
Empty String
• A string with no letters:
                      0

• Observations:
                  w w         w


                  abba abba       abba
                                         45
Substring
• Substring of string:
   – a subsequence of consecutive characters

                      abbab                ab
•            String            Substring
                      abbab                abba
                      abbab                b
                      abbab                bbab
                                               46
Prefix and Suffix
•    Prefixes   Suffixes   abbab w uv
                 abbab
    a            bbab        prefix
                                      suffix
    ab           bab
    abb          ab
    abba         b
                                       47
    abbab
Another Operation
                 wn        ww  w
                           
                            
                             n
                       2
             abba           abbaabba
• Example:

                 0
             w
• Definition:
   –                   0
                abba
                                       48
The * Operation
•   * : the set of all possible strings from
•       alphabet



    a, b
*      , a, b, aa, ab, ba, bb, aaa, aab,

•
                                               49
The + Operation
  : the set of all possible strings from
    alphabet     except

  a, b
*    , a, b, aa, ab, ba, bb, aaa, aab,


      *
     a, b, aa, ab, ba, bb, aaa, aab,
                                           50
Language          *

• A language is any subset of
             a, b
• Example: *    , a, b, aa, ab, ba, bb, aaa,



               a, aa, aab
• Languages:
             { , abba, baba, aa, ab, aaaaaa}
                                         51
Another Examplen
                      n
                 L {a b : n      0}

• An infinite language


ab
                     L   abb L
aabb
aaaaabbbbb
                                 52
Operations on Languages

• The usual set operations
a, ab, aaaa  bb, ab         {a, ab, bb, aaaa}
a, ab, aaaa  bb, ab         {ab}
a, ab, aaaa       bb, ab     a, aaaa

• Complement:    L       * L
  a, ba        , b, aa, ab, bb, aaa,     53
Reverse
                R         R
           L            {w : w L}
• Definition:
                                 R
          ab, aab, baba              ba, baa, abab
• Examples:
                           n n
                    L {a b : n 0}

                    R         n n
                    L     {b a : n 0}         54
Concatenation
             L1L2    xy : x L1, y L2

• Definition:


         a, ab, ba b, aa

• Example:
             ab, aaa, abb, abaa, bab, baaa
                                        55
Another Operation
             Ln   LL  L
                  
                       n
• Definition:
        3
 a, b        a, b a, b a, b
 aaa, aab, aba, abb, baa, bab, bba, bbb


                  L0

• Special case:
                                   0
                   a , bba , aaa       56
More Examples
          n n
    L {a b : n 0}
•

    2     n n m m
    L   {a b a b : n, m 0}

                      2
         aabbaaabbb L
                             57
Star-Closure (Kleene *)
                     0   1    2
             L* L  L  L 
• Definition:


                 ,
• Example:
                a, bb,
a, bb *
                aa, abb, bba, bbbb,
•               aaa, aabb, abba, abbbb,
                                           58
Positive Closure
                     1    2
           L        L  L 
                    L*
• Definition:


                a, bb,
a, bb           aa, abb, bba, bbbb,
                aaa, aabb, abba, abbbb,
                                       59
Finite Automaton
       Input
•     String

                   Output
    Finite             String
    Automaton



                                60
Finite Accepter
      Input
•     String
                    Output
                   “Accept”
    Finite
                      or
    Automaton
                   “Reject”


                              61
Transition Graph
                                   a,b
    Abba -Finite Accepter
•                                   q5
                a                        a,b
       b             a    b
      q0 a     q1 b q2 b q3 a            q4

    initial                           final
    state                             state
                      transition
              state                  “accept”
                                                62
Initial Configuration
           Input String
a b b a
•
                          a,b

                           q5
             a                  a,b
     b            a    b
    q0 a    q1 b q2 b q3 a      q4

                                      63
Reading the Input
a b b a
•
                         a,b

                          q5
            a                  a,b
     b           a    b
    q0 a   q1 b q2 b q3 a      q4

                                     64
a b b a

                      a,b

                       q5
           a                a,b
   b            a    b
  q0 a    q1 b q2 b q3 a    q4

                                  65
a b b a

                      a,b

                       q5
           a                a,b
   b            a    b
  q0 a    q1 b q2 b q3 a    q4

                                  66
a b b a

                      a,b

                       q5
           a                a,b
   b            a    b
  q0 a    q1 b q2 b q3 a    q4

                                  67
Input finished

a b b a

                        a,b

                          q5
           a                   a,b
   b            a    b
  q0 a    q1 b q2 b q3 a       q4

                    Output: “accept”68
Rejection
a b a
•
                         a,b

                          q5
            a                  a,b
     b           a    b
    q0 a   q1 b q2 b q3 a      q4

                                     69
a b a
•
                       a,b

                        q5
            a                a,b
     b           a    b
    q0 a   q1 b q2 b q3 a    q4

                                   70
a b a
•
                       a,b

                        q5
            a                a,b
     b           a    b
    q0 a   q1 b q2 b q3 a    q4

                                   71
a b a
•
                       a,b

                        q5
            a                a,b
     b           a    b
    q0 a   q1 b q2 b q3 a    q4

                                   72
Input finished

a b a

                     a,b
                         Output:
                      q5 “reject”
          a              a,b
   b           a    b
  q0 a   q1 b q2 b q3 a    q4

                                73
Another Example
a a b


  a                       a,b


  q0    b           a,b
               q1         q2


                                74
a a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             75
a a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             76
a a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             77
Input finished

a a b


  a                            a,b
            Output: “accept”

  q0    b               a,b
                   q1          q2


                                     78
Rejection
b a b


  a                           a,b


  q0    b               a,b
                q1            q2


                                    79
b a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             80
b a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             81
b a b


  a                    a,b


  q0    b        a,b
            q1         q2


                             82
Input finished

b a b


  a                            a,b


  q0    b              a,b
                  q1           q2

                       Output: “reject”
                                     83
• Deterministic Finite Accepter (DFA)

             M     Q, , , q0 , F


Q : Finite set of states
     : input alphabet

     : transition function
                             :Q X       Q
q0   : initial state is a member of Q

F    : set of final states
                                        84
Input Alphabet
       a, b

                    a,b

                     q5
 b       a                a,b
              a    b
q0 a    q1 b q2 b q3 a    q4
                                85
Set of States Q
Q    q0 , q1, q2 , q3 , q4 , q5
                                  a,b

                                   q5
            a                           a,b
     b           a    b
    q0 a   q1 b q2 b q3 a               q4

                                              86
Initial State q0

                    a,b

                     q5
        a                  a,b
 b           a    b
q0 a   q1 b q2 b q3 a      q4

                                 87
Set of Final States F
F     q4

                          a,b

                           q5
             a                  a,b
     b            a    b
    q0 a    q1 b q2 b q3 a      q4

                                      88
Transition Function
        :Q      Q

                    a,b

                     q5
 b      a                 a,b
             a    b
q0 a   q1 b q2 b q3 a     q4
                                89
q0 , a   q1

                      a,b

                       q5
 b      a                   a,b
             a    b
q0 a   q1 b q2 b q3 a       q4
                                  90
q0 , b   q5

                      a,b

                       q5
 b      a                   a,b
             a    b
q0 a   q1 b q2 b q3 a       q4
                                  91
q2 , b   q3

                      a,b

                       q5
 b      a                   a,b
             a    b
q0 a   q1 b q2 b q3 a       q4
                                  92
a    b      Transition Function
q0    q1   q5
q1•   q5   q2
q2    q2   q3
q3    q4   q5                      a,b
q4    q5   q5
q5    q5   q5                       q5
                 b      a                 a,b
                             a    b
                q0 a   q1 b q2 b q3 a     q4
                                         93
Extended Transition Function *

         *: Q   *   Q

                        a,b

                         q5
   b      a                   a,b
               a    b
  q0 a   q1 b q2 b q3 a       q4
                                    94
* q0 , ab   q2

                        a,b

                         q5
 b      a                     a,b
             a    b
q0 a   q1 b q2 b q3 a         q4
                                    95
* q0 , abba   q4

                      a,b

                          q5
 b      a                      a,b
             a    b
q0 a   q1 b q2 b q3 a          q4
                                     96
* q0 , abbbaa   q5

                    a,b

                        q5
 b      a                    a,b
             a    b
q0 a   q1 b q2 b q3 a        q4
                                   97
Observation: There is a walk from q0 to q1
             with label abbbaa

           * q0 , abbbaa    q5
                                 a,b

                                  q5
         b      a                      a,b
                     a    b
        q0 a   q1 b q2 b q3 a          q4
                                             98
Recursive Definition
    * q,    q
•   * q, wa   ( * (q, w), a )
                          a,b

                           q5
     b      a                   a,b
                 a    b
    q0 a   q1 b q2 b q3 a       q4
                                      99
* q0 , ab
     * (q0 , a ), b
       * q0 ,     ,a ,b
    q0 , a , b
 q1 , b
q2                        a,b

                           q5
       b      a                 a,b
                   a    b
      q0 a   q1 b q2 b q3 a     q4
                                      100
Languages Accepted by DFAs
• Take DFA    M

• Definition:
  – The language L M contains
  – all input strings accepted by M


LM
 –        = { strings that drive M to a final state}

                                                   101
Example
LM     abba                        M
•                       a,b

                         q5
      b      a                a,b
                  a    b
     q0 a   q1 b q2 b q3 a    q4
                             accept
                                    102
Another Example
LM          , ab, abba                    M
•                             a,b

                               q5
        b        a       a          a,b
                           b
       q0 a     q1 b q2 b q3 a      q4
     accept          accept      accept
                                          103
Formally

• For a DFA Language accepted by M :

  LM       w     * : * q0 , w         F
   M           Q,       ,    , q0 , F
alphabet   transition       initial   final
           function         state     states
                                          104
Observation
• Language accepted by M:
   LM        w      * : * q0 , w   F



• Language rejected by M :
  LM         w     * : * q0 , w    F
                                       105
•        More Examples
                n
         LM   {a b : n 0}

    a                         a,b


    q0   b             a,b
                q1            q2

              accept     trap state
                          or dead state
                                  106
LM       = { all strings with prefix   ab }
•                                        a,b



    q0        a         q1      b         q2

               b         a              accept

                       q3       a,b
                                               107
L M = { all strings without
            substring 001 }
•

      1                   0           0,1
           1
                     0            1
                0         00          001

           0
                                            108
Regular Languages

• A language L is regular if there is
• a DFA M such that L L M

• All regular languages form a language
  family
  –
                                          109
Example
            L awa : w           a, b *
                                         a
• The language             b
• is regular:
                                 b
             q0       a    q2            q3
•
                 b               a
             q4

                     a,b                      110
Non Deterministic
   Automata



                    111
Non Deterministic Finite
          Accepter

M        Q, , , q0 , F
                           Q
      :Q                2
                               112
Nondeterministic Finite Accepter (NFA)

Alphabet = {a}



                 q1 a   q2
           a
      q0
           a
                 q3

                                  113
Nondeterministic Finite Accepter (NFA)

Alphabet = {a}


  Two choices    q1 a   q2
           a
      q0
           a
                 q3

                                  114
Nondeterministic Finite Accepter (NFA)

Alphabet = {a}


  Two choices    q1 a     q2   No transition
           a
      q0
           a
                 q3 No transition

                                        115
First Choice

a a


                 q1 a    q2
           a
      q0
           a
                 q3

                              116
First Choice

a a


                 q1 a    q2
           a
      q0
           a
                 q3

                              117
First Choice

a a


                 q1 a    q2
           a
      q0
           a
                 q3

                              118
First Choice

 a a
All input is consumed

                  q1 a    q2   “accept”
            a
       q0
            a
                  q3

                                      119
Second Choice

a a


                 q1 a   q2
           a
      q0
           a
                 q3

                               120
Second Choice

a a


                 q1 a   q2
           a
      q0
           a
                 q3

                               121
Second Choice

a a


                 q1 a    q2
           a
      q0
           a
                      No transition:
                 q3
                      the automaton hangs
                                      122
Second Choice

 a a
Input cannot be consumed

                  q1 a     q2
            a
       q0
            a
                  q3   “reject”

                                  123
An NFA accepts a string:

when there is a computation of the NFA
that accepts the string


•All the input is consumed and the automaton
 is in a final state



                                         124
An NFA rejects a string:

when there is no computation of the NFA
that accepts the string

  • All the input is consumed and the
    automaton is in a non final state


  • The input cannot be consumed
                                          125
Example

  aa is accepted by the NFA:
                 “accept”
            q1 a   q2                      q1 a   q2
        a                              a
   q0                             q0
        a                              a
            q3                             q3   “reject”
because this computation
accepts aa                                        126
Rejection example

a


              q1 a    q2
         a
    q0
         a
              q3

                             127
First Choice

a


               q1 a    q2
         a
    q0
         a
               q3

                            128
First Choice

a
             “reject”
                q1 a    q2
         a
    q0
         a
                q3

                             129
Second Choice

a


               q1 a   q2
         a
    q0
         a
               q3

                             130
Second Choice

a


               q1 a   q2
         a
    q0
         a
               q3

                             131
Second Choice

a


               q1 a      q2
         a
    q0
         a
               q3   “reject”

                               132
Example
     a is rejected by the NFA:
                                 “reject”
         q1 a    q2                  q1 a   q2
     a                           a
q0                          q0
     a                           a
         q3   “reject”               q3



All possible computations lead to rejection
                                       133
Rejection example

a a a


             q1 a    q2
        a
   q0
        a
             q3

                            134
First Choice

a a a


              q1 a    q2
        a
   q0
        a
              q3

                           135
First Choice

a a a


              q1 a    q2
        a
   q0
        a            No transition:
                     the automaton hangs
              q3

                                   136
First Choice

 a a a
Input cannot be consumed

                q1 a    q2   “reject”
          a
     q0
          a
                q3

                                        137
Second Choice

a a a


              q1 a   q2
        a
   q0
        a
              q3

                            138
Second Choice

a a a


              q1 a   q2
        a
   q0
        a
              q3

                            139
Second Choice

a a a


              q1 a    q2
        a
   q0
        a
                   No transition:
              q3
                   the automaton hangs
                                   140
Second Choice

 a a a
Input cannot be consumed

                q1 a     q2
          a
     q0
          a
                q3   “reject”

                                141
aaa is rejected by the NFA:

               “reject”
          q1 a   q2                q1 a   q2
      a                        a
 q0                       q0
      a                        a
          q3                       q3   “reject”


All possible computations lead to rejection
                                       142
Language accepted:   L {aa}


           q1 a      q2
       a
  q0
       a
           q3

                              143
Lambda →Transitions




q0 a   q1   q2 a   q3


                        144
a a




      q0 a   q1   q2 a   q3


                              145
a a




      q0 a   q1   q2 a   q3


                              146
(read head doesn‟t move)

a a




      q0 a    q1      q2 a         q3


                                        147
a a




      q0 a   q1   q2 a   q3


                              148
all input is consumed

 a a



                                 “accept”

       q0 a     q1        q2 a     q3


String   aa is accepted                     149
Rejection Example


a a a




   q0 a     q1      q2 a    q3


                                 150
a a a




   q0 a   q1   q2 a   q3


                           151
(read head doesn‟t move)

a a a




   q0 a       q1      q2 a         q3


                                        152
a a a




   q0 a   q1     q2 a      q3

               No transition:
               the automaton hangs
                                153
Input cannot be consumed

 a a a



                              “reject”

     q0 a      q1      q2 a     q3


String   aaa is rejected                 154
Language accepted:   L {aa}



 q0 a     q1         q2 a     q3


                                   155
Another NFA Example




q0    a   q1   b   q2      q3


                                156
a b




 q0   a   q1   b   q2   q3


                             157
a b




 q0   a   q1   b   q2   q3


                             158
a b




 q0   a   q1   b   q2   q3


                             159
a b



                   “accept”

 q0   a   q1   b      q2      q3


                                   160
Another String

a b a b




 q0   a     q1   b    q2   q3


                                161
a b a b




 q0   a   q1   b   q2   q3


                             162
a b a b




 q0   a   q1   b   q2   q3


                             163
a b a b




 q0   a   q1   b   q2   q3


                             164
a b a b




 q0   a   q1   b   q2   q3


                             165
a b a b




 q0   a   q1   b   q2   q3


                             166
a b a b




 q0   a   q1   b   q2   q3


                             167
a b a b



                   “accept”

 q0   a   q1   b      q2      q3


                                   168
Language accepted

     L       ab, abab, ababab, ...
             ab


q0       a        q1   b   q2        q3


                                          169
Another NFA Example



     0
q0       q1   0, 1 q2
     1


                        170
Language accepted

L(M ) = {λ, 10, 1010, 101010, ...}
      = {10}*
           0
   q0          q1   0, 1 q2
           1


                                     171
Remarks:
    •The      symbol never appears on the
     input tape

    •Extreme automata:

           M1                     M2
           q0                      q0

    L(M1 ) = {}              L(M 2 ) = {λ}
                                        172
•NFAs are interesting because we can
 express languages easier than DFAs


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

                         q0        a   q1

 L( M1 ) = {a}           L( M 2 ) = {a} 173
Formal Definition of NFAs
     M      Q,     ,
                   , q0 , F
Q : Set of states, i.e. q0 , q1, q2
  : Input alphabet, i.e. a, b
  : Transition function
q0 : Initial state

F : Final states                      174
Transition Function


     q0 , 1        q1


     0
q0            q1    0, 1 q
                          2
      1

                              175
(q1,0) {q0 , q2}


        0
q0          q1   0, 1 q
                       2
        1

                           176
(q0 , ) {q0 , q2}


        0
q0          q1   0, 1 q
                       2
        1

                           177
(q2 ,1)


     0
q0        q1   0, 1 q
                     2
     1

                         178
Extended Transition Function *
               * q0 , a       q1
•



           q4          q5
                 a a
      q0   a      q1      b   q2   q3
                                        179
* q0 , aa        q4 , q5


      q4         q5
           a a
q0   a     q1    b      q2      q3
                                     180
* q0 , ab      q2 , q3 , q0


        q4         q5
             a a
q0     a     q1    b     q2        q3
                                        181
Formally
             qj       * qi , w

It holds
if and only if

       there is a walk from   qi to q j
       with label w
                                          182
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 )
                                                 183
F   q0 ,q5
                    q4         q5
                         a a
             q0    a     q1    b     q2        q3




* q0 , ab     q2 , q3 , q0          ab L M
                                             184
F       q0 ,q5
                       q4         q5
    •                       a a
                 q0    a    q1    b      q2      q3




* q0 , abaa           q4 , q5          aaba L(M )
                                               185
F    q0 ,q5
                   q4         q5
                        a a
              q0   a    q1    b     q2         q3




    * q0 , aba     q1              aba L M
                                             186
q4         q5
                    a a
     q0        a    q1     b   q2          q3




LM        aa        ab *       ab   aa
                                         187
Formally

• The language accepted by NFA    M is:
          LM        w1, w2 , w3 ,...
        * (q0 , wm ) {qi , q j ,...}

• where
• and there is some qk   F      (final state)
                                          188
w LM                * (q0 , w)

 •                    qi
            w
                      qk         qk     F
       q0   w
                w     qj


                                      189
Equivalence of NFAs and DFAs




                           190
Equivalence of Machines

• For DFAs or NFAs:

• Machine   M1   is equivalent to machine M
                                              2

• if    L M1      L M2
•                                         191
NFA   M1
L M1   {10} *        0
                q0        q1    0, 1         q2
  •
                     1


                         DFA   M2        0,1
L M2   {10}*         0
                q0        q1    1        q2
                     1
                           0           192
• Since   L M1    L M2           10 *

• machines   M1   and    M 2are equivalent

                             0
     NFA     M1         q0        q1    0, 1   q2
                             1


                                               0,1
                             0
      DFA    M2         q0        q1     1     q2
                             1
                                   0                 193
Equivalence of NFAs and DFAs
Question:      NFAs   =   DFAs ?



            Same power?
            Accept the same languages?


                                         194
Equivalence of NFAs and DFAs


Question:      NFAs   =   DFAs ?   YES!


            Same power?
            Accept the same languages?


                                         195
We will prove:


Languages                Languages
accepted                 accepted
by NFAs                  by DFAs



  NFAs and DFAs have the same
  computation power

                                     196
Step 1


  Languages               Languages
  accepted                accepted
  by NFAs                 by DFAs

Proof: Every DFA is trivially an NFA



      A language accepted by a DFA
      is also accepted by an NFA       197
Step 2


  Languages             Languages
  accepted              accepted
  by NFAs               by DFAs

Proof: Any NFA can be converted to an
       equivalent DFA

       A language accepted by an NFA
       is also accepted by a DFA        198
NFA to DFA
NFA   M                   a
          q0   a     q1         q2
 •                        b


DFA   M
          q0


                                     199
NFA   M                     a
          q0   a       q1                q2
 •                          b


DFA   M
          q0       a
                                q1, q2


                                              200
NFA   M                     a
          q0   a       q1                q2
 •                          b


DFA   M
          q0       a
                                q1, q2
               b

                                              201
NFA   M                     a
          q0   a       q1                q2
 •                          b

                                              a
DFA   M
          q0       a
                                q1, q2
               b

                                                  202
NFA   M                     a
          q0   a       q1                q2
 •                          b

                   b                          a
DFA   M
          q0       a
                                q1, q2
               b

                                                  203
NFA   M                     a
          q0   a       q1                q2
 •                          b

                   b                          a
DFA   M
          q0       a
                                q1, q2
               b
                                  a, b
                                                  204
NFA   M                     a            LM       L(M )
          q0   a       q1                q2
 •                          b
                                              a
DFA   M            b

          q0       a
                                q1, q2
               b
                                  a, b
                                                    205
NFA to DFA: Remarks

• We are given an NFA   M


• We want to convert it to an equivalent DFA M

      LM       L(M )
                                          206
• If the NFA has states


              q0 , q1, q2 ,...

• the DFA has states in the power set
•

    , q0 , q1 , q1, q2 , q3 , q4 , q7 ,....
                                              207
Procedure NFA to DFA
•


• 1.   Initial state of NFA:   q0

•

•      Initial state of DFA:   q0
                                    208
NFA   M                 a
          q0   a   q1       q2
 •                      b


DFA   M
          q0


                                 209
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}
•
              ...
      {qi , q j ,..., qm}, a   {qi , q j ,..., qm}
•
                                              210
       Add transition to DFA
NFA   M                        a
          q0     a       q1                 q2
 •                           b
               * (q0 , a ) {q1, q2 }

DFA M

          q0         a
                                   q1, q2

               q0 , a         q1, q2             211
Procedure NFA to DFA



• Repeat Step 2 for all letters in alphabet,
•                 until
• no more transitions can be added.



                                               212
NFA   M                     a
          q0   a       q1                q2
 •                          b

                   b                          a
DFA   M
          q0       a
                                q1, q2
               b
                                  a, b
                                                  213
Procedure NFA to DFA

•   3. For any DFA state {qi , q j ,..., qm}


•      If some   q j is a final state in the NFA


•      Then, {qi , q j ,..., qm }
•
                                                   214
       is a final state in the DFA
NFA   M                     a
          q0   a       q1                q2       q1         F
 •                          b
                                              a
DFA   M            b

          q0       a
                                q1, q2
               b                              q1, q2         F
                                  a, b
                                                       215
Theorem
 Take NFA M
  •
Apply procedure to obtain DFA   M


Then   M    and     M     are equivalent :

            LM       LM
                                        216
Finally
        We have proven
Languages             Languages
accepted              accepted
by NFAs               by DFAs




                                  217
We have proven

Languages            Languages
accepted             accepted
by NFAs              by DFAs

                  Regular Languages


                                 218
We have proven

   Languages             Languages
   accepted              accepted
   by NFAs               by DFAs

Regular Languages     Regular Languages


                                     219
We have proven

   Languages              Languages
   accepted               accepted
   by NFAs                by DFAs

Regular Languages      Regular Languages

 Thus, NFAs accept the regular languages
                                      220
Single Final State
for NFAs and DFAs



                      221
Observation


• Any Finite Automaton (NFA or DFA)

• can be converted to an equivalent NFA

• with a single final state
                                          222
Example
    a                 NFA
a         b

b


    a             Equivalent NFA

a         b

b
                             223
In General
NFA




Equivalent NFA

                        Single
                        final state
                              224
Extreme Case

NFA without final state




                      Add a final state
                      Without transitions



                                    225
Some Properties of
Regular Languages



                     226
properties

For regular languages    L1 and L
                                 2
we will prove that:
           Union:   L1     L2

   Concatenation:   L1L2         Are regular
                                 Languages
            Star:   L1 *
                                         227
We Say:
Regular languages are closed under

          Union:   L1     L2

  Concatenation:   L1L2


           Star:   L1 *
                                     228
Properties
 For regular languages   L1   and   L2
 we will prove that:
        Union:   L1     L2
                                Are regular
Concatenation:   L1L2
                                Languages


        Star:    L1 *
                                         229
Regular language    L1   Regular language     L2

     L M1      L1          L M2      L2

     NFA    M1              NFA    M2



 Single final state      Single final state
                                          230
Example
            a
     n                   M1
L1 {a b}        b


                    M2
L2   ba         b    a

                              231
L1    L2 Union
                M1
• NFA for



                M2


                       232
n
          L1   L2 {a b} {ba}
NFA for
                        n
  •            L1 {a b}
               a
                    b


                   L2 {ba}
                    b       a
                                233
Concatenation
       L1L2

• NFA for
       M1             M2




                            234
Example
                  n           n
       L1L2 {a b}{ba} {a bba}
•
• NFA for
            n
  L1 {a b}
  a                L2 {ba}
      b             b     a


                                  235
Star Operation
• NFA for L *
           1

                            L1 *
                M1




                             236
Example
                 n
       L1* {a b} *

• NFA for
                       n
            L1       {a N>=}
                         b0
            a
                 b


                               237
Procedure: NFA to DFA
1   Create a graph with vertex {q0}.Identify this vertex as
    initial vertex of DFA.
2   Repeat the following steps until no more edges are
    missing.Take any vertex {qi,qj,….qk} of G that has no
    outgoing edge for some symbol a of the alphabet.
    Compute *(qi, a), * (qj, a)…. *(qk, a)
    Then form the union of all these yielding the set
                                                   *
    {ql, qm, …qn}.
    Create a vertex for G labeled {ql, qm,…qn} if it does not
    already exist.
    Add to G an edge from {qi, qj,…qk} to {ql,qm…qn} and
    label it with a.
3   Every state of G whose label contains any qf of F is
    identified as a final vertex of DFA.
4   If NFA accepts then vertex {q0} in G is also made a
                                                      238
    final vertex.
1
     0

q0         q1         q2
     0,1        0,1




                               239
Start
Equivalent                    q0       1
                        0
DFA                                         q
                 {q0,                       1
                 q1}                                                1
                                                     0,1
                               1                           q2
             0
                                                    0,1         0

                   q0,q1,q2        1        q1,q2

      0                                                             0,1

                                                                    240

More Related Content

What's hot

Text Analysis with Machine Learning
Text Analysis with Machine LearningText Analysis with Machine Learning
Text Analysis with Machine Learning
Turi, Inc.
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Fuzzy Logic
Fuzzy LogicFuzzy Logic
Fuzzy Logic
Rishikese MR
 
4 internet programming
4 internet programming4 internet programming
4 internet programmingsoner_kavlak
 
Developing R Graphical User Interfaces
Developing R Graphical User InterfacesDeveloping R Graphical User Interfaces
Developing R Graphical User Interfaces
Setia Pramana
 
Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming Language
Reham AlBlehid
 
Index Structures.pptx
Index Structures.pptxIndex Structures.pptx
Index Structures.pptx
MBablu1
 
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptxDisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
Adeel Saifee
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of ada
Sahil Kumar
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
PDFSHARE
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
United International University
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHING
Abhishek Singh
 
Shuffle exchange networks
Shuffle exchange networksShuffle exchange networks
Shuffle exchange networks
Lahiru Danushka
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
EN1036VivekSingh
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
Temesgen Molla
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Kuppusamy P
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 

What's hot (20)

Text Analysis with Machine Learning
Text Analysis with Machine LearningText Analysis with Machine Learning
Text Analysis with Machine Learning
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Fuzzy Logic
Fuzzy LogicFuzzy Logic
Fuzzy Logic
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
4 internet programming
4 internet programming4 internet programming
4 internet programming
 
Developing R Graphical User Interfaces
Developing R Graphical User InterfacesDeveloping R Graphical User Interfaces
Developing R Graphical User Interfaces
 
Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming Language
 
Index Structures.pptx
Index Structures.pptxIndex Structures.pptx
Index Structures.pptx
 
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptxDisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
DisMath-lecture-1-Introduction-to-Discrete-Maths-08032022-114934am.pptx
 
backtracking algorithms of ada
backtracking algorithms of adabacktracking algorithms of ada
backtracking algorithms of ada
 
Message passing interface
Message passing interfaceMessage passing interface
Message passing interface
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Intro to assembly language
Intro to assembly languageIntro to assembly language
Intro to assembly language
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHING
 
Shuffle exchange networks
Shuffle exchange networksShuffle exchange networks
Shuffle exchange networks
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
Macro-processor
Macro-processorMacro-processor
Macro-processor
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
NP completeness
NP completenessNP completeness
NP completeness
 

Viewers also liked

Non regular languages
Non regular languagesNon regular languages
Non regular languageslavishka_anuj
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammarlavishka_anuj
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
Mukesh Tekwani
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machineslavishka_anuj
 

Viewers also liked (9)

One ques
One quesOne ques
One ques
 
Non regular languages
Non regular languagesNon regular languages
Non regular languages
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfg
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
Finite automata
Finite automataFinite automata
Finite automata
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 

Similar to Flat

Unit 3
Unit 3Unit 3
Unit 3
guna287176
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
Dr. C.V. Suresh Babu
 
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
STAIR Lab, Chiba Institute of Technology
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
smruti sarangi
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
luzenith_g
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
KokilaK25
 
Computing the Square Roots of Unity to break RSA using Quantum Algorithms
Computing the Square Roots of Unity to break RSA using Quantum AlgorithmsComputing the Square Roots of Unity to break RSA using Quantum Algorithms
Computing the Square Roots of Unity to break RSA using Quantum Algorithms
Dharmalingam Ganesan
 
Class 29: Inheritance
Class 29: InheritanceClass 29: Inheritance
Class 29: Inheritance
David Evans
 
Csr2011 june15 09_30_shen
Csr2011 june15 09_30_shenCsr2011 june15 09_30_shen
Csr2011 june15 09_30_shenCSR2011
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1chidabdu
 
pattern recognition
pattern recognition pattern recognition
pattern recognition
MohammadMoattar2
 
The Perceptron (D1L2 Deep Learning for Speech and Language)
The Perceptron (D1L2 Deep Learning for Speech and Language)The Perceptron (D1L2 Deep Learning for Speech and Language)
The Perceptron (D1L2 Deep Learning for Speech and Language)
Universitat Politècnica de Catalunya
 
The Magic of Auto Differentiation
The Magic of Auto DifferentiationThe Magic of Auto Differentiation
The Magic of Auto Differentiation
Sanyam Kapoor
 
Class 28: Entropy
Class 28: EntropyClass 28: Entropy
Class 28: Entropy
David Evans
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiouvafopoulos
 
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
npinto
 

Similar to Flat (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
 
Alg1
Alg1Alg1
Alg1
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Computing the Square Roots of Unity to break RSA using Quantum Algorithms
Computing the Square Roots of Unity to break RSA using Quantum AlgorithmsComputing the Square Roots of Unity to break RSA using Quantum Algorithms
Computing the Square Roots of Unity to break RSA using Quantum Algorithms
 
Class 29: Inheritance
Class 29: InheritanceClass 29: Inheritance
Class 29: Inheritance
 
Csr2011 june15 09_30_shen
Csr2011 june15 09_30_shenCsr2011 june15 09_30_shen
Csr2011 june15 09_30_shen
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
 
Lecture5
Lecture5Lecture5
Lecture5
 
pattern recognition
pattern recognition pattern recognition
pattern recognition
 
Mit6 094 iap10_lec03
Mit6 094 iap10_lec03Mit6 094 iap10_lec03
Mit6 094 iap10_lec03
 
The Perceptron (D1L2 Deep Learning for Speech and Language)
The Perceptron (D1L2 Deep Learning for Speech and Language)The Perceptron (D1L2 Deep Learning for Speech and Language)
The Perceptron (D1L2 Deep Learning for Speech and Language)
 
The Magic of Auto Differentiation
The Magic of Auto DifferentiationThe Magic of Auto Differentiation
The Magic of Auto Differentiation
 
Class 28: Entropy
Class 28: EntropyClass 28: Entropy
Class 28: Entropy
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
 
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
[Harvard CS264] 09 - Machine Learning on Big Data: Lessons Learned from Googl...
 

Recently uploaded

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

Flat

  • 1. Theory of Automata & Formal Languages 1
  • 2. BOOKS Theory of computer Science: K.L.P.Mishra & N.Chandrasekharan Intro to Automata theory, Formal languages and computation: Ullman,Hopcroft Motwani Elements of theory of computation Lewis & papadimitrou 2
  • 3. Syllabus Introduction Deterministic and non deterministic Finite Automata, Regular Expression,Two way finite automata,Finite automata with output,properties of regular sets,pumping lemma, closure properties,Myhill nerode theorem 3
  • 4. Context free Grammar: Derivation trees, Simplification forms Pushdown automata: Def, Relationship between PDA and context free language,Properties, decision algorithms Turing Machines: Turing machine model,Modification of turing machines,Church’s thesis,Undecidability,Recursive and recursively enumerable languages Post correspondence problems recursive functions 4
  • 5. Chomsky Hierarchy: Regular grammars, unrestricted grammar, context sensitive language, relationship among languages 5
  • 6. temporary memory input memory CPU output memory Program memory 6
  • 7. temporary memory 3 f ( x) x z 2*2 4 f ( x) z * 2 8 input memory x 2 CPU output memory Program memory compute x x compute 2 x x 7
  • 8. Automaton temporary memory Automaton input memory CPU output memory Program memory 8
  • 9. temporary memory input memory Finite Automaton output memory 9
  • 10. Different Kinds of Automata Automata are distinguished by the temporary memory • Finite Automata: no temporary memory • Pushdown Automata: stack • Turing Machines: random access memory 10
  • 11. Pushdown Automaton Stack Push, Pop input memory Pushdown Automaton output memory Programming Languages (medium computing power) 11
  • 12. Turing Machine Random Access Memory input memory Turing Machine output memory Algorithms (highest computing power) 12
  • 13. Power of Automata Finite Pushdown Turing Automata Automata Machine 13
  • 14. Power sets A power set is a set of sets S = { a, b, c } Powerset of S = the set of all the subsets of S 2S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: | 2S | = 2|S| ( 8 = 23 ) 14
  • 15. Cartesian Product A = { 2, 4 } B = { 2, 3, 5 } A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 4) } |A X B| = |A| |B| Generalizes to more than two sets AXBX…XZ 15
  • 16. RELATIONS R = {(x1, y1), (x2, y2), (x3, y3), …} xi R yi e. g. if R = „>‟: 2 > 1, 3 > 2, 3 > 1 In relations xi can be repeated 16
  • 17. Equivalence Relations • Reflexive: xRx • Symmetric: xRy yRx • Transitive: x R Y and y R z xRz Example: R = „=„ •x=x •x=y y=x • x = y and y = z x=z 17
  • 18. Equivalence Classes For equivalence relation R equivalence class of x = {y : x R y} Example: R = { (1, 1), (2, 2), (1, 2), (2, 1), (3, 3), (4, 4), (3, 4), (4, 3) } Equivalence class of 1 = {1, 2} Equivalence class of 3 = {3, 4} 18
  • 19. Example of Equivalence relation Let Z = set of integers R be defined on it as: R= {(x,y)| x Z, y Z and (x - y)is divisible by 5} This relation is known as ” congruent modulo 5” 19
  • 20. The equivalence classes are [0]R= {…-10, -5, 0, 5,10,…} [1]R = {…..,-9, -4, 1, 6, 11, 16….} [2]R= {….-8, -3,2,7,12,17…..} [3]R = {….-7, -2, 3, 8 ,13,…} [4]R = {….-6,-1,4,9,14,19,….} Z/R ={[0]R, [1]R, [2]R, [3]R, [4]R} 20
  • 21. PROOF TECHNIQUES • Proof by induction • Proof by contradiction 21
  • 22. Induction We have statements P1, P2, P3, … If we know • for some k that P1, P2, …, Pk are true • for any n >= k that P1, P2, …, Pn imply Pn+1 Then Every Pi is true 22
  • 23. Trees root parent leaf child Trees have no cycles 23
  • 24. Proof by Induction • Inductive basis Find P1, P2, …, Pk which are true • Inductive hypothesis Let‟s assume P1, P2, …, Pn are true, for any n >= k • Inductive step Show that Pn+1 is true 24
  • 25. root Level 0 Level 1 leaf Height 3 Level 2 Level 3 25
  • 27. Example Theorem: A binary tree of height n has at most 2n leaves. Proof: let l(i) be the number of leaves at level i l(0) = 0 l(3) = 8 27
  • 28. Induction Step Level n hypothesis: l(n) <= 2n n+1 28
  • 29. We want to show: l(i) <= 2i • Inductive basis l(0) = 1 (the root node) • Inductive hypothesis Let‟s assume l(i) <= 2i for all i = 0, 1, …, n • Induction step we need to show that l(n + 1) <= 2n+1 29
  • 30. Induction Step Level n hypothesis: l(n) <= 2n n+1 l(n+1) <= 2 * l(n) <= 2 * 2n = 2n+1 30
  • 31. Proof by Contradiction We want to prove that a statement P is true • we assume that P is false • then we arrive at an incorrect conclusion • therefore, statement P must be true 31
  • 32. Example Theorem: 2 is not rational Proof: Assume by contradiction that it is rational 2 = n/m n and m have no common factors We will show that this is impossible 32
  • 33. 2 = n/m 2 m 2 = n2 n is even Therefore, n2 is even n=2k m is even 2 m2 = 4k2 m2 = 2k2 m=2p Thus, m and n have common factor 2 Contradiction! 33
  • 34. Basic Terms Alphabet: A finite non empty set of elements. ={a,b,c,d,…z} 34
  • 35. • String: A sequence of letters – Examples: “cat”, “dog”, “house”, … – Defined over an alphabet: a, b, c,, z Language: It is a set of strings on some alphabet 35
  • 36. Alphabets and Strings • We will use small alphabets: a, b • Strings a ab u ab abba v bbbaaa baba w abba aaabbbaabab 36
  • 37. String Operations w a1a2 an abba v b1b2 bm bbbaaa Concatenation wv a1a2 anb1b2 bm abbabbbaaa 37
  • 38. w a1a2 an ababaaabbb Reverse R w an  a2 a1 bbbaaababa 38
  • 39. String Length w a1a2 an w n • Length: abba 4 • Examples: aa 2 a 1 39
  • 40. Recursive Definition of Length a 1 For any letter: wa wa w 1 abba abb 1 For any string : ab 1 1 Example: a 1 1 1 1 1 1 1 4 40
  • 41. Length of Concatenation uv u v u aab, u 3 v abaab, v 5 • Example: uv aababaab 8 uv u v 3 5 8 41
  • 42. Proof of Concatenation Length uv u v • Claim: v • Proof: By induction on the length v 1 – Induction basis: – From definition of length: uv u 1 u v 42
  • 43. uv u v – Inductive hypothesis: v 1,2,, n • for uv u v – Inductive step: we will prove – – for v n 1 43
  • 44. Inductive Step v wa w n, a 1 • Write , where uv uwa uw 1 • From definition of length: wa w 1 uw u w • From inductive hypothesis: uv • Thus: u w 1 u wa u v 44
  • 45. Empty String • A string with no letters: 0 • Observations: w w w abba abba abba 45
  • 46. Substring • Substring of string: – a subsequence of consecutive characters abbab ab • String Substring abbab abba abbab b abbab bbab 46
  • 47. Prefix and Suffix • Prefixes Suffixes abbab w uv abbab a bbab prefix suffix ab bab abb ab abba b 47 abbab
  • 48. Another Operation wn ww  w    n 2 abba abbaabba • Example: 0 w • Definition: – 0 abba 48
  • 49. The * Operation • * : the set of all possible strings from • alphabet a, b * , a, b, aa, ab, ba, bb, aaa, aab, • 49
  • 50. The + Operation : the set of all possible strings from alphabet except a, b * , a, b, aa, ab, ba, bb, aaa, aab, * a, b, aa, ab, ba, bb, aaa, aab, 50
  • 51. Language * • A language is any subset of a, b • Example: * , a, b, aa, ab, ba, bb, aaa, a, aa, aab • Languages: { , abba, baba, aa, ab, aaaaaa} 51
  • 52. Another Examplen n L {a b : n 0} • An infinite language ab L abb L aabb aaaaabbbbb 52
  • 53. Operations on Languages • The usual set operations a, ab, aaaa  bb, ab {a, ab, bb, aaaa} a, ab, aaaa  bb, ab {ab} a, ab, aaaa bb, ab a, aaaa • Complement: L * L a, ba , b, aa, ab, bb, aaa, 53
  • 54. Reverse R R L {w : w L} • Definition: R ab, aab, baba ba, baa, abab • Examples: n n L {a b : n 0} R n n L {b a : n 0} 54
  • 55. Concatenation L1L2 xy : x L1, y L2 • Definition: a, ab, ba b, aa • Example: ab, aaa, abb, abaa, bab, baaa 55
  • 56. Another Operation Ln LL  L  n • Definition: 3 a, b a, b a, b a, b aaa, aab, aba, abb, baa, bab, bba, bbb L0 • Special case: 0 a , bba , aaa 56
  • 57. More Examples n n L {a b : n 0} • 2 n n m m L {a b a b : n, m 0} 2 aabbaaabbb L 57
  • 58. Star-Closure (Kleene *) 0 1 2 L* L  L  L  • Definition: , • Example: a, bb, a, bb * aa, abb, bba, bbbb, • aaa, aabb, abba, abbbb, 58
  • 59. Positive Closure 1 2 L L  L  L* • Definition: a, bb, a, bb aa, abb, bba, bbbb, aaa, aabb, abba, abbbb, 59
  • 60. Finite Automaton Input • String Output Finite String Automaton 60
  • 61. Finite Accepter Input • String Output “Accept” Finite or Automaton “Reject” 61
  • 62. Transition Graph a,b Abba -Finite Accepter • q5 a a,b b a b q0 a q1 b q2 b q3 a q4 initial final state state transition state “accept” 62
  • 63. Initial Configuration Input String a b b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 63
  • 64. Reading the Input a b b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 64
  • 65. a b b a a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 65
  • 66. a b b a a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 66
  • 67. a b b a a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 67
  • 68. Input finished a b b a a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 Output: “accept”68
  • 69. Rejection a b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 69
  • 70. a b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 70
  • 71. a b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 71
  • 72. a b a • a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 72
  • 73. Input finished a b a a,b Output: q5 “reject” a a,b b a b q0 a q1 b q2 b q3 a q4 73
  • 74. Another Example a a b a a,b q0 b a,b q1 q2 74
  • 75. a a b a a,b q0 b a,b q1 q2 75
  • 76. a a b a a,b q0 b a,b q1 q2 76
  • 77. a a b a a,b q0 b a,b q1 q2 77
  • 78. Input finished a a b a a,b Output: “accept” q0 b a,b q1 q2 78
  • 79. Rejection b a b a a,b q0 b a,b q1 q2 79
  • 80. b a b a a,b q0 b a,b q1 q2 80
  • 81. b a b a a,b q0 b a,b q1 q2 81
  • 82. b a b a a,b q0 b a,b q1 q2 82
  • 83. Input finished b a b a a,b q0 b a,b q1 q2 Output: “reject” 83
  • 84. • Deterministic Finite Accepter (DFA) M Q, , , q0 , F Q : Finite set of states : input alphabet : transition function :Q X Q q0 : initial state is a member of Q F : set of final states 84
  • 85. Input Alphabet a, b a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 85
  • 86. Set of States Q Q q0 , q1, q2 , q3 , q4 , q5 a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 86
  • 87. Initial State q0 a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 87
  • 88. Set of Final States F F q4 a,b q5 a a,b b a b q0 a q1 b q2 b q3 a q4 88
  • 89. Transition Function :Q Q a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 89
  • 90. q0 , a q1 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 90
  • 91. q0 , b q5 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 91
  • 92. q2 , b q3 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 92
  • 93. a b Transition Function q0 q1 q5 q1• q5 q2 q2 q2 q3 q3 q4 q5 a,b q4 q5 q5 q5 q5 q5 q5 b a a,b a b q0 a q1 b q2 b q3 a q4 93
  • 94. Extended Transition Function * *: Q * Q a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 94
  • 95. * q0 , ab q2 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 95
  • 96. * q0 , abba q4 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 96
  • 97. * q0 , abbbaa q5 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 97
  • 98. Observation: There is a walk from q0 to q1 with label abbbaa * q0 , abbbaa q5 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 98
  • 99. Recursive Definition * q, q • * q, wa ( * (q, w), a ) a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 99
  • 100. * q0 , ab * (q0 , a ), b * q0 , ,a ,b q0 , a , b q1 , b q2 a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 100
  • 101. Languages Accepted by DFAs • Take DFA M • Definition: – The language L M contains – all input strings accepted by M LM – = { strings that drive M to a final state} 101
  • 102. Example LM abba M • a,b q5 b a a,b a b q0 a q1 b q2 b q3 a q4 accept 102
  • 103. Another Example LM , ab, abba M • a,b q5 b a a a,b b q0 a q1 b q2 b q3 a q4 accept accept accept 103
  • 104. Formally • For a DFA Language accepted by M : LM w * : * q0 , w F M Q, , , q0 , F alphabet transition initial final function state states 104
  • 105. Observation • Language accepted by M: LM w * : * q0 , w F • Language rejected by M : LM w * : * q0 , w F 105
  • 106. More Examples n LM {a b : n 0} a a,b q0 b a,b q1 q2 accept trap state or dead state 106
  • 107. LM = { all strings with prefix ab } • a,b q0 a q1 b q2 b a accept q3 a,b 107
  • 108. L M = { all strings without substring 001 } • 1 0 0,1 1 0 1 0 00 001 0 108
  • 109. Regular Languages • A language L is regular if there is • a DFA M such that L L M • All regular languages form a language family – 109
  • 110. Example L awa : w a, b * a • The language b • is regular: b q0 a q2 q3 • b a q4 a,b 110
  • 111. Non Deterministic Automata 111
  • 112. Non Deterministic Finite Accepter M Q, , , q0 , F Q :Q 2 112
  • 113. Nondeterministic Finite Accepter (NFA) Alphabet = {a} q1 a q2 a q0 a q3 113
  • 114. Nondeterministic Finite Accepter (NFA) Alphabet = {a} Two choices q1 a q2 a q0 a q3 114
  • 115. Nondeterministic Finite Accepter (NFA) Alphabet = {a} Two choices q1 a q2 No transition a q0 a q3 No transition 115
  • 116. First Choice a a q1 a q2 a q0 a q3 116
  • 117. First Choice a a q1 a q2 a q0 a q3 117
  • 118. First Choice a a q1 a q2 a q0 a q3 118
  • 119. First Choice a a All input is consumed q1 a q2 “accept” a q0 a q3 119
  • 120. Second Choice a a q1 a q2 a q0 a q3 120
  • 121. Second Choice a a q1 a q2 a q0 a q3 121
  • 122. Second Choice a a q1 a q2 a q0 a No transition: q3 the automaton hangs 122
  • 123. Second Choice a a Input cannot be consumed q1 a q2 a q0 a q3 “reject” 123
  • 124. An NFA accepts a string: when there is a computation of the NFA that accepts the string •All the input is consumed and the automaton is in a final state 124
  • 125. An NFA rejects a string: when there is no computation of the NFA that accepts the string • All the input is consumed and the automaton is in a non final state • The input cannot be consumed 125
  • 126. Example aa is accepted by the NFA: “accept” q1 a q2 q1 a q2 a a q0 q0 a a q3 q3 “reject” because this computation accepts aa 126
  • 127. Rejection example a q1 a q2 a q0 a q3 127
  • 128. First Choice a q1 a q2 a q0 a q3 128
  • 129. First Choice a “reject” q1 a q2 a q0 a q3 129
  • 130. Second Choice a q1 a q2 a q0 a q3 130
  • 131. Second Choice a q1 a q2 a q0 a q3 131
  • 132. Second Choice a q1 a q2 a q0 a q3 “reject” 132
  • 133. Example a is rejected by the NFA: “reject” q1 a q2 q1 a q2 a a q0 q0 a a q3 “reject” q3 All possible computations lead to rejection 133
  • 134. Rejection example a a a q1 a q2 a q0 a q3 134
  • 135. First Choice a a a q1 a q2 a q0 a q3 135
  • 136. First Choice a a a q1 a q2 a q0 a No transition: the automaton hangs q3 136
  • 137. First Choice a a a Input cannot be consumed q1 a q2 “reject” a q0 a q3 137
  • 138. Second Choice a a a q1 a q2 a q0 a q3 138
  • 139. Second Choice a a a q1 a q2 a q0 a q3 139
  • 140. Second Choice a a a q1 a q2 a q0 a No transition: q3 the automaton hangs 140
  • 141. Second Choice a a a Input cannot be consumed q1 a q2 a q0 a q3 “reject” 141
  • 142. aaa is rejected by the NFA: “reject” q1 a q2 q1 a q2 a a q0 q0 a a q3 q3 “reject” All possible computations lead to rejection 142
  • 143. Language accepted: L {aa} q1 a q2 a q0 a q3 143
  • 144. Lambda →Transitions q0 a q1 q2 a q3 144
  • 145. a a q0 a q1 q2 a q3 145
  • 146. a a q0 a q1 q2 a q3 146
  • 147. (read head doesn‟t move) a a q0 a q1 q2 a q3 147
  • 148. a a q0 a q1 q2 a q3 148
  • 149. all input is consumed a a “accept” q0 a q1 q2 a q3 String aa is accepted 149
  • 150. Rejection Example a a a q0 a q1 q2 a q3 150
  • 151. a a a q0 a q1 q2 a q3 151
  • 152. (read head doesn‟t move) a a a q0 a q1 q2 a q3 152
  • 153. a a a q0 a q1 q2 a q3 No transition: the automaton hangs 153
  • 154. Input cannot be consumed a a a “reject” q0 a q1 q2 a q3 String aaa is rejected 154
  • 155. Language accepted: L {aa} q0 a q1 q2 a q3 155
  • 156. Another NFA Example q0 a q1 b q2 q3 156
  • 157. a b q0 a q1 b q2 q3 157
  • 158. a b q0 a q1 b q2 q3 158
  • 159. a b q0 a q1 b q2 q3 159
  • 160. a b “accept” q0 a q1 b q2 q3 160
  • 161. Another String a b a b q0 a q1 b q2 q3 161
  • 162. a b a b q0 a q1 b q2 q3 162
  • 163. a b a b q0 a q1 b q2 q3 163
  • 164. a b a b q0 a q1 b q2 q3 164
  • 165. a b a b q0 a q1 b q2 q3 165
  • 166. a b a b q0 a q1 b q2 q3 166
  • 167. a b a b q0 a q1 b q2 q3 167
  • 168. a b a b “accept” q0 a q1 b q2 q3 168
  • 169. Language accepted L ab, abab, ababab, ... ab q0 a q1 b q2 q3 169
  • 170. Another NFA Example 0 q0 q1 0, 1 q2 1 170
  • 171. Language accepted L(M ) = {λ, 10, 1010, 101010, ...} = {10}* 0 q0 q1 0, 1 q2 1 171
  • 172. Remarks: •The symbol never appears on the input tape •Extreme automata: M1 M2 q0 q0 L(M1 ) = {} L(M 2 ) = {λ} 172
  • 173. •NFAs are interesting because we can express languages easier than DFAs a,b NFA M1 DFA M2 q2 q0 a q1 b a,b q0 a q1 L( M1 ) = {a} L( M 2 ) = {a} 173
  • 174. Formal Definition of NFAs M Q, , , q0 , F Q : Set of states, i.e. q0 , q1, q2 : Input alphabet, i.e. a, b : Transition function q0 : Initial state F : Final states 174
  • 175. Transition Function q0 , 1 q1 0 q0 q1 0, 1 q 2 1 175
  • 176. (q1,0) {q0 , q2} 0 q0 q1 0, 1 q 2 1 176
  • 177. (q0 , ) {q0 , q2} 0 q0 q1 0, 1 q 2 1 177
  • 178. (q2 ,1) 0 q0 q1 0, 1 q 2 1 178
  • 179. Extended Transition Function * * q0 , a q1 • q4 q5 a a q0 a q1 b q2 q3 179
  • 180. * q0 , aa q4 , q5 q4 q5 a a q0 a q1 b q2 q3 180
  • 181. * q0 , ab q2 , q3 , q0 q4 q5 a a q0 a q1 b q2 q3 181
  • 182. Formally qj * qi , w It holds if and only if there is a walk from qi to q j with label w 182
  • 183. 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 ) 183
  • 184. F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 * q0 , ab q2 , q3 , q0 ab L M 184
  • 185. F q0 ,q5 q4 q5 • a a q0 a q1 b q2 q3 * q0 , abaa q4 , q5 aaba L(M ) 185
  • 186. F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 * q0 , aba q1 aba L M 186
  • 187. q4 q5 a a q0 a q1 b q2 q3 LM aa ab * ab aa 187
  • 188. Formally • The language accepted by NFA M is: LM w1, w2 , w3 ,... * (q0 , wm ) {qi , q j ,...} • where • and there is some qk F (final state) 188
  • 189. w LM * (q0 , w) • qi w qk qk F q0 w w qj 189
  • 190. Equivalence of NFAs and DFAs 190
  • 191. Equivalence of Machines • For DFAs or NFAs: • Machine M1 is equivalent to machine M 2 • if L M1 L M2 • 191
  • 192. NFA M1 L M1 {10} * 0 q0 q1 0, 1 q2 • 1 DFA M2 0,1 L M2 {10}* 0 q0 q1 1 q2 1 0 192
  • 193. • Since L M1 L M2 10 * • machines M1 and M 2are equivalent 0 NFA M1 q0 q1 0, 1 q2 1 0,1 0 DFA M2 q0 q1 1 q2 1 0 193
  • 194. Equivalence of NFAs and DFAs Question: NFAs = DFAs ? Same power? Accept the same languages? 194
  • 195. Equivalence of NFAs and DFAs Question: NFAs = DFAs ? YES! Same power? Accept the same languages? 195
  • 196. We will prove: Languages Languages accepted accepted by NFAs by DFAs NFAs and DFAs have the same computation power 196
  • 197. Step 1 Languages Languages accepted accepted by NFAs by DFAs Proof: Every DFA is trivially an NFA A language accepted by a DFA is also accepted by an NFA 197
  • 198. Step 2 Languages Languages accepted accepted by NFAs by DFAs Proof: Any NFA can be converted to an equivalent DFA A language accepted by an NFA is also accepted by a DFA 198
  • 199. NFA to DFA NFA M a q0 a q1 q2 • b DFA M q0 199
  • 200. NFA M a q0 a q1 q2 • b DFA M q0 a q1, q2 200
  • 201. NFA M a q0 a q1 q2 • b DFA M q0 a q1, q2 b 201
  • 202. NFA M a q0 a q1 q2 • b a DFA M q0 a q1, q2 b 202
  • 203. NFA M a q0 a q1 q2 • b b a DFA M q0 a q1, q2 b 203
  • 204. NFA M a q0 a q1 q2 • b b a DFA M q0 a q1, q2 b a, b 204
  • 205. NFA M a LM L(M ) q0 a q1 q2 • b a DFA M b q0 a q1, q2 b a, b 205
  • 206. NFA to DFA: Remarks • We are given an NFA M • We want to convert it to an equivalent DFA M LM L(M ) 206
  • 207. • If the NFA has states q0 , q1, q2 ,... • the DFA has states in the power set • , q0 , q1 , q1, q2 , q3 , q4 , q7 ,.... 207
  • 208. Procedure NFA to DFA • • 1. Initial state of NFA: q0 • • Initial state of DFA: q0 208
  • 209. NFA M a q0 a q1 q2 • b DFA M q0 209
  • 210. 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} • ... {qi , q j ,..., qm}, a {qi , q j ,..., qm} • 210 Add transition to DFA
  • 211. NFA M a q0 a q1 q2 • b * (q0 , a ) {q1, q2 } DFA M q0 a q1, q2 q0 , a q1, q2 211
  • 212. Procedure NFA to DFA • Repeat Step 2 for all letters in alphabet, • until • no more transitions can be added. 212
  • 213. NFA M a q0 a q1 q2 • b b a DFA M q0 a q1, q2 b a, b 213
  • 214. Procedure NFA to DFA • 3. For any DFA state {qi , q j ,..., qm} • If some q j is a final state in the NFA • Then, {qi , q j ,..., qm } • 214 is a final state in the DFA
  • 215. NFA M a q0 a q1 q2 q1 F • b a DFA M b q0 a q1, q2 b q1, q2 F a, b 215
  • 216. Theorem Take NFA M • Apply procedure to obtain DFA M Then M and M are equivalent : LM LM 216
  • 217. Finally We have proven Languages Languages accepted accepted by NFAs by DFAs 217
  • 218. We have proven Languages Languages accepted accepted by NFAs by DFAs Regular Languages 218
  • 219. We have proven Languages Languages accepted accepted by NFAs by DFAs Regular Languages Regular Languages 219
  • 220. We have proven Languages Languages accepted accepted by NFAs by DFAs Regular Languages Regular Languages Thus, NFAs accept the regular languages 220
  • 221. Single Final State for NFAs and DFAs 221
  • 222. Observation • Any Finite Automaton (NFA or DFA) • can be converted to an equivalent NFA • with a single final state 222
  • 223. Example a NFA a b b a Equivalent NFA a b b 223
  • 224. In General NFA Equivalent NFA Single final state 224
  • 225. Extreme Case NFA without final state Add a final state Without transitions 225
  • 226. Some Properties of Regular Languages 226
  • 227. properties For regular languages L1 and L 2 we will prove that: Union: L1 L2 Concatenation: L1L2 Are regular Languages Star: L1 * 227
  • 228. We Say: Regular languages are closed under Union: L1 L2 Concatenation: L1L2 Star: L1 * 228
  • 229. Properties For regular languages L1 and L2 we will prove that: Union: L1 L2 Are regular Concatenation: L1L2 Languages Star: L1 * 229
  • 230. Regular language L1 Regular language L2 L M1 L1 L M2 L2 NFA M1 NFA M2 Single final state Single final state 230
  • 231. Example a n M1 L1 {a b} b M2 L2 ba b a 231
  • 232. L1 L2 Union M1 • NFA for M2 232
  • 233. n L1 L2 {a b} {ba} NFA for n • L1 {a b} a b L2 {ba} b a 233
  • 234. Concatenation L1L2 • NFA for M1 M2 234
  • 235. Example n n L1L2 {a b}{ba} {a bba} • • NFA for n L1 {a b} a L2 {ba} b b a 235
  • 236. Star Operation • NFA for L * 1 L1 * M1 236
  • 237. Example n L1* {a b} * • NFA for n L1 {a N>=} b0 a b 237
  • 238. Procedure: NFA to DFA 1 Create a graph with vertex {q0}.Identify this vertex as initial vertex of DFA. 2 Repeat the following steps until no more edges are missing.Take any vertex {qi,qj,….qk} of G that has no outgoing edge for some symbol a of the alphabet. Compute *(qi, a), * (qj, a)…. *(qk, a) Then form the union of all these yielding the set * {ql, qm, …qn}. Create a vertex for G labeled {ql, qm,…qn} if it does not already exist. Add to G an edge from {qi, qj,…qk} to {ql,qm…qn} and label it with a. 3 Every state of G whose label contains any qf of F is identified as a final vertex of DFA. 4 If NFA accepts then vertex {q0} in G is also made a 238 final vertex.
  • 239. 1 0 q0 q1 q2 0,1 0,1 239
  • 240. Start Equivalent q0 1 0 DFA q {q0, 1 q1} 1 0,1 1 q2 0 0,1 0 q0,q1,q2 1 q1,q2 0 0,1 240