SlideShare una empresa de Scribd logo
1 de 94
Non
Deterministic
 Automata
  This ppt covers 2.2 ~ 2.4.


                   NFA         1
Nondeterministic FA
   As we know, any w *, then *(q0, w)
    corresponds to a unique walk on the
    transition graph of a DFA M.

   When we allow FA to act non-
    deterministically, it implies *(q0, w) may
    not correspond to a unique walk on the
    transition graph of such FA anymore.

                                                 2
Nondeterministic Finite Accepter
            (NFA)
  = {a}


           q1 a    q2
       a
  q0
       a
           q3

                                   3
Nondeterministic Finite Accepter
               (NFA)
     = {a}
More than one choices
                 q1 a     q2
             a
      q0
             a
                 q3     (q0, a ) = {q1, q3 }

                                               4
Nondeterministic Finite Accepter
            (NFA)
  = {a}                   No transition!


            q1 a          q2
       a
  q0
       a
            q3
       i.e., (q2, a ) =        = (q3, a )
                                            5
Nondeterministic Finite Accepter
               (NFA)
Consider input string aa :

              q1 a    q2
          a
     q0
          a
              q3
 There are two computations!
                                      6
Example
            q1 a   q2                  q1 a   q2
        a                          a
   q0                         q0
        a                          a
            q3                         q3

All input is consumed &   No transition for (q3, a),
stops at a final state.   the automaton hangs, a
                          dead configuration
 aa is “accepted”         aa is “rejected”

                                                       7
An NFA accepts a string:
 when there is one computation of the NFA
 that accepts the string

             such that

all the input is consumed AND
the automaton is in a final state

Thus aa is “accepted” by the NFA.
                                       8
Therefore, 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
             OR
• The input cannot be consumed
  (dead configuration)
                                          9
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
                                               10
Another Example
aaa is rejected by the NFA:
                        No transition:
               “reject” the automaton hangs
          q1 a   q2                    q1 a   q2
      a                            a
 q0                           q0
      a                            a

                                            “reject”
          q3                           q3



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


           q1 a      q2
      a
 q0
      a
           q3

                              12
Another NFA Example




     transition is allowed for NFA


q0     a     q1   b     q2           q3



                                          13
transition is allowed for NFA

It implies that the NFA can move from
state qi to state qj without moving the
read head, i.e. without consuming any
input symbol.



                                          14
Another NFA Example
Consider the input string ab:
 q0 a q1       b   q2   ab is “accepted”
 q0   a   q1   b   q2   q3    “rejected”
 q0 a q1       b   q2   q3   q0   “rejected”

  q0       a       q1   b    q2        q3



                                               15
Another String

a b a b




 q0   a     q1   b    q2   q3


                                16
a b a b

q0   a    q1   b   q2        q3    q0   a   q1   b   q2

                                  “accept”

     q0        a        q1    b      q2              q3


                                                          17
Language accepted

     L       ab, abab, ababab, ...
             ab


q0       a        q1   b   q2        q3



                                          18
Another NFA Example




       0
  q0       q1   0, 1 q2
       1


                          19
Language accepted

L(M ) = {λ, 10, 1010, 101010, ...}
      = {10}*
                            (redundant state,
           0                i.e. useless state)
   q0          q1   0, 1 q2
           1


                                             20
NFAs are interesting because we can
express languages easier than DFAs

Example: design a FA for {a} with   ={a}.


Example: design a FA for
       {awa: w {a, b}*} with    ={a, b}.



                                            21
Formal Definition of NFAs (p.49)
    M Q, , , q0 , F

Q : Set of states,    Remember:
                      The     is not a symbol,
  : Input alphabet,   it never appears on the

  : Transition function
q0 : Initial state

F : Final states
                                                 22
NFA’s Transition Function
           :Qx(          { })        2Q


        Note that Every DFA is an NFA.


When input is , the original state is always a
member of its transition output, i.e. q   (q, )


                                                  23
NFA’s Transition Function
 :Qx(              { })        2Q

 q0 , 1       q1
          0
 q0                q1   0, 1   q2
          1




                                    24
NFA’s Transition Function
 :Qx(         { })       2Q
      (q1,0) {q0 , q2}

        0
 q0          q1   0, 1   q2
         1




                              25
NFA’s Transition Function
 :Qx(         { })        2Q
      (q0 , ) {q0 , q2}

         0
 q0          q1   0, 1    q2
         1




                               26
:Qx(       { })       2Q
  (q2 ,1)     . So as   (q0, 0) &   (q2, 0)



         0
  q0         q1     0, 1     q2
         1


Remark: Every DFA is an NFA.

                                              27
Extended Transition
     Function   *
Similar as DFA, extended transition function is
defined to work with inputs to be strings.
          *
           :Qx(          { } )*    2Q
                     *
    or simply         :Qx *         2Q
 When input string is empty ( ), the original state
 is always a member of its extended transition, i.e.
                         q     * q,
                                                       28
Extended Transition
Function *

       * q0 , a        q1

        q4         q5
             a a
  q0    a    q1    b        q2   q3

                                      29
* q0 , aa        q4 , q5


      q4         q5
           a a
q0   a     q1    b      q2      q3

                                     30
* q0 , ab    ?


     q4          q5
           a a
q0   a      q1   b    q2   q3

                                31
* q0 , ab      q2 , q3 , q0


        q4         q5
             a a
q0     a     q1    b     q2        q3

                                        32
* q0 , b    ?


     q4         q5
          a a
q0   a     q1   b    q2   q3

                               33
Consider the transition graph:

     a                     *     a
