lec7 print turing machines stanford

Upload: cesar-amaral

Post on 02-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    1/14

    CS154

    Turing Machines

    Turing Machine

    FINITESTATE

    CONTROL

    INFINITE TAPE

    I N P U T

    q0q1

    A

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    2/14

    0 0, R

    read write move

    , R

    qaccept

    qreject

    0 0, R

    , R

    This Turing machine decides the language {0}

    = {0}

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    3/14

    0 0, R

    read write move

    , R

    qaccept

    0 0, R

    , R

    0 0, R

    , L

    This Turing machine recognizes the language {0}

    = {0}

    Turing Machines versus DFAs

    TM can both write to an read from the ta!e

    The hea can move left and right

    The in!ut oesn"t have to be rea entirel#$

    Acce!t an %e&ect ta'e immeiate e((ect

    an the com!utation can continue (urther

    )even$ (orever* a(ter all in!ut has been rea

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    4/14

    Deciing the language + = { ,-, . , {0$/} }

    STATE

    0 1 1 # 0 1 10 #1 0 1X XX

    1. If theres no # on the tape (or more than one #), reject.

    2. While there is a bit to the left of #,

    Replace the first bit ith !, an" chec if the first bit bto the ri$ht of the # is i"entical. (If not, reject.)

    Replace that bit b ith an ! too.

    %. If theres a bit to the ri$ht of #, then reject else accept

    De(inition1 A Turing Machine is a 23tu!le

    T = )4$ $ 5$ $ 60$ 6acce!t$ 6re&ect*$ ,here1

    4 is a (inite set o( states

    5 is the ta!e al!habet$ ,here 5 an 5

    60 4 is the start state

    is the in!ut al!habet$ ,here

    1 4 5 7 4 5 {+$ %}

    6acce!t 4 is the acce!t state

    6re&ect 4 is the re&ect state$ an 6re&ect 6acce!t

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    5/14

    Turing Machine 8on(igurations

    //0/06200//0 {45}*corres!ons to the configuration1

    q7

    1 0 0 0 0 01 1 1 1

    De(ining Acce!tance an %e&ection (or TMs

    +et 8/ an 89 be con(igurations o( a TM M

    De(inition: 8/ yields 89 i( M is in con(iguration 89a(ter running M in con(iguration 8/ (or one ste!

    ;u!!ose )6/$ b* = )69$ c$ +*

    Then aa6/bb #iels a69acb

    ;u!!ose )6/$ a* = )69$ c$ %*

    Then cab6/a #iels cabc69

    +et , an M be a Turing machineM accepts , i( there are con(igs 80$ 8/$ :::$ 8'$ s:t:

    80 = 60, 8i #iels 8i

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    6/14

    A TM M recognizes a language +

    i( M acce!ts eactl# those strings in +

    A TM M decides a language + i( M acce!ts all

    strings in + an re&ects all strings not in +

    A language + is calle recogni>able or

    recursivel# enumerable )r:e:*

    i( some TM recogni>es +

    A language + is calle eciable or recursivei( some TM ecies +

    w L ?

    accept reject

    TM

    yes no

    w *

    L is decidable

    (recursive)

    w L ?

    accept reject or loop

    TM

    yes no

    w *

    L is recognizable

    (recursively enumerable)

    Theorem1 + is eciable

    i(( both + an + are recogni>able

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    7/14

    %ecall1 ?iven + *$ e(ine + 1= @ +

    o,B An# ieasB

    M/ al,a#s acce!ts $ ,hen is in +

    M9 al,a#s acce!ts $ ,hen isn"t in +

    Theorem1 + is eciablei(( both + an + are recogni>able

    ?iven1

    a TM M/ that recogni>es + an

    a TM M9 that recogni>es +$

    ,ant to buil a ne, machine M that decides +

    Theorem1 + is eciable

    i(( both + an + are recogni>able

    ;imulate M/ )* on one ta!e$ M9 )* on another:Eactl# one o( the t,o ,ill acce!t

    I( M/ acce!ts then acce!t

    I( M9 acce!ts then re&ect

    %ecall1 ?iven + *$ e(ine + 1= @ +

    ?iven1

    a TM M/ that recogni>es + an

    a TM M9 that recogni>es +$

    ,ant to buil a ne, machine M that decides +

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    8/14

    { 0 . n C 0 }9n

    1. Seep from left to ri$ht, cross o&t e'er other 0

    2. If in step 1, the tape ha" onl one 0, accept

    %. If in step 1, the tape ha" an o"" n&mber of 0s,

    reject

    4. o'e the hea" bac to the first inp&t smbol.

    5. *o to step 1.

    Turing Machine P;ED8DE1

    Why does this work?

    Iea1 Ever# time ,e return to stage /$

    the number o( 0"s on the ta!e has been halve:

    ;te! /0 , R

    , R

    qacceptqreject

    0 x, R

    x x, R, R

    x x, R

    0 0, L

    x x, L

    x x, R

    , L, R

    0 x, R0 0, R

    , Rx x, R

    q0 q1

    q2

    q3

    q4

    { 0 . n C 0 }9n

    ;te! 9

    ;te!

    ;te! G

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    9/14

    Multita!e Turing Machines

    1 4 5' 7 4 5' {+$%}'

    FINITESTATE

    CONTROLk

    FINITESTATE

    CONTROL

    0 01

    FINITESTATE

    CONTROL 0 01 ## #

    ..

    .

    Theorem1 Ever# Multita!e Turing Machine can be

    trans(orme into a single ta!e Turing Machine

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    10/14

    FINITESTATE

    CONTROL

    0 01

    FINITESTATE

    CONTROL 0 01 ## #

    ..

    .

    Theorem1 Ever# Multita!e Turing Machine can be

    trans(orme into a single ta!e Turing Machine

    FINITESTATE

    CONTROL

    0 01

    FINITESTATE

    CONTROL 0 01 ## #

    ..

    .

    Theorem1 Ever# Multita!e Turing Machine can be

    trans(orme into a single ta!e Turing Machine

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    11/14

    Theorem1 Ever# Multita!e Turing Machine can be

    trans(orme into a single ta!e Turing Machine

    FINITESTATE

    CONTROL

    0 01

    FINITESTATE

    CONTROL 0 01 # # #.

    . .

    Theorem1 Ever# noneterministic Turing machine N

    can be trans(orme into a single ta!e Turing

    Machine M that recognizes the language +)N*:

    Noneterministic Turing Machines

    Proo( Iea )more etails in ;i!ser*Pic' a natural orering on all strings in {4 5 -}

    M),*1 For all strings D {4 5 -} in the orering$

    8hec' i( D = 80-LLLL -8' ,here 80$ H$8' is some

    acce!ting com!utation histor# (or N on ,:

    I( so$ accept.

    ave multi!le transitions (or a state$ s#mbol !air

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    12/14

    e can encoe Turing Machines as bit strings

    0n/0m/0'/0s/0t/0r/0u/ H

    n states

    m tape symbols(first k are input

    symbols)

    start

    state

    acceptstate

    rejectstate

    blanksymbol

    ) )!$ i*$ )6$ &$ +* * = 0!/0i/06/0&/0

    ) )!$ i*$ )6$ &$ %* * = 0!/0i/06/0&/00

    ;imilarl#$ ,e can encoe DFAs an NFAs asbit strings$ an , as bit strings

    ADFA = { )J$ ,* . J encoes a DFA over some $an J acce!ts , }

    ANFA = { )J$ ,* . J encoes an NFA$ J acce!ts , }

    ATM = { )M$ ,* . M encoes a TM$ M acce!ts , }

    For e(ine b)* to be its binar# encoing

    For $ # $ e(ine thepair of x and yas

    )$ #* 1= 0.b)*./ b)* b)#*

    Then ,e e(ine the (ollo,ing languages over {0$/}1

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    13/14

    ATM = { )M$ ,* . M encoes a TM over some $

    , encoes a string over an M acce!ts ,}

    ATM = { )M$ ,* . M oes not acce!t , }

    Technical Note1

    e"ll use an ecoing o( !airs$ TMs$ an strings so that

    everybinar# string ecoes to some !air )M$ ,*

    I( {0$/} oesn"t ecoe to )M$,* in the usual ,a#$

    then ,e e(ine that ecoes to the !air )D$ K*

    ,here D is a Lumm# TM that acce!ts nothing:

    Then$ ,e can e(ine the com!lement o( ATM ver# sim!l#1

    niversal Turing Machines

    Theorem1 There is a Turing machine

    ,hich ta'es as in!ut1

    + the coe o( an arbitrar# TM M

    + an an in!ut string ,

    such that acce!ts )M$ ,*M acce!ts ,:

    This is afundamental!ro!ert# o( TMs1

    There is a Turing Machine that

    can run arbitrar# Turing Machine coe

    Note that DFAsONFAs o nothave this !ro!ert#:

    That is$ ADFA an ANFA are not regular:

  • 8/10/2019 Lec7 Print Turing Machines Stanford

    14/14

    The 8hurch3Turing Thesis

    Ever#one"s

    Intuitive Notion

    o( Algorithms

    = Turing Machines

    This is not a theorem

    it is a falsifiable scientific hypothesis.

    An it has been thoroughl# teste