cs411-2015s-12 turing machine modifications - usfcsgalles/cs411/lecture/lecture12.pdf ·...
TRANSCRIPT
![Page 1: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/1.jpg)
Automata TheoryCS411-2015S-12
Turing Machine Modifications
David Galles
Department of Computer Science
University of San Francisco
![Page 2: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/2.jpg)
12-0: Extending Turing Machines
When we added a stack to NFA to get a PDA, weincreased computational power
Can we do the same thing for Turing Machines?
That is, can we add some new “feature” to TMsthat will increase their computational power?
![Page 3: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/3.jpg)
12-1: Multi-Track Tape
Instead of each tape location holding a singlesymbol, we add several “tracks” to the tape
Based on contents of all tracks, either movehead left, move head right, or write new valuesto any of the tracks
a b b c b a
...
Read/write head
![Page 4: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/4.jpg)
12-2: Multi-Track Tape
Can simulate a mutli-track machine with a standardTM
Increase the size of the tape alphabet
k tracks, each with an alphabet of n symbols
New alphabet of size nk
![Page 5: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/5.jpg)
12-3: Multi-Track Tape
a b b b a...
Read/write head
b a b a b
= a=a
b=b
C=a
D=aa
E=ab
F=b
G=ba
H=bb
...GEF EH aRead/write head
![Page 6: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/6.jpg)
12-4: Multiple Tapes
Several tapes, with independent read/write heads
Reach symbol on each tape, and based oncontents of all tapes:
Write or move each tape independently
Transition to new state
a b b c b a ...Read/write head
...
...
Read/write head
Read/write head
![Page 7: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/7.jpg)
12-5: Multiple Tapes
Create a 2-Tape Machine that adds two numbers
Convert ⊲⊔w; v to ⊲⊔w + v (leading zeros OK)
Assume that tape 1 holds input (and output), andtape 2 starts out with blanks
![Page 8: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/8.jpg)
12-6: Multiple Tapes
Create a 2-Tape Machine that adds two numbers
Convert ⊲⊔w; v to ⊲⊔w + v (leading zeros OK)
Copy first # to second tape (zeroing out first # onfirst tape)
Do “standard addition”, keeping track of carries.
![Page 9: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/9.jpg)
12-7: Multiple Tapes
Create a 2-Tape Machine that adds two numbers
R1,2 a =1
0 a1 2
0 R1 1
L1,2
0 1, 1 01 12 2
1 1
0 01 2
0 1
1 11 2
0 1
L1,2
0 1, 1 01 12 2
0 1
0 01 2
1 1
1 11 2
0 1
0 1 2
1 1
1 1 2
0 L1 1
1 1 2
0 1 2
1 1 2
![Page 10: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/10.jpg)
12-8: Multiple Tapes
Are k-tape machines more powerful than 1-tapemachines?
![Page 11: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/11.jpg)
12-9: Multiple Tapes
a b b c b a ...
...
...
b c b b a
b b a
...a b b c b a
b c b b a
b b a
1
1
1
![Page 12: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/12.jpg)
12-10: Multiple Tapes
Each transition from the original, multi-tapemachine will require several transitions from thesimulated machine – and each state in themultiple-tape machine will be represented by a setof states in the simulation machine
First, need to scan tape head to find all “virtualheads”, and remember what symbol is stored ateach head location
Use state to store this information
Next, scan tape to implement the action oneach tape (moving head, rewriting symbols, etc)
Finally, transition to a new set of states
![Page 13: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/13.jpg)
12-11: 2-Way Infinite Tape
... ...Read/write head
a b c d e f g h i
![Page 14: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/14.jpg)
12-12: 2-Way Infinite Tape
...
... ...Read/write head
a b c d e f g h i
f g h i
e d c b a*
Read/write head
![Page 15: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/15.jpg)
12-13: 2-Way Infinite Tape
Make 2 copies of states in original machine: Oneset for top tape, one set for bottom tape
Top Tape States
Use the top track
Execute as normal
When “Move Left” command, and beginning oftape symbol is on the bottom tape, move Rightinstead, switch to Bottom Tape States
![Page 16: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/16.jpg)
12-14: 2-Way Infinite Tape
Make 2 copies of states in original machine: Oneset for top tape, one set for bottom tape
Bottom Tape States
Use the bottom track
Move left on a “Move Right” command, moveright on a “Move Left” command
When the beginning of tape symbol isencountered, switch to Top Tape States
![Page 17: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/17.jpg)
12-15: Simple Computer
CPU
3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)
Memory
Operation:
Set IR → MEM[PC]
Increment PC
Execute instruction in IR
Repeat
![Page 18: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/18.jpg)
12-16: Simple Computer
CPUInstruction
Register
Program
Counter
Accumulator
Registers
Memory
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 ...
![Page 19: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/19.jpg)
12-17: Simple Computer
Instruction Meaning
00 HALT Stop Computation
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← x if ACC = 0
10 JGT x IP← x if ACC > 0
Write a program that multiplies two numbers (in loca-
tions 1000 & 1001), and stores the result in 1002
![Page 20: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/20.jpg)
12-18: Simple Computer
Memory Machine Code Assembly
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
![Page 21: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/21.jpg)
12-19: Computers & TMs
We can simulate this computer with a multi-tapeTuring machine:
One tape for each register (IR, IP, ACC)
One tape for the MemoryMemory tape will be entries of the form<address> <contents>
![Page 22: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/22.jpg)
12-20: Computers & TMs
Memory
address contents
...
Instruction Pointer...
Instruction Register...
Accumulator...0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 1
1 1 0 0 0
0
![Page 23: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/23.jpg)
12-21: Computers & TMs
Operation:
Scan through memory until reach an addressthat matches the IP
Copy contents of memory at that address to theIR
Increment IP
Based on the instruction code:Copy value into IPCopy a value into MemoryCopy a value into the ACCDo addition/subtraction
![Page 24: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/24.jpg)
12-22: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 1
0
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
...
![Page 25: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/25.jpg)
12-23: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 1
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 26: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/26.jpg)
12-24: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 1
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 01 10
(LOAD 1000)
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 27: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/27.jpg)
12-25: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 01 10
(LOAD 1000)
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 28: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/28.jpg)
12-26: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 01 10
(LOAD 1000)
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 29: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/29.jpg)
12-27: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator...
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 01 10
(LOAD 1000)
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
0 2 10 00
![Page 30: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/30.jpg)
12-28: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
...0 2 10 00
![Page 31: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/31.jpg)
12-29: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
...0 2 10 00
![Page 32: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/32.jpg)
12-30: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 2
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 013 3
(STORE 1003)
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
...0 2 10 00
![Page 33: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/33.jpg)
12-31: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 3
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 013 3
(STORE 1003)
...0 2 10 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 34: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/34.jpg)
12-32: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 3
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 013 3
(STORE 1003)
...0 2 10 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0& & & & & & &0 00 0 01 0 5 2 0 3 0 00 ...
![Page 35: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/35.jpg)
12-33: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 3
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
0 0 013 3
(STORE 1003)
...0 2 10 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 2& & & & & & &0 00 0 01 0 5 2 0 3 0 10 ...
![Page 36: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/36.jpg)
12-34: Computers & TMs
Memory
Instruction Pointer
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& & & & & & &1 11 1 12 3 3 3 2 4 3 2
0 0 0 3
0
0 0 0 0 0 3 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0& & & & & & &2 15 0 16 9 2 7 7 8 3 30
...
Instruction Register...
Accumulator
0 0 0 0 0 2 0 0 1 0 0 0 0 0 1 0 0 0 0 4 0 0 1 0 0 0& & & & & & &1 19 1 00 4 1 1 8 2 0 00
...0 2 10 00
... 1 0 0 0 2 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 2& & & & & & &0 00 0 01 0 5 2 0 3 0 10 ...
![Page 37: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/37.jpg)
12-35: Computers & TMs
“Simple Computer” can be modeled by a TuringMachine
Any current machine can be modeled in the sameway by a Turing Machine
If there is an algorithm for it, a Turning Machinecan do it
Note that at this point, we don’t care how long itmight take, just that it can be done
![Page 38: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/38.jpg)
12-36: Turing Complete
A computation formalism is “Turing Complete” if itcan simulate a Turing Machine
Turing Complete ⇒ can compute anything
Of course it might not be convenient ...
![Page 39: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/39.jpg)
12-37: Non-Determinism
Final extension to Turing Machines:Non-Determinism
Just like non-determinism in NFAs, PDAs
String is accepted by a non-deterministic TuringMachine if there is at least one computationalpath that accepts
![Page 40: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/40.jpg)
12-38: Non-Determinism
A Non-Deterministic Machine M Decides a language Lif:
All computational paths halt
For each w ∈ L, at least one computational pathfor w accepts
For all w 6∈ L, no computational path accepts
![Page 41: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/41.jpg)
12-39: Non-Determinism
A Non-Deterministic Machine M Semi-Decides alanguage L if:
For each w ∈ L, at least one computational pathfor w halts and accepts
For all w 6∈ L, no computational path halts andaccepts
![Page 42: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/42.jpg)
12-40: Non-Determinism
A Non-Deterministic Machine M Computes a Functionif:
All computational paths halt
Every computational path produces the sameresult
![Page 43: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/43.jpg)
12-41: Non-Determinism
Non-Deterministic TM for L = {w ∈ {0, 1} : w is
composite }
(semi-decides is OK)
![Page 44: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/44.jpg)
12-42: Non-Determinism
Non-Deterministic TM for L = {w ∈ {0, 1} : w is
composite }
R R
0
1
; R
0
1
L MMULT
Mw w
How could we make this machine decide (instead of
semi-decide) L?
![Page 45: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/45.jpg)
12-43: Non-Determinism
How we can make this machine decide (instead ofsemi-decide) L
First, transform w into w ⊔ w;w
Non-deterministically modify the second 2 w’s
Multiply the second 2 w’s
Check to see if the resulting string is w ⊔ w
![Page 46: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/46.jpg)
12-44: Non-Determinism
Are Non-Deterministic Turing Machines morepowerful than Deterministic Turing machines?
Is there some L which can be semi-decided bya non-deterministic Turing Machine, whichcannot be semi-decided by a DeterministicTuring Machine?
Non-determinism in Finite Automata didn’t buy usanything
Non-determinism in Push-Down Automata did
![Page 47: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/47.jpg)
12-45: Non-Determinism
How to Simulate a Non-Deterministic TuringMachine with a Deterministic Turing Machine
![Page 48: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/48.jpg)
12-46: Non-Determinism
How to Simulate a Non-Deterministic TuringMachine with a Deterministic Turing Machine
Try one computational path – if it says yes, haltand say yes. Otherwise, try a differentcomputational path. Repeat until success
![Page 49: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/49.jpg)
12-47: Non-Determinism
How to Simulate a Non-Deterministic TuringMachine with a Deterministic Turing Machine
Try one computational path – if it says yes, haltand say yes. Otherwise, try a differentcomputational path. Repeat until success
But what if the first computational path runsforever . . .
![Page 50: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/50.jpg)
12-48: Non-Determinism
How to Simulate a Non-Deterministic TuringMachine with a Deterministic Turing Machine
Try all computational paths of length 1
Try all computational paths of length 2
Try all computational paths of length 3. . .
If there is a halting configuration, you will find iteventually. Otherwise, run forever.
![Page 51: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/51.jpg)
12-49: Non-Determinism
...1
Control Tape
...a
Original Tape
...Work Tape
b c d e f g
a b c d e f g
![Page 52: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/52.jpg)
12-50: Non-Determinism
R R R yes
R
a,b
a a
b,b,
b, q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 53: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/53.jpg)
12-51: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 54: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/54.jpg)
12-52: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 55: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/55.jpg)
12-53: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 56: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/56.jpg)
12-54: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 57: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/57.jpg)
12-55: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 58: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/58.jpg)
12-56: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 59: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/59.jpg)
12-57: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 60: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/60.jpg)
12-58: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 2 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 61: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/61.jpg)
12-59: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 2 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 62: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/62.jpg)
12-60: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 2 ...State: q2
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 63: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/63.jpg)
12-61: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 1 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 64: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/64.jpg)
12-62: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 65: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/65.jpg)
12-63: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 66: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/66.jpg)
12-64: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
2 2 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 67: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/67.jpg)
12-65: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q0
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 68: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/68.jpg)
12-66: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 69: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/69.jpg)
12-67: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 70: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/70.jpg)
12-68: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q1
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 71: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/71.jpg)
12-69: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q2
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 72: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/72.jpg)
12-70: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: q3
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 73: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/73.jpg)
12-71: Non-Determinism
Control Tape
a b a a
Original Tape
Work Tape
...
a b a a ...
1 1 1 2 1 1 ...State: yes
q1
(q2,R)
q2
q3
q4
a b
q0 (q1,R) (q1,R) (q1,R)
(q1,R) (q1,R) (q4,R)
(q3,R) (q4,R) (q4,R)
(q4,R) (q4,R) yes
(q4,R) (q4,R) (q4,R)
![Page 74: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/74.jpg)
12-72: Turing Machines
Some Turing Machine review problems:
Create a Turing Machine that semi-decides thelanguage L = all strings over {a, b} with at leastas many a’s as b’s
![Page 75: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/75.jpg)
12-73: Turing Machines
Create a Turing Machine that semi-decides thelanguage L = all strings over {a, b} with at least asmany a’s as b’s
R b,
X L R a L
b
yes
X
![Page 76: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/76.jpg)
12-74: Turing Machines
Some Turing Machine review problems:
Create a Turing Machine that computes the
function ⌈lg x⌉, where x is a binary number
![Page 77: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/77.jpg)
12-75: Turing Machines
Some Turing Machine review problems:
Create a Turing Machine that computes the
function ⌈lg x⌉, where x is a binary numberSet result to 0While x ≤ 2, divide x by 2, and add one tothe result
![Page 78: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/78.jpg)
12-76: Turing Machines
Create a Turing Machine that computes the
function ⌈lg x⌉, where x is a binary number
YR0
R
R
R R0L L
MINC L L R
0,1
M LeftShift
0
11
![Page 79: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/79.jpg)
12-77: Turing Machines
Create a Turing Machine that computes the
function ⌈lg x⌉, where x is a binary number
YR0
R
R
R R0L L
MINC L R
0,1
M LeftShift
0
11
Initialize result to 0Eliminate leading zeroes
Set marker for shifting at end of computation
Blank out
MSBIncrement
Result
![Page 80: CS411-2015S-12 Turing Machine Modifications - USFCSgalles/cs411/lecture/lecture12.pdf · CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science](https://reader033.vdocuments.us/reader033/viewer/2022041413/5e197c5403e9da70fb08ff73/html5/thumbnails/80.jpg)
12-78: Turing Machines
R
M LeftShift
x=0,1
ZLY
x RZ
R
x=0,1
R LY