q0                        q0

q1                        q1

q2                        q2



              a
         q0       q1           q2
                                     34
Formally, for an NFA
There is a walk from qi to q j with                        label
                                              w        1       2   ...       k
   qi                    w                     qj

if and only if q j               * qi , w       w          1       2   ...       k

                    qi    1        2                                   k
                                                                           qj

        Def. 2.5 p.51
        For an nfa, the extended transition function is
        defined so that qj     *( qi , w) iff there is a walk
        in the transition graph from qi to qj labeled w.
                                                                                 35
Hw # 20 p.56

   Show that for any nfa

       *
           (q, wv)       
                         *
                                    *
                                        ( p, v).
                     p       ( q , w)


     for all q Q, and all w, v              *




                                                   36
The Language of an NFA                             M
aa
F      q0 ,q5            q4           q5
                                a a
                 q0     a       q1       b    q2        q3


Consider the aa, or the walk from q0 with label
aa:
     * q0 , aa        q4 , q5                aa L(M )
                                     F                       37
ab
F     q0 ,q5          q4           q5
                           a a
               q0    a     q1      b        q2   q3




     * q0 , ab      q2 , q3 , q0            ab L M
                                        F             38
abaa
F      q0 ,q5         q4         q5
                           a a
                q0   a     q1    b      q2    q3




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




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



LM              (ab) n aa : n 0

                                       41
Formally
The language accepted by NFA     M is:
        LM          w1, w2 , w3 ,...

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


and there is some     qk     F (final state)
                                                    42
w LM                    * (q0 , w)
                           qi
              w
                           qk             qk   F
         q0   w
                   w       qj

L( M )   {w       *:   * ( q0, w)     F        }
                                                   43
An NFA Example
Consider the input string ab:
 q0   a   q1   b   q2       * (q0 , ab) {q0 , q2 , q3}
 q0   a   q1   b   q2   q3
 q0   a   q1   b   q2   q3      q0

q0        a        q1   b      q2           q3



                                                    44
Consider the input string ab:
       * (q0 , ab) {q0 , q2 , q3}
   q0   a   q1   b   q2 ab is “accepted”
   q0   a   q1   b   q2   q3
   q0   a   q1   b   q2   q3   q0

  q0        a        q1   b    q2      q3



                                            45
Another String

a b a b




 q0   a     q1   b    q2   q3


                                46
q0    a   q1   b   q2    q3   q0   a   q1   b   q2

As long as there is one computation that
consumes all input symbols and stops at a final
state, aabb is accepted.
                          “accept”

    q0        a        q1   b    q2                q3


                                                        47
Language accepted

     L       ab, abab, ababab, ...
             ab


q0       a        q1   b   q2        q3



                                          48
NFAs are interesting because we can
express languages easier than DFAs

Example: design an FA for {a} with   ={a, b}.


Example: design an FA for
       {awa: w {a, b}*} with     ={a, b}.



                                            49
Consider the transition graph:

     a                     *     a
q0                        q0

q1                        q1

q2                        q2



              a
         q0       q1           q2
                                     50
Hw # 20 p.56

   Show that for any nfa

       *
           (q, wv)       U
                         *
                                    *
                                        ( p, v).
                     p       ( q , w)


     for all q Q, and all w, v              *




                                                   51
Remarks for FA M = {Q, , , q0, F }:
•The       symbol never appears on the
 input alphabet

•Simple NFA:

     M1                         M2
     q0                         q0

L(M1 ) = {}               L(M 2 ) = {λ}
                                          52
The language accepted by NFA               M is:
 L( M )      {w        *:      * ( q0, w)    F          }

Is it true that for any NFA        M  ,

 L(M )       {w        *:     * ( q0, w)    F       }

Is it true that for any NFA         M,
L(M )     {w      *:        * (q0, w) (Q F )            }
        Referring to Hw 2.3 # 5, 6. P.62                    53
NFAs accept the
 Regular Languages
Hw of 2.2(p.54)   1 – 19         not hand in



                           NFA                 54
Equivalence of Machines

Definition for Automata:

Machine     M1 is equivalent to machine M 2
if   L M1     L M2


                                              55
Example of equivalent
                   machines
                                     0
L M1   {10} *
                           q0            q1
                NFA   M1             1
                                              0,1
                           0
L M2   {10}*                    q1       1    q2
                  q0
                           1
            DFA   M2             0
                                                   56
Which is more powerful?

 Every dfa is an nfa.
 Thus, every language accepted by
   a dfa is also accepted by an nfa.
 Is nfa more powerful than dfa?




                                       57
We will prove:


  Languages
                           Regular
  accepted
                           Languages
  by NFAs
                               Languages
                               accepted
                               by DFAs
NFAs and DFAs have the
same computation power
                                           58
Step 1


  Languages
                          Regular
  accepted
                          Languages
  by NFAs

Proof: Every DFA is trivially an NFA


       Any language L accepted by a DFA
       is also accepted by an NFA
                                          59
Step 2


  Languages
                        Regular
  accepted
                        Languages
  by NFAs

Proof: Any NFA can be converted to an
       equivalent DFA

       Any language L accepted by an NFA
       is also accepted by a DFA        60
Convert NFA to DFA
                                 a
NFA M N   q0        a       q1       q2
                                 b
               *        a        b
               q0
               q1
               q2

          An extended transition
          function is very helpful
                                          61
Convert NFA to DFA
NFA M N                        a
            q0     a      q1              q2
                               b

            Let p0={q0} be the initial state for MD
