SlideShare ist ein Scribd-Unternehmen logo
1 von 82
Turing Machines
Invented by Alan Turing in 1936.

A simple mathematical model of a general
  purpose computer.

It is capable of performing any calculation
   which can be performed by any computing
   machine.
The Language Hierarchy

 n n n ?
a b c             ww ?

   Context-Free Languages
      n n            R
     a b         ww
     Regular Languages
      a*     a *b *
Languages accepted by
   Turing Machines
 n n n
a b c                   ww

   Context-Free Languages
      n n            R
        a b            ww    NDPA

    Regular Languages
                      Finite
         a * a *b *   Automata
A Turing Machine
Tape
......                           ......


               Read-Write head
Control Unit
The Tape
         No boundaries -- infinite length
......                                      ......


               Read-Write head




         The head moves Left or Right
......                            ......


            Read-Write head


The head at each time step:

          1. Reads a symbol
          2. Writes a symbol
          3. Moves Left or Right
Example:
                     Time 0
 ......             a b a c   ......



                     Time 1
  ......            a b k c   ......

1. Reads    a
2. Writes       k
3. Moves Left
Time 1
 ......             a b k c   ......



                     Time 2
 ......             a f k c   ......


1. Reads    b
2. Writes       f
3. Moves Right
The Input String
                   Input string              Blank symbol

......              a b a c                           ......

           head
Head starts at the leftmost position
of the input string
         Are treated as left and right brackets for the
         input written on the tape.
States & Transitions
Read       Write
                         Move Left



  q1   a     b, L   q2

                         Move Right

  q1   a     b, R   q2
Example:
                        Time 1
   ......        a b a c         ......

                         q1
                 current state




        q1   a   b, R     q2
Time 1
......          a b a c            ......

                         q1

                    Time 2
......          a b b c            ......

                              q2

q1       a   b, R   q2
Example:
                      Time 1
  ......          a b a c        ......

                            q1

                      Time 2
  ......          a b b c        ......

                      q2

  q1       a   b, L    q2
Example:
                  Time 1
  ......      a b a c                ......

                           q1

                  Time 2
  ......      a b b c g              ......

                                q2

  q1       g, R   q2
Determinism
         Turing Machines are deterministic

         Allowed                Not Allowed
     a     b, R     q2             a   b, R   q2

q1                            q1
                    q3             a   d, L   q3
     b     d, L

          No lambda transitions allowed
Partial Transition Function
Example:

   ......           a b a c                 ......

                         q1

       a     b, R   q2        Allowed:

  q1                          No transition
                              for input symbol   c
       b     d, L   q3
Halting


The machine halts if there are
no possible transitions to follow
Example:



  ......          a b a c              ......

                        q1

      a    b, R   q2
                       No possible transition
 q1
                             HALT!!!
      b    d, L   q3
Final States
 q1             q2       Allowed



 q1             q2      Not Allowed


• Final states have no outgoing transitions

• In a final state the machine halts
Acceptance
                     If machine halts
Accept Input
                     in a final state


                     If machine halts
                     in a non-final state
Reject Input                  or
                     If machine enters
                     an infinite loop
Turing Machine Example
A Turing machine that accepts the language:
                                  aa *


            a        a, R

                            ,L
                q0               q1
Time 0                   a a a

                         q0



         a        a, R

                              ,L
             q0                    q1
Time 1                   a a a

                          q0



         a        a, R

                           ,L
             q0                  q1
Time 2                   a a a

                            q0



         a        a, R

                           ,L
             q0                  q1
Time 3                   a a a

                                 q0



         a        a, R

                           ,L
             q0                   q1
Time 4                   a a a

                            q1



         a        a, R      Halt & Accept

                           ,L
             q0                  q1
Rejection Example


Time 0                    a b a

                          q0


          a        a, R

                               ,L
              q0                    q1
Time 1                a b a

                         q0
                       No possible Transition
         a        a, R    Halt & Reject


                          ,L
             q0                 q1
Infinite Loop Example



   b        b, L
   a        a, R

                   ,L
       q0               q1
Time 0                   a b a

                         q0


         b        b, L
         a        a, R

                              ,L
             q0                    q1
Time 1                   a b a

                          q0


         b        b, L
         a        a, R

                           ,L
             q0                  q1
Time 2                   a b a

                     q0


         b        b, L
         a        a, R

                           ,L
             q0                  q1
Time 2                a b a
                      q0
Time 3                a b a
                           q0
