CS411-2015S-12 Turing Mchine Modifictions 1 12-0: Extending Turing Mchines When we dded stck to NFA to get PDA, we incresed computtionl power Cn we do the sme thing for Turing Mchines? Tht is, cn we dd some new feture to TMs tht will increse their computtionl power? 12-1: Multi-Trck Tpe Insted of ech tpe loction holding single symol, we dd severl trcks to the tpe Bsed on contents of ll trcks, either move hed left, move hed right, or write new vlues to ny of the trcks c Red/write hed 12-2: Multi-Trck Tpe Cn simulte mutli-trck mchine with stndrd TM Increse the size of the tpe lphet k trcks, ech with n lphet ofnsymols New lphet of sizen k 12-3: Multi-Trck Tpe Red/write hed = = = C= D= E= F= G= H= GEF EH Red/write hed 12-4: Multiple Tpes Severl tpes, with independent red/write heds Rech symol on ech tpe, nd sed on contents of ll tpes:
CS411-2015S-12 Turing Mchine Modifictions 2 Write or move ech tpe independently Trnsition to new stte Red/write hed Red/write hed c Red/write hed 12-5: Multiple Tpes Crete 2-Tpe Mchine tht dds two numers Convert w;v to w +v (leding zeros OK) Assume tht tpe 1 holds input (nd output), nd tpe 2 strts out with lnks 12-6: Multiple Tpes Crete 2-Tpe Mchine tht dds two numers Convert w;v to w +v (leding zeros OK) Copy first # to second tpe (zeroing out first # on first tpe) Do stndrd ddition, keeping trck of crries. 12-7: Multiple Tpes Crete 2-Tpe Mchine tht dds two numers 0 1 0 1 0 2 1 = R 1,2 0 1 2 0 R 1 2 1 2 1 1 1 1 L 1,2 0 1, 1 0 0 1 1 1 1 2 1 0 1 0 2 1 1 1 2 1 1 0 L 1 1 2 1 1 2 0 1 2 1 1 1 2 1 2 1 2 0 1, 0 1,2 L 0 1 0 1 2 0 1 1 1 12-8: Multiple Tpes Are k-tpe mchines more powerful thn 1-tpe mchines? 12-9: Multiple Tpes
CS411-2015S-12 Turing Mchine Modifictions 3 c c 1 c 1 c 1 12-10: Multiple Tpes Ech trnsition from the originl, multi-tpe mchine will require severl trnsitions from the simulted mchine nd ech stte in the multiple-tpe mchine will e represented y set of sttes in the simultion mchine First, need to scn tpe hed to find ll virtul heds, nd rememer wht symol is stored t ech hed loction Use stte to store this informtion Next, scn tpe to implement the ction on ech tpe (moving hed, rewriting symols, etc) Finlly, trnsition to new set of sttes 12-11: 2-Wy Infinite Tpe c d e f g h i 12-12: 2-Wy Infinite Tpe Red/write hed c d e f g h i Red/write hed f g h i * e d c 12-13: 2-Wy Infinite Tpe Red/write hed
CS411-2015S-12 Turing Mchine Modifictions 4 Mke 2 copies of sttes in originl mchine: One set for top tpe, one set for ottom tpe Top Tpe Sttes Use the top trck Execute s norml When Move Left commnd, nd eginning of tpe symol is on the ottom tpe, move Right insted, switch to Bottom Tpe Sttes 12-14: 2-Wy Infinite Tpe Mke 2 copies of sttes in originl mchine: One set for top tpe, one set for ottom tpe Bottom Tpe Sttes Use the ottom trck Move left on Move Right commnd, move right on Move Left commnd When the eginning of tpe symol is encountered, switch to Top Tpe Sttes 12-15: Simple Computer CPU 3 Registers ( (IR), Progrm Counter (PC), Accumultor (ACC) Opertion: Set IR MEM[PC] Increment PC Execute instruction in IR Repet 12-16: Simple Computer CPU Registers Instruction Register Progrm Counter Accumultor 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015
CS411-2015S-12 Turing Mchine Modifictions 5 12-17: Simple Computer Instruction Mening 00 HALT Stop Computtion 01 LOAD x ACC MEM[x] 02 LOADI x ACC x 03 STORE x MEM[x] AC 04 ADD x ACC ACC + MEM[x] 05 ADDI x ACC ACC + x 06 SUB x ACC ACC - MEM[x] 07 SUBI x ACC ACC - x 08 JUMP x IP x 09 JZERO x IP xif ACC = 0 10 JGT x IP xif ACC>0 Write progrm tht multiplies two numers (in loctions 1000 & 1001), nd stores the result in 1002 12-18: Simple Computer Mchine Code Assemly 0001 011000 LOAD 1000 0002 031003 STORE 1003 0003 020000 LOADI 0 0004 031002 STORE 1002 0005 021003 LOAD 1003 0006 090012 JZERO 0012 0007 070001 SUBI 1 0008 031003 STORE 1003 0009 011002 LOAD 1002 0010 041001 ADD 1001 0011 080004 STORE 1002 0012 000000 HALT 12-19: Computers & TMs We cn simulte this computer with multi-tpe Turing mchine: One tpe for ech register (IR, IP, ACC) One tpe for the tpe will e entries of the form<ddress><contents> 12-20: Computers & TMs ddress contents 0 0 0 1 1 1 0 0 0 Accumultor 0 12-21: Computers & TMs Opertion: Scn through memory until rech n ddress tht mtches the IP Copy contents of memory t tht ddress to the IR Increment IP Bsed on the instruction code: Copy vlue into IP Copy vlue into Copy vlue into the ACC Do ddition/sutrction
CS411-2015S-12 Turing Mchine Modifictions 6 12-22: Computers & TMs 1 0 0 0 & 0 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 1 Accumultor 12-23: Computers & TMs 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 1 Accumultor 12-24: Computers & TMs 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 Accumultor 12-25: Computers & TMs (LOAD 1000)
CS411-2015S-12 Turing Mchine Modifictions 7 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 0 1 1 0 0 0 Accumultor 12-26: Computers & TMs (LOAD 1000) 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 0 1 1 0 0 0 Accumultor 12-27: Computers & TMs (LOAD 1000) 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 0 1 1 0 0 0 Accumultor 0 0 0 0 2 1 12-28: Computers & TMs (LOAD 1000)
CS411-2015S-12 Turing Mchine Modifictions 8 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 Accumultor 0 0 0 0 2 1 12-29: Computers & TMs 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 Accumultor 0 0 0 0 2 1 12-30: Computers & TMs 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 2 0 3 1 0 0 3 Accumultor 0 0 0 0 2 1 12-31: Computers & TMs (STORE 1003)
CS411-2015S-12 Turing Mchine Modifictions 9 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 3 0 3 1 0 0 3 Accumultor 0 0 0 0 2 1 12-32: Computers & TMs (STORE 1003) 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 0 0 0 0 0 0 3 0 3 1 0 0 3 Accumultor 0 0 0 0 2 1 12-33: Computers & TMs (STORE 1003) 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 2 1 0 0 0 0 3 0 3 1 0 0 3 Accumultor 0 0 0 0 2 1 12-34: Computers & TMs (STORE 1003)
CS411-2015S-12 Turing Mchine Modifictions 10 1 0 0 0 & 0 0 0 2 1 & 1 0 0 1 & 0 0 0 0 0 5 & 1 0 0 2 & 0 0 0 0 0 0 & 1 0 0 3 & 0 0 0 0 2 1 0 0 0 0 3 Accumultor 0 0 0 0 2 1 12-35: Computers & TMs Simple Computer cn e modeled y Turing Mchine Any current mchine cn e modeled in the sme wy y Turing Mchine If there is n lgorithm for it, Turning Mchine cn do it Note tht t this point, we don t cre how long it might tke, just tht it cn e done 12-36: Turing Complete A computtion formlism is Turing Complete if it cn simulte Turing Mchine Turing Complete cn compute nything Of course it might not e convenient 12-37: Non-Determinism Finl extension to Turing Mchines: Non-Determinism Just like non-determinism in NFAs, PDAs String is ccepted y non-deterministic Turing Mchine if there is t lest one computtionl pth tht ccepts 12-38: Non-Determinism A Non-Deterministic Mchine M Decides lnguge L if: All computtionl pths hlt For echw L, t lest one computtionl pth forw ccepts For ll w L, no computtionl pth ccepts 12-39: Non-Determinism A Non-Deterministic Mchine M Semi-Decides lnguge L if: For echw L, t lest one computtionl pth forw hlts nd ccepts For ll w L, no computtionl pth hlts nd ccepts 12-40: Non-Determinism A Non-Deterministic Mchine M Computes Function if:
CS411-2015S-12 Turing Mchine Modifictions 11 All computtionl pths hlt Every computtionl pth produces the sme result 12-41: Non-Determinism Non-Deterministic TM forl = {w {0,1} : w is composite} (semi-decides is OK) 12-42: Non-Determinism Non-Deterministic TM forl = {w {0,1} : w is composite} 0 0 R R ; R L M MULT M w w 1 1 How could we mke this mchine decide (insted of semi-decide)l? 12-43: Non-Determinism How we cn mke this mchine decide (insted of semi-decide)l First, trnsform w into w w; w Non-deterministiclly modify the second 2w s Multiply the second 2 w s Check to see if the resulting string is w w 12-44: Non-Determinism Are Non-Deterministic Turing Mchines more powerful thn Deterministic Turing mchines? Is there some L which cn e semi-decided y non-deterministic Turing Mchine, which cnnot e semi-decided y Deterministic Turing Mchine? Non-determinism in Finite Automt didn t uy us nything Non-determinism in Push-Down Automt did 12-45: Non-Determinism How to Simulte Non-Deterministic Turing Mchine with Deterministic Turing Mchine 12-46: Non-Determinism How to Simulte Non-Deterministic Turing Mchine with Deterministic Turing Mchine Try one computtionl pth if it sys yes, hlt nd sy yes. Otherwise, try different computtionl pth. Repet until success 12-47: Non-Determinism
CS411-2015S-12 Turing Mchine Modifictions 12 How to Simulte Non-Deterministic Turing Mchine with Deterministic Turing Mchine Try one computtionl pth if it sys yes, hlt nd sy yes. Otherwise, try different computtionl pth. Repet until success 12-48: Non-Determinism But wht if the first computtionl pth runs forever How to Simulte Non-Deterministic Turing Mchine with Deterministic Turing Mchine Try ll computtionl pths of length 1 Try ll computtionl pths of length 2 Try ll computtionl pths of length 3 If there is hlting configurtion, you will find it eventully. Otherwise, run forever. 12-49: Non-Determinism Originl Tpe c d e f g Work Tpe c d e f g Control Tpe 1 12-50: Non-Determinism, R R R yes R,,, (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) 12-51: Non-Determinism
CS411-2015S-12 Turing Mchine Modifictions 13 Originl Tpe Work Tpe Control Tpe 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0 12-52: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 12-53: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 14 Originl Tpe Work Tpe Control Tpe 2 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0 12-54: Non-Determinism Originl Tpe Work Tpe Control Tpe 2 12-55: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 15 Originl Tpe Work Tpe Control Tpe 1 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0 12-56: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 1 12-57: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 16 Originl Tpe Work Tpe Control Tpe 1 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: 12-58: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 2 12-59: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0
CS411-2015S-12 Turing Mchine Modifictions 17 Originl Tpe Work Tpe Control Tpe 1 2 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: 12-60: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 2 12-61: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 18 Originl Tpe Work Tpe Control Tpe 2 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0 12-62: Non-Determinism Originl Tpe Work Tpe Control Tpe 2 1 12-63: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 19 Originl Tpe Work Tpe Control Tpe 2 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: 12-64: Non-Determinism Originl Tpe Work Tpe Control Tpe 2 2 12-65: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0
CS411-2015S-12 Turing Mchine Modifictions 20 Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: q0 12-66: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 12-67: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 21 Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: 12-68: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 12-69: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 22 Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: 12-70: Non-Determinism Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 12-71: Non-Determinism (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte:
CS411-2015S-12 Turing Mchine Modifictions 23 Originl Tpe Work Tpe Control Tpe 1 1 1 2 1 1 12-72: Turing Mchines (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) (,R) yes (,R) (,R) (,R) Stte: yes Some Turing Mchine review prolems: Crete Turing Mchine tht semi-decides the lnguge L = ll strings over {, } with t lest s mny s s s 12-73: Turing Mchines Crete Turing Mchine tht semi-decides the lngugel=ll strings over{, } with t lest s mny s s s R, yes X L R X L 12-74: Turing Mchines Some Turing Mchine review prolems: Crete Turing Mchine tht computes the function lgx, wherex is inry numer 12-75: Turing Mchines Some Turing Mchine review prolems: Crete Turing Mchine tht computes the function lgx, wherex is inry numer
CS411-2015S-12 Turing Mchine Modifictions 24 12-76: Turing Mchines Set result to 0 While x 2, dividexy 2, nd dd one to the result Crete Turing Mchine tht computes the function lgx, wherexis inry numer 0 R R0L L YR 0 1 R 1 R M INC L L R M LeftShift 12-77: Turing Mchines 0,1 Crete Turing Mchine tht computes the function lgx, wherexis inry numer Set mrker for shifting t end of computtion Eliminte leding zeroes Initilize result to 0 0 R R0L L YR 0 1 R 1 R M INC L R M LeftShift 0,1 Blnk out MSB 12-78: Turing Mchines M LeftShift Increment Result R x=0,1 ZL Y R x R Z R x=0,1 L Y