DFA   MD
           q0
                                    Back to Procedure NFA to DFA




                                                                   62
Convert NFA to DFA
NFA M N                        a
                q0   a    q1          q2
                               b

            Now, define D(p0,a) for a
DFA   MD     D(p0,a) = N*({q0},a) ={q1,q2} p1


           q0        a
                            q1, q2


                                                63
Convert NFA to DFA
NFA M N                                 a
                q0       a         q1                 q2
                                        b
                     D(p0,b)   =   N*({q0},b)      =         p2
DFA   MD
           q0            a
                                    q1, q2
                     b

                                             Back to Procedure NFA to DFA

                                                                            64
Convert NFA to DFA
NFA M N                                  a
                q0        a       q1                q2
                                         b
           D(p1,a)   =   N*({q1,q2},a)=      N*({q1},a)   N*({q2},a)
       = {q1,q2}          = {q1,q2} = p1
DFA   MD                                              a
           q0             a
                                    q1, q2
                     b

                                                                  65
Convert NFA to DFA
NFA M N                             a
                 q0       a    q1              q2
                                    b
            D(p1,b)
                  = N*({q1,q2},b) =     N*({q1},b)   N*({q2},b)
           = {q0} {q0} = {q0} = p0
DFA   MD                   b                   a
            q0            a
                                q1, q2
                      b

                                                            66
Convert NFA to DFA
NFA M N                                 a
                q0        a        q1                 q2
                                         b
           D(p2,a)   =   N*(   ,a) =    =p2=    D(p2,b)

DFA   MD                  b                           a

           q0            a
                                       q1, q2
                     b
                                                Back to Procedure NFA to DFA

                                         a, b
                                                                               67
Convert NFA to DFA
NFA M N                            a
                q0       a    q1           q2
                                   b
 How about final state?        Lastly, check if          L(M)
                          b                a
DFA   MD
           q0            a
                               q1, q2
                     b
                                   a, b           back
                                                                68
NFA to DFA: Remarks

   We are given an NFA MN


   We want to convert it
    to an equivalent DFA MD


   With L M N     L( M D )
                              69
   If the NFA has states

                 q0 , q1, q2 ,...

   the DFA has states in the powerset


       , q0 , q1 , q1, q2 , q3 , q4 , q7 ,....

                                                 70
Procedure NFA to DFA p.59

1.   Initial state of NFA:    q0



     Initial state of DFA:   p0          q0
                             To Conversion Example



                                                     71
Procedure NFA to DFA
2. For every DFA’s state pk {qi , q j ,..., qm }

    Compute in the NFA
               * qi , a ,
               * q j,a ,      union       {qi , q j ,..., qm}
             ...
    Add transition to DFA                         To Convertion Example



D   pk , a          D   {qi , q j ,..., qm }, a    {qi , q j ,..., qm }
                                                                          72
Procedure NFA to DFA

 Repeat Step 2 for all letters in alphabet,
                 until
 no more transitions can be added.
Remark:
In DFA, every vertex must have exactly | | outgoing
edges, each labeled with a different element of .
                                     To Convertion Example


                                                             73
Procedure NFA to DFA
3. For any DFA state pk {qi , q j ,..., qm }

   If some   q j is a final state in the NFA

   Then, make    p k a final state in the DFA

Remark: If       is accepted in the NFA then
         p0       q0    should be a final state.
                                     To Convertion Example
                                                             74
Theorem
Take NFA    MN

Apply procedure to obtain DFA   MD

Then   MN    and   MD   are equivalent :


            L(MN) = L(MD)
                                           75
Proof

       L(MN) = L(MD)


L(MN) L(MD
         )   AND     L(MN) L(MD
                              )


                                  76
First we show:   L(MN) L(MD
                          )

    Take arbitrary:   w L(MN)


     We will prove:   w L(MD)



                                77
w L(MN)




MN   q0           w                     qf


              w   1   2   ...   k

MN   q0   1   2                     k
                                        qf

                                             78
We will show that if    w L(MN)
                  w     1   2   ...   k


MN     q0     1   2                       k
                                              qf




              1   2                       k
MD
       {q0}                               {q f ,...}
                      w L(MD)
                                                       79
More generally, we will show that if in                              MN :
  (arbitrary walk) v                       a1a2 ... an
                a1           a2                                an
 MN      q0            qi         qj                     ql         qm




               a1           a2                                an
 MD
        {q0}        {qi ,...} {q j ,...}           {ql ,...} {qm ,...}

                                                                            80
Proof by induction on             |v|

Induction Basis:      v          a1


                           a1
           MN       q0            qi

                          a1
           MD
                   {q0}        {qi ,...}

                                                 81
Induction hypothesis:               1 |v| k
                        v     a1a2 ... ak

              a1        a2                  ak
MN     q0          qi        qj        qc        qd



             a1         a2                  ak
MD
      {q0}    {qi ,...} {q j ,...}   {qc ,...} {qd ,...}

                                                           82
Induction Step:             |v| k 1
      v      a1a2 ... ak ak               1      v ak     1
                       v


                  a1        a2                       ak
 MN        q0          qi        qj             qc        qd


                                    v
                 a1         a2                       ak
 MD
          {q0}    {qi ,....} {q j ,...}       {qc ,...} {qd ,...}


                                    v                               83
Induction Step:                |v| k 1
      v      a1a2 ... ak ak                  1     v ak      1
                         v


                  a1           a2                       ak        ak 1
 MN        q0            qi         qj            qc         qd          qe

                                        v
                 a1           a2                        ak         ak 1
 MD
          {q0}        {qi ,...} {q j ,...}       {qc ,...} {qd ,...} {qe ,...}

                                       v                                         84