Time 4                a b a
                      q0

Time 5                 a b a
                         q0
  ... Infinite Loop
Because of the infinite loop:

  •The final state cannot be reached

  •The machine never halts

  •The input is not accepted
Another Turing Machine
                     Example        n                      n
    Turing machine for the language                 {a b }



                   q4              y    y, R          y        y, L
y      y, R                        a    a, R          a        a, L
                            ,L
          y     y, R        a    x, R        b      y, L
     q3                q0               q1                 q2
                                    x        x, R
Time 0                a a b b

                          q0


                 q4              y    y, R          y     y, L
y     y, R                       a    a, R          a     a, L
                          ,L
          y   y, R        a    x, R        b      y, L
     q3              q0               q1                 q2
                                  x        x, R
Time 1                x a b b

                               q1


                 q4                 y   y, R          y     y, L
y      y, R                         a   a, R          a     a, L
                          ,L
          y   y, R        a     x, R         b      y, L
     q3              q0                 q1                 q2
                                    x        x, R
Time 2                x a b b

                                q1


                 q4              y       y, R          y     y, L
y     y, R                       a       a, R          a     a, L
                          ,L
          y   y, R        a    x, R           b      y, L
     q3              q0                  q1                 q2
                                     x        x, R
Time 3                x a y b

                               q2


                 q4                 y   y, R          y     y, L
y     y, R                          a   a, R          a     a, L
                          ,L
          y   y, R        a     x, R         b      y, L
     q3              q0                 q1                 q2
                                    x        x, R
Time 4                x a y b

                          q2


                 q4              y    y, R          y     y, L
y     y, R                       a    a, R          a     a, L
                          ,L
          y   y, R        a    x, R        b      y, L
     q3              q0               q1                 q2
                                  x        x, R
Time 5                x a y b

                               q0


                 q4                 y   y, R          y     y, L
y     y, R                          a   a, R          a     a, L
                          ,L
          y   y, R        a     x, R         b      y, L
     q3              q0                 q1                 q2
                                    x        x, R
Time 6                x x y b

                                q1


                 q4              y       y, R          y     y, L
y     y, R                       a       a, R          a     a, L
                          ,L
          y   y, R        a    x, R           b      y, L
     q3              q0                  q1                 q2
                                     x        x, R
Time 7                x x y b

                                      q1


                 q4              y         y, R      y     y, L
y     y, R                       a         a, R      a     a, L
                          ,L
          y   y, R        a    x, R          b     y, L
     q3              q0                q1                 q2
                                  x         x, R
Time 8                x x y y

                                q2


                 q4              y    y, R          y     y, L
y     y, R                       a    a, R          a     a, L
                          ,L
          y   y, R        a    x, R        b      y, L
     q3              q0               q1                 q2
                                  x        x, R
Time 9                x x y y

                               q2


                 q4                 y   y, R          y     y, L
y     y, R                          a   a, R          a     a, L
                          ,L
          y   y, R        a     x, R         b      y, L
     q3              q0                 q1                 q2
                                    x        x, R
Time 10               x x y y

                                q0


                 q4              y       y, R          y     y, L
y      y, R                      a       a, R          a     a, L
                          ,L
          y   y, R        a    x, R           b      y, L
     q3              q0                  q1                 q2
                                     x        x, R
Time 11               x x y y

                                      q3


                 q4              y         y, R          y     y, L
y      y, R                      a         a, R          a     a, L
                          ,L
          y   y, R        a    x, R             b      y, L
     q3              q0                    q1                 q2
                                  x             x, R
Time 12               x x y y

                                      q3


                 q4              y    y, R          y     y, L
y      y, R                      a    a, R          a     a, L
                          ,L
          y   y, R        a    x, R        b      y, L
     q3              q0               q1                 q2
                                  x        x, R
Time 13                 x x y y

                                        q4
              Halt & Accept

                   q4              y         y, R      y     y, L
y      y, R                        a         a, R      a     a, L
                            ,L
          y     y, R        a    x, R          b     y, L
     q3                q0                q1                 q2
                                    x         x, R
Observation:


  If we modify the
  machine for the language        n n
                                {a b }


   we can easily construct
                                   n n n
   a machine for the language    {a b c }
Formal Definitions
        for
 Turing Machines
Transition Function



q1   c   d, L    q2


(q1, c) (q2 , d , L)
Turing Machine:

                  Input                 Tape
                  alphabet              alphabet
   States


        M     (Q, , , , q0 , , F )

 A partial                                    Final
 Transition                                   states
 function     Initial        Blank : a special symbol
              state          Of