Therefore if         w L(MN)
                 w        1   2   ...   k

MN     q0    1        2                      k
                                                 qf




             1        2                      k
 MD
      {q0}                                  {q f ,...}
                          w L(MD)
                                                         85
We have shown:   L(MN) L(MD
                          )


We also need to show:   L(MN) L(MD
                                 )
       (proof is similar)



                                     86
Example
           a                                b
NFA
           q0      , a, b    q1      a, b   q2

Convert NFA to DFA                Simplified version of DFA
            a                               a

       a    p1                              p1
                            b a, b                  a, b
  p0           b                                b
       b    p2 a, b p3 a p4                 p2 a, b p3

       Ex. 2.13 Fig. 2.14 (p.59)– in class (you
       can eliminate the redundant state first)            87
Minimal DFAs

   A dfa M’ is minimal if M is also a dfa such
    that L(M’)=L(M) then |QM | |QM’|




                                              88
Minimal DFAs

   States p and q are called indistinguishable if
               * ( p, w) F implies          * (q, w) F
      and
                * ( p, w) F implies         * (q, w) F
         for all w      *

   States p and q are called distinguishable if
     w      * such that   * ( p, w) F and     * (q, w) F
                                                           89
Minimal DFAs
   To obtain a minimal DFA M’ from a given DFA M:
       Remove all inaccessible states, i.e. not reachable from the
        initial state.
       Reduce states until it has no more indistinguishable states.


   Read procedures: mark (p.64) & reduce (p.66), and
    theorem 2.3 (p.65) & 2.4 (p.67) for details.
         Remove all inaccessible states can be accomplished
         by enumerating all simple paths of the graph of the
         dfa starting at the initial state, any state not part of
         some path is inaccessible.                                    90
Example: Minimal DFAs

             q1           0,1
     0                1
         0        0
q0           q2       1   q4
              0       1
     1                     0
             q3           q5
                      1




                                91
Minimal DFAs
Prove or Disprove:
 If M = (Q, , , q0, F) is a minimal DFA for a
  regular language L, then M’ = (Q, , , q0, Q-F)
  is a minimal DFA for the complement of L.




                                                   92
Minimal DFAs
   Prove or Disprove:
   If M = (Q, , , q0, F) is a minimal DFA for a
    regular language L, then      M’ = (Q, , , q0,
    Q-F) is a minimal DFA for the complement of
    L.




                                                     93
Homework Discussion
   2.3 (p.62) Discuss 7, 8, 11, 14, 15



                     Homework
     2.3 (p.62) 1 ~15 & 2.4 (p.68) 1, 2, 4, 6
     Hand in: 3, 5, 6, 9, 12 (p.62) & 2ae (p.68)



                                                   94

Más contenido relacionado

La actualidad más candente

Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfaAbdul Aziz
 
Logic design alexander1 christopher
Logic design alexander1  christopherLogic design alexander1  christopher
Logic design alexander1 christopherworld_chris
 
Sequentialcircuits
SequentialcircuitsSequentialcircuits
SequentialcircuitsRaghu Vamsi
 
Continuous variables quantum cryptography
Continuous variables quantum cryptographyContinuous variables quantum cryptography
Continuous variables quantum cryptographywtyru1989
 
B sc3 unit 5 sequencial lc
B sc3 unit 5 sequencial lcB sc3 unit 5 sequencial lc
B sc3 unit 5 sequencial lcMahiboobAliMulla
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Class8
 Class8 Class8
Class8issbp
 
Clk-to-q delay, library setup and hold time
Clk-to-q delay, library setup and hold timeClk-to-q delay, library setup and hold time
Clk-to-q delay, library setup and hold timeVLSI SYSTEM Design
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic CircuitRamasubbu .P
 
B sc cs i bo-de u-iv sequential circuit
B sc cs i bo-de u-iv sequential circuitB sc cs i bo-de u-iv sequential circuit
B sc cs i bo-de u-iv sequential circuitRai University
 

La actualidad más candente (20)

Week5 lec1-bscs1
Week5 lec1-bscs1Week5 lec1-bscs1
Week5 lec1-bscs1
 
Lec 3 ---- dfa
Lec 3  ---- dfaLec 3  ---- dfa
Lec 3 ---- dfa
 
Logic design alexander1 christopher
Logic design alexander1  christopherLogic design alexander1  christopher
Logic design alexander1 christopher
 
Sr Latch or Flip Flop
Sr Latch or Flip FlopSr Latch or Flip Flop
Sr Latch or Flip Flop
 
12 latches
12 latches12 latches
12 latches
 
Sequentialcircuits
SequentialcircuitsSequentialcircuits
Sequentialcircuits
 
Continuous variables quantum cryptography
Continuous variables quantum cryptographyContinuous variables quantum cryptography
Continuous variables quantum cryptography
 
B sc3 unit 5 sequencial lc
B sc3 unit 5 sequencial lcB sc3 unit 5 sequencial lc
B sc3 unit 5 sequencial lc
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Latches
LatchesLatches
Latches
 
discrete-hmm
discrete-hmmdiscrete-hmm
discrete-hmm
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Ssmboost
SsmboostSsmboost
Ssmboost
 
Class8
 Class8 Class8
Class8
 
Clk-to-q delay, library setup and hold time
Clk-to-q delay, library setup and hold timeClk-to-q delay, library setup and hold time
Clk-to-q delay, library setup and hold time
 
Group 10 flip flop and rs latch 1
Group 10 flip flop and rs latch 1Group 10 flip flop and rs latch 1
Group 10 flip flop and rs latch 1
 
Lect26 Engin112
Lect26 Engin112Lect26 Engin112
Lect26 Engin112
 
Sequential Logic Circuit
Sequential Logic CircuitSequential Logic Circuit
Sequential Logic Circuit
 
B sc cs i bo-de u-iv sequential circuit
B sc cs i bo-de u-iv sequential circuitB sc cs i bo-de u-iv sequential circuit
B sc cs i bo-de u-iv sequential circuit
 

Destacado

CloudE: Standards of Excellence for Ethernet Cloud Connections
CloudE: Standards of Excellence for Ethernet Cloud ConnectionsCloudE: Standards of Excellence for Ethernet Cloud Connections
CloudE: Standards of Excellence for Ethernet Cloud ConnectionsBusiness Cable Collaboration Group
 
slimmer werken wintercourse
slimmer werken wintercourseslimmer werken wintercourse
slimmer werken wintercoursegueste3d816
 
Os5 2
Os5 2Os5 2
Os5 2issbp
 
Client server
Client serverClient server
Client serverJoy Das
 
Building for success and failure with Disqus
Building for success and failure with DisqusBuilding for success and failure with Disqus
Building for success and failure with DisqusJonathon Hill
 
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)David Gómez García
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systemsissbp
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your BusinessBarry Feldman
 

Destacado (9)

CloudE: Standards of Excellence for Ethernet Cloud Connections
CloudE: Standards of Excellence for Ethernet Cloud ConnectionsCloudE: Standards of Excellence for Ethernet Cloud Connections
CloudE: Standards of Excellence for Ethernet Cloud Connections
 
slimmer werken wintercourse
slimmer werken wintercourseslimmer werken wintercourse
slimmer werken wintercourse
 
Os5 2
Os5 2Os5 2
Os5 2
 
Client server
Client serverClient server
Client server
 
Building for success and failure with Disqus
Building for success and failure with DisqusBuilding for success and failure with Disqus
Building for success and failure with Disqus
 
System Unit
System UnitSystem Unit
System Unit
 
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
 
Ch11 input output systems
Ch11 input output systemsCh11 input output systems
Ch11 input output systems
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
 

Similar a Class3

FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).pptssuser47f7f2
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.pptRohitPaul71
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automataahmad haidaroh
 
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 1Abhimanyu Mishra
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxamara jyothi
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxranjan317165
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examplesankitamakin
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsRushabh2428
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Akila Krishnamoorthy
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAkila Krishnamoorthy
 
95414579 flip-flop
95414579 flip-flop95414579 flip-flop
95414579 flip-flopKyawthu Koko
 

Similar a Class3 (20)

Automata
AutomataAutomata
Automata
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Lecture03 (1).ppt
Lecture03 (1).pptLecture03 (1).ppt
Lecture03 (1).ppt
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automata
 
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
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
NFAvsDFA.ppt
NFAvsDFA.pptNFAvsDFA.ppt
NFAvsDFA.ppt
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
Pda
PdaPda
Pda
 
Finite automata
Finite automataFinite automata
Finite automata
 
PDA (1) (1).pptx
PDA (1) (1).pptxPDA (1) (1).pptx
PDA (1) (1).pptx
 
Automata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA ConversionAutomata theory - NFA ε to DFA Conversion
Automata theory - NFA ε to DFA Conversion
 
95414579 flip-flop
95414579 flip-flop95414579 flip-flop
95414579 flip-flop
 
TuringMachines.ppt
TuringMachines.pptTuringMachines.ppt
TuringMachines.ppt
 

Más de issbp

Os10 2
Os10 2Os10 2
Os10 2issbp
 
Os10
Os10Os10
Os10issbp
 
Os9 2
Os9 2Os9 2
Os9 2issbp
 
Os8 2
Os8 2Os8 2
Os8 2issbp
 
Os7 2
Os7 2Os7 2
Os7 2issbp
 
Os6 2
Os6 2Os6 2
Os6 2issbp
 
Os4 2
Os4 2Os4 2
Os4 2issbp
 
Os3 2
Os3 2Os3 2
Os3 2issbp
 
Os2 2
Os2 2Os2 2
Os2 2issbp
 
Class9
 Class9 Class9
Class9issbp
 
Class7
 Class7 Class7
Class7issbp
 
Class6
 Class6 Class6
Class6issbp
 

Más de issbp (20)

Os10 2
Os10 2Os10 2
Os10 2
 
Os10
Os10Os10
Os10
 
Os9 2
Os9 2Os9 2
Os9 2
 
Os9
Os9Os9
Os9
 
Os8 2
Os8 2Os8 2
Os8 2
 
Os8
Os8Os8
Os8
 
Os7 2
Os7 2Os7 2
Os7 2
 
Os7
Os7Os7
Os7
 
Os6 2
Os6 2Os6 2
Os6 2
 
Os6
Os6Os6
Os6
 
Os5
Os5Os5
Os5
 
Os4 2
Os4 2Os4 2
Os4 2
 
Os4
Os4Os4
Os4
 
Os3 2
Os3 2Os3 2
Os3 2
 
Os3
Os3Os3
Os3
 
Os2 2
Os2 2Os2 2
Os2 2
 
Os2
Os2Os2
Os2
 
Class9
 Class9 Class9
Class9
 
Class7
 Class7 Class7
Class7
 
Class6
 Class6 Class6
Class6
 