Configuration
                c a b a

                      q1



Instantaneous description:   ca q1 ba
Time 4                Time 5
    x a y b               x a y b

   q2                       q0



A Move:     q2 xayb  x q0 ayb
Time 4               Time 5
     x a y b              x a y b

    q2                      q0

    Time 6               Time 7
    x x y b              x x y b

         q1                        q1

q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b
q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b




Equivalent notation:   q2 xayb  xxy q1 b
Initial configuration:       q0 w


                 Input string

                         w

                 a a b b

                 q0
The Accepted Language
For any Turing Machine   M


  L( M ) {w :      q0 w  x1 q f x2 }


        Initial state        Final state
Standard Turing Machine
The machine we described is the standard:


      • Deterministic

      • Infinite tape in both directions

      •Tape is the input/output file
Design a Turing machine to recognize all
 strings in which 010 is present as a
 substring.          0,0,R



          0,0,R           1,1,R        0,0,R
     q0            q1             q2           H



                  1,1,R
 1,1, R
DFA for the previous language
                          0



         0            1            0
    q0           q1           q2



             1
1

                                       0,1
Turing machine for odd no of 1’s


       1, 1 , R
                             1, b , R




                  1, b , R
Recursively Enumerable
          and
      Recursive

     Languages
Definition:
   A language is recursively enumerable
   if some Turing machine accepts it
Let   L be a recursively enumerable language
and   M the Turing Machine that accepts it

For string    w:
if    w L     then   M halts in a final state

 if   w   L   then   M halts in a non-final state
                         or loops forever
Definition:
   A language is recursive
   if some Turing machine accepts it
   and halts on any input string




In other words:
   A language is recursive if there is
    a membership algorithm for it
Let   L be a recursive language
and   M the Turing Machine that accepts it

For string    w:

if   w L      then   M halts in a final state

if    w   L   then   M halts in a non-final state
We will prove:

   1. There is a specific language
      which is not recursively enumerable
      (not accepted by any Turing Machine)



   2. There is a specific language
      which is recursively enumerable
      but not recursive
Non Recursively Enumerable



  Recursively Enumerable



        Recursive
We will first prove:

 • If a language is recursive then
   there is an enumeration procedure for it




• A language is recursively enumerable
  if and only if
  there is an enumeration procedure for it
The Chomsky Hierarchy
Unrestricted Grammars:

                Productions
                  u    v


String of variables           String of variables
and terminals                 and terminals
Example unrestricted grammar:

              S    aBc
              aB     cA
              Ac     d
Theorem:

 A language L is recursively enumerable
 if and only if L is generated by an
 unrestricted grammar
Context-Sensitive Grammars:

                  Productions
                    u    v


String of variables             String of variables
and terminals                   and terminals

           and:   |u|    |v|
The language        n n n
               {a b c }
is context-sensitive:

            S        abc | aAbc
               Ab     bA
               Ac     Bbcc
            bB        Bb
            aB        aa | aaA
The language        n n n
               {a b c }
is context-sensitive:

            S        abc | aAbc
               Ab     bA
               Ac     Bbcc
            bB        Bb
            aB        aa | aaA
Theorem:

A language   L is context sensistive
              if and only if
L   is accepted by a Linear-Bounded automaton
Observation:

There is a language which is context-sensitive
but not recursive
The Chomsky Hierarchy

Non-recursively enumerable

 Recursively-enumerable
       Recursive

   Context-sensitive

     Context-free

        Regular

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Automata theory
Automata theoryAutomata theory
Automata theory
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machine
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Turing machine
Turing machineTuring machine
Turing machine
 
Turing machine
Turing machineTuring machine
Turing machine
 
Pda
PdaPda
Pda
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Push down automata
Push down automataPush down automata
Push down automata
 
Turing machine - theory of computation
Turing machine - theory of computationTuring machine - theory of computation
Turing machine - theory of computation
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Turing machine
Turing machineTuring machine
Turing machine
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Unit v
Unit vUnit v
Unit v
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Turing machine
Turing machineTuring machine
Turing machine
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 

Ähnlich wie Turing machines

Ähnlich wie Turing machines (7)

Tm
TmTm
Tm
 
Automata
AutomataAutomata
Automata
 
Class3
 Class3 Class3
Class3
 
Turingmachines
Turingmachines Turingmachines
Turingmachines
 
Finite automata
Finite automataFinite automata
Finite automata
 