Class3

  • 1. Non Deterministic Automata This ppt covers 2.2 ~ 2.4. NFA 1
  • 2. Nondeterministic FA  As we know, any w *, then *(q0, w) corresponds to a unique walk on the transition graph of a DFA M.  When we allow FA to act non- deterministically, it implies *(q0, w) may not correspond to a unique walk on the transition graph of such FA anymore. 2
  • 3. Nondeterministic Finite Accepter (NFA) = {a} q1 a q2 a q0 a q3 3
  • 4. Nondeterministic Finite Accepter (NFA) = {a} More than one choices q1 a q2 a q0 a q3 (q0, a ) = {q1, q3 } 4
  • 5. Nondeterministic Finite Accepter (NFA) = {a} No transition! q1 a q2 a q0 a q3 i.e., (q2, a ) = = (q3, a ) 5
  • 6. Nondeterministic Finite Accepter (NFA) Consider input string aa : q1 a q2 a q0 a q3 There are two computations! 6
  • 7. Example q1 a q2 q1 a q2 a a q0 q0 a a q3 q3 All input is consumed & No transition for (q3, a), stops at a final state. the automaton hangs, a dead configuration aa is “accepted” aa is “rejected” 7
  • 8. An NFA accepts a string: when there is one computation of the NFA that accepts the string such that all the input is consumed AND the automaton is in a final state Thus aa is “accepted” by the NFA. 8
  • 9. Therefore, 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 OR • The input cannot be consumed (dead configuration) 9
  • 10. 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 10
  • 11. Another Example aaa is rejected by the NFA: No transition: “reject” the automaton hangs q1 a q2 q1 a q2 a a q0 q0 a a “reject” q3 q3 All possible computations lead to rejection 11
  • 12. Language accepted: L {aa} q1 a q2 a q0 a q3 12
  • 13. Another NFA Example transition is allowed for NFA q0 a q1 b q2 q3 13
  • 14. transition is allowed for NFA It implies that the NFA can move from state qi to state qj without moving the read head, i.e. without consuming any input symbol. 14
  • 15. Another NFA Example Consider the input string ab: q0 a q1 b q2 ab is “accepted” q0 a q1 b q2 q3 “rejected” q0 a q1 b q2 q3 q0 “rejected” q0 a q1 b q2 q3 15
  • 16. Another String a b a b q0 a q1 b q2 q3 16
  • 17. a b a b q0 a q1 b q2 q3 q0 a q1 b q2 “accept” q0 a q1 b q2 q3 17
  • 18. Language accepted L ab, abab, ababab, ... ab q0 a q1 b q2 q3 18
  • 19. Another NFA Example 0 q0 q1 0, 1 q2 1 19
  • 20. Language accepted L(M ) = {λ, 10, 1010, 101010, ...} = {10}* (redundant state, 0 i.e. useless state) q0 q1 0, 1 q2 1 20
  • 21. NFAs are interesting because we can express languages easier than DFAs Example: design a FA for {a} with ={a}. Example: design a FA for {awa: w {a, b}*} with ={a, b}. 21
  • 22. Formal Definition of NFAs (p.49) M Q, , , q0 , F Q : Set of states, Remember: The is not a symbol, : Input alphabet, it never appears on the : Transition function q0 : Initial state F : Final states 22
  • 23. NFA’s Transition Function :Qx( { }) 2Q Note that Every DFA is an NFA. When input is , the original state is always a member of its transition output, i.e. q (q, ) 23
  • 24. NFA’s Transition Function :Qx( { }) 2Q q0 , 1 q1 0 q0 q1 0, 1 q2 1 24
  • 25. NFA’s Transition Function :Qx( { }) 2Q (q1,0) {q0 , q2} 0 q0 q1 0, 1 q2 1 25
  • 26. NFA’s Transition Function :Qx( { }) 2Q (q0 , ) {q0 , q2} 0 q0 q1 0, 1 q2 1 26
  • 27. :Qx( { }) 2Q (q2 ,1) . So as (q0, 0) & (q2, 0) 0 q0 q1 0, 1 q2 1 Remark: Every DFA is an NFA. 27
  • 28. Extended Transition Function * Similar as DFA, extended transition function is defined to work with inputs to be strings. * :Qx( { } )* 2Q * or simply :Qx * 2Q When input string is empty ( ), the original state is always a member of its extended transition, i.e. q * q, 28
  • 29. Extended Transition Function * * q0 , a q1 q4 q5 a a q0 a q1 b q2 q3 29
  • 30. * q0 , aa q4 , q5 q4 q5 a a q0 a q1 b q2 q3 30
  • 31. * q0 , ab ? q4 q5 a a q0 a q1 b q2 q3 31
  • 32. * q0 , ab q2 , q3 , q0 q4 q5 a a q0 a q1 b q2 q3 32
  • 33. * q0 , b ? q4 q5 a a q0 a q1 b q2 q3 33
  • 34. Consider the transition graph: a * a q0 q0 q1 q1 q2 q2 a q0 q1 q2 34
  • 35. Formally, for an NFA There is a walk from qi to q j with label w 1 2 ... k qi w qj if and only if q j * qi , w w 1 2 ... k qi 1 2 k qj Def. 2.5 p.51 For an nfa, the extended transition function is defined so that qj *( qi , w) iff there is a walk in the transition graph from qi to qj labeled w. 35
  • 36. Hw # 20 p.56  Show that for any nfa * (q, wv)  * * ( p, v). p ( q , w) for all q Q, and all w, v * 36
  • 37. The Language of an NFA M aa F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 Consider the aa, or the walk from q0 with label aa: * q0 , aa q4 , q5 aa L(M ) F 37
  • 38. ab F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 * q0 , ab q2 , q3 , q0 ab L M F 38
  • 39. abaa F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 * q0 , abaa q4 , q5 abaa L(M ) F 39
  • 40. F q0 ,q5 q4 q5 a a q0 a q1 b q2 q3 * q0 , aba q1 aba L M F 40
  • 41. q4 q5 a a q0 a q1 b q2 q3 LM (ab) n aa : n 0 41
  • 42. Formally The language accepted by NFA M is: LM w1, w2 , w3 ,... where * (q0 , wm ) {qi , q j ,..., qk ,...} and there is some qk F (final state) 42
  • 43. w LM * (q0 , w) qi w qk qk F q0 w w qj L( M ) {w *: * ( q0, w) F } 43
  • 44. An NFA Example Consider the input string ab: q0 a q1 b q2 * (q0 , ab) {q0 , q2 , q3} q0 a q1 b q2 q3 q0 a q1 b q2 q3 q0 q0 a q1 b q2 q3 44
  • 45. Consider the input string ab: * (q0 , ab) {q0 , q2 , q3} q0 a q1 b q2 ab is “accepted” q0 a q1 b q2 q3 q0 a q1 b q2 q3 q0 q0 a q1 b q2 q3 45
  • 46. Another String a b a b q0 a q1 b q2 q3 46
  • 47. q0 a q1 b q2 q3 q0 a q1 b q2 As long as there is one computation that consumes all input symbols and stops at a final state, aabb is accepted. “accept” q0 a q1 b q2 q3 47
  • 48. Language accepted L ab, abab, ababab, ... ab q0 a q1 b q2 q3 48
  • 49. NFAs are interesting because we can express languages easier than DFAs Example: design an FA for {a} with ={a, b}. Example: design an FA for {awa: w {a, b}*} with ={a, b}. 49
  • 50. Consider the transition graph: a * a q0 q0 q1 q1 q2 q2 a q0 q1 q2 50
  • 51. Hw # 20 p.56  Show that for any nfa * (q, wv) U * * ( p, v). p ( q , w) for all q Q, and all w, v * 51
  • 52. Remarks for FA M = {Q, , , q0, F }: •The symbol never appears on the input alphabet •Simple NFA: M1 M2 q0 q0 L(M1 ) = {} L(M 2 ) = {λ} 52
  • 53. The language accepted by NFA M is: L( M ) {w *: * ( q0, w) F } Is it true that for any NFA M , L(M ) {w *: * ( q0, w) F } Is it true that for any NFA M, L(M ) {w *: * (q0, w) (Q F ) } Referring to Hw 2.3 # 5, 6. P.62 53
  • 54. NFAs accept the Regular Languages Hw of 2.2(p.54) 1 – 19 not hand in NFA 54
  • 55. Equivalence of Machines Definition for Automata: Machine M1 is equivalent to machine M 2 if L M1 L M2 55
  • 56. Example of equivalent machines 0 L M1 {10} * q0 q1 NFA M1 1 0,1 0 L M2 {10}* q1 1 q2 q0 1 DFA M2 0 56
  • 57. Which is more powerful?  Every dfa is an nfa.  Thus, every language accepted by a dfa is also accepted by an nfa.  Is nfa more powerful than dfa? 57
  • 58. We will prove: Languages Regular accepted Languages by NFAs Languages accepted by DFAs NFAs and DFAs have the same computation power 58
  • 59. Step 1 Languages Regular accepted Languages by NFAs Proof: Every DFA is trivially an NFA Any language L accepted by a DFA is also accepted by an NFA 59
  • 60. Step 2 Languages Regular accepted Languages by NFAs Proof: Any NFA can be converted to an equivalent DFA Any language L accepted by an NFA is also accepted by a DFA 60
  • 61. Convert NFA to DFA a NFA M N q0 a q1 q2 b * a b q0 q1 q2 An extended transition function is very helpful 61
  • 62. Convert NFA to DFA NFA M N a q0 a q1 q2 b Let p0={q0} be the initial state for MD DFA MD q0 Back to Procedure NFA to DFA 62
  • 63. Convert NFA to DFA NFA M N a q0 a q1 q2 b Now, define D(p0,a) for a DFA MD D(p0,a) = N*({q0},a) ={q1,q2} p1 q0 a q1, q2 63
  • 64. Convert NFA to DFA NFA M N a q0 a q1 q2 b D(p0,b) = N*({q0},b) = p2 DFA MD q0 a q1, q2 b Back to Procedure NFA to DFA 64
  • 65. Convert NFA to DFA NFA M N a q0 a q1 q2 b D(p1,a) = N*({q1,q2},a)= N*({q1},a) N*({q2},a) = {q1,q2} = {q1,q2} = p1 DFA MD a q0 a q1, q2 b 65
  • 66. Convert NFA to DFA NFA M N a q0 a q1 q2 b D(p1,b) = N*({q1,q2},b) = N*({q1},b) N*({q2},b) = {q0} {q0} = {q0} = p0 DFA MD b a q0 a q1, q2 b 66
  • 67. Convert NFA to DFA NFA M N a q0 a q1 q2 b D(p2,a) = N*( ,a) = =p2= D(p2,b) DFA MD b a q0 a q1, q2 b Back to Procedure NFA to DFA a, b 67
  • 68. Convert NFA to DFA NFA M N a q0 a q1 q2 b How about final state? Lastly, check if L(M) b a DFA MD q0 a q1, q2 b a, b back 68
  • 69. NFA to DFA: Remarks  We are given an NFA MN  We want to convert it to an equivalent DFA MD  With L M N L( M D ) 69
  • 70. If the NFA has states q0 , q1, q2 ,...  the DFA has states in the powerset , q0 , q1 , q1, q2 , q3 , q4 , q7 ,.... 70
  • 71. Procedure NFA to DFA p.59 1. Initial state of NFA: q0 Initial state of DFA: p0 q0 To Conversion Example 71
  • 72. Procedure NFA to DFA 2. For every DFA’s state pk {qi , q j ,..., qm } Compute in the NFA * qi , a , * q j,a , union {qi , q j ,..., qm} ... Add transition to DFA To Convertion Example D pk , a D {qi , q j ,..., qm }, a {qi , q j ,..., qm } 72
  • 73. Procedure NFA to DFA Repeat Step 2 for all letters in alphabet, until no more transitions can be added. Remark: In DFA, every vertex must have exactly | | outgoing edges, each labeled with a different element of . To Convertion Example 73
  • 74. Procedure NFA to DFA 3. For any DFA state pk {qi , q j ,..., qm } If some q j is a final state in the NFA Then, make p k a final state in the DFA Remark: If is accepted in the NFA then p0 q0 should be a final state. To Convertion Example 74
  • 75. Theorem Take NFA MN Apply procedure to obtain DFA MD Then MN and MD are equivalent : L(MN) = L(MD) 75
  • 76. Proof L(MN) = L(MD) L(MN) L(MD ) AND L(MN) L(MD ) 76
  • 77. First we show: L(MN) L(MD ) Take arbitrary: w L(MN) We will prove: w L(MD) 77
  • 78. w L(MN) MN q0 w qf w 1 2 ... k MN q0 1 2 k qf 78
  • 79. We will show that if w L(MN) w 1 2 ... k MN q0 1 2 k qf 1 2 k MD {q0} {q f ,...} w L(MD) 79
  • 80. More generally, we will show that if in MN : (arbitrary walk) v a1a2 ... an a1 a2 an MN q0 qi qj ql qm a1 a2 an MD {q0} {qi ,...} {q j ,...} {ql ,...} {qm ,...} 80
  • 81. Proof by induction on |v| Induction Basis: v a1 a1 MN q0 qi a1 MD {q0} {qi ,...} 81
  • 82. Induction hypothesis: 1 |v| k v a1a2 ... ak a1 a2 ak MN q0 qi qj qc qd a1 a2 ak MD {q0} {qi ,...} {q j ,...} {qc ,...} {qd ,...} 82
  • 83. Induction Step: |v| k 1 v a1a2 ... ak ak 1 v ak 1 v a1 a2 ak MN q0 qi qj qc qd v a1 a2 ak MD {q0} {qi ,....} {q j ,...} {qc ,...} {qd ,...} v 83
  • 84. Induction Step: |v| k 1 v a1a2 ... ak ak 1 v ak 1 v a1 a2 ak ak 1 MN q0 qi qj qc qd qe v a1 a2 ak ak 1 MD {q0} {qi ,...} {q j ,...} {qc ,...} {qd ,...} {qe ,...} v 84
  • 85. Therefore if w L(MN) w 1 2 ... k MN q0 1 2 k qf 1 2 k MD {q0} {q f ,...} w L(MD) 85
  • 86. We have shown: L(MN) L(MD ) We also need to show: L(MN) L(MD ) (proof is similar) 86
  • 87. Example a b NFA q0 , a, b q1 a, b q2 Convert NFA to DFA Simplified version of DFA a a a p1 p1 b a, b a, b p0 b b b p2 a, b p3 a p4 p2 a, b p3 Ex. 2.13 Fig. 2.14 (p.59)– in class (you can eliminate the redundant state first) 87
  • 88. Minimal DFAs  A dfa M’ is minimal if M is also a dfa such that L(M’)=L(M) then |QM | |QM’| 88
  • 89. Minimal DFAs  States p and q are called indistinguishable if * ( p, w) F implies * (q, w) F and * ( p, w) F implies * (q, w) F for all w *  States p and q are called distinguishable if w * such that * ( p, w) F and * (q, w) F 89
  • 90. Minimal DFAs  To obtain a minimal DFA M’ from a given DFA M:  Remove all inaccessible states, i.e. not reachable from the initial state.  Reduce states until it has no more indistinguishable states.  Read procedures: mark (p.64) & reduce (p.66), and theorem 2.3 (p.65) & 2.4 (p.67) for details. Remove all inaccessible states can be accomplished by enumerating all simple paths of the graph of the dfa starting at the initial state, any state not part of some path is inaccessible. 90
  • 91. Example: Minimal DFAs q1 0,1 0 1 0 0 q0 q2 1 q4 0 1 1 0 q3 q5 1 91
  • 92. Minimal DFAs Prove or Disprove:  If M = (Q, , , q0, F) is a minimal DFA for a regular language L, then M’ = (Q, , , q0, Q-F) is a minimal DFA for the complement of L. 92
  • 93. Minimal DFAs  Prove or Disprove:  If M = (Q, , , q0, F) is a minimal DFA for a regular language L, then M’ = (Q, , , q0, Q-F) is a minimal DFA for the complement of L. 93
  • 94. Homework Discussion  2.3 (p.62) Discuss 7, 8, 11, 14, 15 Homework 2.3 (p.62) 1 ~15 & 2.4 (p.68) 1, 2, 4, 6 Hand in: 3, 5, 6, 9, 12 (p.62) & 2ae (p.68) 94