Lecture03 (1).ppt
Lecture03 (1).pptLecture03 (1).ppt
Lecture03 (1).ppt
 
Simple circular curve by Nikhil Pakwanne
Simple circular curve by Nikhil PakwanneSimple circular curve by Nikhil Pakwanne
Simple circular curve by Nikhil Pakwanne
 

Mehr von lavishka_anuj

Mehr von lavishka_anuj (9)

Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfg
 
One ques
One quesOne ques
One ques
 
Non regular languages
Non regular languagesNon regular languages
Non regular languages
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Grammar
GrammarGrammar
Grammar
 
Flat
FlatFlat
Flat
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 

Kürzlich hochgeladen

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Kürzlich hochgeladen (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Turing machines

  • 2. Invented by Alan Turing in 1936. A simple mathematical model of a general purpose computer. It is capable of performing any calculation which can be performed by any computing machine.
  • 3. The Language Hierarchy n n n ? a b c ww ? Context-Free Languages n n R a b ww Regular Languages a* a *b *
  • 4. Languages accepted by Turing Machines n n n a b c ww Context-Free Languages n n R a b ww NDPA Regular Languages Finite a * a *b * Automata
  • 5. A Turing Machine Tape ...... ...... Read-Write head Control Unit
  • 6. The Tape No boundaries -- infinite length ...... ...... Read-Write head The head moves Left or Right
  • 7. ...... ...... Read-Write head The head at each time step: 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right
  • 8. Example: Time 0 ...... a b a c ...... Time 1 ...... a b k c ...... 1. Reads a 2. Writes k 3. Moves Left
  • 9. Time 1 ...... a b k c ...... Time 2 ...... a f k c ...... 1. Reads b 2. Writes f 3. Moves Right
  • 10. The Input String Input string Blank symbol ...... a b a c ...... head Head starts at the leftmost position of the input string Are treated as left and right brackets for the input written on the tape.
  • 11. States & Transitions Read Write Move Left q1 a b, L q2 Move Right q1 a b, R q2
  • 12. Example: Time 1 ...... a b a c ...... q1 current state q1 a b, R q2
  • 13. Time 1 ...... a b a c ...... q1 Time 2 ...... a b b c ...... q2 q1 a b, R q2
  • 14. Example: Time 1 ...... a b a c ...... q1 Time 2 ...... a b b c ...... q2 q1 a b, L q2
  • 15. Example: Time 1 ...... a b a c ...... q1 Time 2 ...... a b b c g ...... q2 q1 g, R q2
  • 16. Determinism Turing Machines are deterministic Allowed Not Allowed a b, R q2 a b, R q2 q1 q1 q3 a d, L q3 b d, L No lambda transitions allowed
  • 17. Partial Transition Function Example: ...... a b a c ...... q1 a b, R q2 Allowed: q1 No transition for input symbol c b d, L q3
  • 18. Halting The machine halts if there are no possible transitions to follow
  • 19. Example: ...... a b a c ...... q1 a b, R q2 No possible transition q1 HALT!!! b d, L q3
  • 20. Final States q1 q2 Allowed q1 q2 Not Allowed • Final states have no outgoing transitions • In a final state the machine halts
  • 21. Acceptance If machine halts Accept Input in a final state If machine halts in a non-final state Reject Input or If machine enters an infinite loop
  • 22. Turing Machine Example A Turing machine that accepts the language: aa * a a, R ,L q0 q1
  • 23. Time 0 a a a q0 a a, R ,L q0 q1
  • 24. Time 1 a a a q0 a a, R ,L q0 q1
  • 25. Time 2 a a a q0 a a, R ,L q0 q1
  • 26. Time 3 a a a q0 a a, R ,L q0 q1
  • 27. Time 4 a a a q1 a a, R Halt & Accept ,L q0 q1
  • 28. Rejection Example Time 0 a b a q0 a a, R ,L q0 q1
  • 29. Time 1 a b a q0 No possible Transition a a, R Halt & Reject ,L q0 q1
  • 30. Infinite Loop Example b b, L a a, R ,L q0 q1
  • 31. Time 0 a b a q0 b b, L a a, R ,L q0 q1
  • 32. Time 1 a b a q0 b b, L a a, R ,L q0 q1
  • 33. Time 2 a b a q0 b b, L a a, R ,L q0 q1
  • 34. Time 2 a b a q0 Time 3 a b a q0 Time 4 a b a q0 Time 5 a b a q0 ... Infinite Loop
  • 35. Because of the infinite loop: •The final state cannot be reached •The machine never halts •The input is not accepted
  • 36. Another Turing Machine Example n n Turing machine for the language {a b } q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 37. Time 0 a a b b q0 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 38. Time 1 x a b b q1 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 39. Time 2 x a b b q1 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 40. Time 3 x a y b q2 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 41. Time 4 x a y b q2 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 42. Time 5 x a y b q0 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 43. Time 6 x x y b q1 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 44. Time 7 x x y b q1 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 45. Time 8 x x y y q2 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 46. Time 9 x x y y q2 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 47. Time 10 x x y y q0 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 48. Time 11 x x y y q3 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 49. Time 12 x x y y q3 q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 50. Time 13 x x y y q4 Halt & Accept q4 y y, R y y, L y y, R a a, R a a, L ,L y y, R a x, R b y, L q3 q0 q1 q2 x x, R
  • 51. Observation: If we modify the machine for the language n n {a b } we can easily construct n n n a machine for the language {a b c }
  • 52. Formal Definitions for Turing Machines
  • 53. Transition Function q1 c d, L q2 (q1, c) (q2 , d , L)
  • 54. Turing Machine: Input Tape alphabet alphabet States M (Q, , , , q0 , , F ) A partial Final Transition states function Initial Blank : a special symbol state Of
  • 55. Configuration c a b a q1 Instantaneous description: ca q1 ba
  • 56. Time 4 Time 5 x a y b x a y b q2 q0 A Move: q2 xayb  x q0 ayb
  • 57. Time 4 Time 5 x a y b x a y b q2 q0 Time 6 Time 7 x x y b x x y b q1 q1 q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b
  • 58. q2 xayb  x q0 ayb  xx q1 yb  xxy q1 b Equivalent notation: q2 xayb  xxy q1 b
  • 59. Initial configuration: q0 w Input string w a a b b q0
  • 60. The Accepted Language For any Turing Machine M L( M ) {w : q0 w  x1 q f x2 } Initial state Final state
  • 61. Standard Turing Machine The machine we described is the standard: • Deterministic • Infinite tape in both directions •Tape is the input/output file
  • 62. Design a Turing machine to recognize all strings in which 010 is present as a substring. 0,0,R 0,0,R 1,1,R 0,0,R q0 q1 q2 H 1,1,R 1,1, R
  • 63. DFA for the previous language 0 0 1 0 q0 q1 q2 1 1 0,1
  • 64. Turing machine for odd no of 1’s 1, 1 , R 1, b , R 1, b , R
  • 65. Recursively Enumerable and Recursive Languages
  • 66. Definition: A language is recursively enumerable if some Turing machine accepts it
  • 67. Let L be a recursively enumerable language and M the Turing Machine that accepts it For string w: if w L then M halts in a final state if w L then M halts in a non-final state or loops forever
  • 68. Definition: A language is recursive if some Turing machine accepts it and halts on any input string In other words: A language is recursive if there is a membership algorithm for it
  • 69. Let L be a recursive language and M the Turing Machine that accepts it For string w: if w L then M halts in a final state if w L then M halts in a non-final state
  • 70. We will prove: 1. There is a specific language which is not recursively enumerable (not accepted by any Turing Machine) 2. There is a specific language which is recursively enumerable but not recursive
  • 71. Non Recursively Enumerable Recursively Enumerable Recursive
  • 72. We will first prove: • If a language is recursive then there is an enumeration procedure for it • A language is recursively enumerable if and only if there is an enumeration procedure for it
  • 74. Unrestricted Grammars: Productions u v String of variables String of variables and terminals and terminals
  • 75. Example unrestricted grammar: S aBc aB cA Ac d
  • 76. Theorem: A language L is recursively enumerable if and only if L is generated by an unrestricted grammar
  • 77. Context-Sensitive Grammars: Productions u v String of variables String of variables and terminals and terminals and: |u| |v|
  • 78. The language n n n {a b c } is context-sensitive: S abc | aAbc Ab bA Ac Bbcc bB Bb aB aa | aaA
  • 79. The language n n n {a b c } is context-sensitive: S abc | aAbc Ab bA Ac Bbcc bB Bb aB aa | aaA
  • 80. Theorem: A language L is context sensistive if and only if L is accepted by a Linear-Bounded automaton
  • 81. Observation: There is a language which is context-sensitive but not recursive
  • 82. The Chomsky Hierarchy Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free Regular