turing machine read/write – move left/right bb read/write head 001000 state qi

43
Turing Machine Read/Write – Move Left/Right B B Read/Write Head 0 0 1 0 0 0 State Qi

Upload: katelynn-leedom

Post on 14-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Turing MachineRead/Write – Move Left/Right

B B

Read/Write Head

0 0 1 0 0 0

State Qi

Page 2: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

State Diagram for Modulus 3shows only the tape input

Q0

Q1

Q2

Start 1

1

00

1

0

Q3 Q4

BB

B

B,0,1

Page 3: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Turing MachineProgram To Compute Values

Modulus 3State, Write, Direction

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

Page 4: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B B1 1 0 1 0 1

State Q0

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

New State – Write B

Page 5: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB 1 0 1 0 1

State Q1

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

Page 6: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB B 0 1 0 1

State Q0

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

Write B

Page 7: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB B B 1 0 1

State Q0

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L New State – Write B

Page 8: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB B B B 0 1

State Q1

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,LNew State – Write B

Page 9: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB B B B B 1

State Q2

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,LWrite B

Page 10: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B BB B B B B B

State Q2

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

New State – Write 0

Page 11: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B 0B B B B B B

State Q4

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

New State – Write 1

Page 12: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Modulus 353 % 3

B 0B B B B B 1

Q3 Halt

State B 0 1

Q0 3,0,L, 0,B,R 1,B,R

Q1 3,1,L 2,B,R 0,B,R

Q2 4,0,L 1,B,R 2,B,R

Q3 Halt Halt Halt

Q4 3,1,L 3,1,L 3,1,L

Page 13: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Turing MachineProgram To Add Unary Numbers

State, Write, Direction

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 3,1,Halt Halt 3,1,L

Page 14: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary Numbers2 + 3 = 5

B B1 1 0 1 1 1

State Q0

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 15: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 0 1 1 1

State Q0

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 16: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 0 1 1 1

State Q0 New State – Write B

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 17: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 1

State Q1

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 18: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 1

State Q1

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 19: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 1

State Q1

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 20: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 1

State Q1New State

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 21: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 1

State Q2

New State – Write B

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 22: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 B

State Q3

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 23: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 B 1 1 B

State Q3

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 24: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Adding Two Unary numbers 2 + 3 = 5

B B1 1 1 1 1 B

Q3 HALT HALT – Write 1

State B 0 1

Q0 Halt 1,B,R 0,1,R

Q1 2,B,L Halt 1,1,R

Q2 Halt Halt 3,B,L

Q3 - 1,Halt Halt 3,1,L

Page 25: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Turing MachineProgram To Subtract Unary Numbers

State, Write, Direction

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 26: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Turing Machine with Halt State Program To Subtract Unary Numbers

State, Write, Direction

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,4 1,B,4 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,4 3,B,4 0,B,R

Q4 Halt Halt Halt

Page 27: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 1

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 28: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 1

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

. . .

Page 29: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 1

State Q1

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 30: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 B

State Q2

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 31: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 B

State Q2

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 32: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 B

State Q2

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

. . .

Page 33: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B B1 1 1 0 1 B

State Q3

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 34: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 1 B

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 35: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 1 B

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

. . .

Page 36: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 1 B

State Q1

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 37: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 B B

State Q2

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 38: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 B B

State Q2

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

. . .

Page 39: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB 1 1 0 B B

State Q3

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 40: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB B 1 0 B B

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 41: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB B 1 0 B B

State Q0

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 2,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

. . .

Page 42: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB B 1 0 B B

Q1

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 1,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R

Page 43: Turing Machine Read/Write – Move Left/Right BB Read/Write Head 001000 State Qi

Subtracting Two Unary Numbers5 − 2 = 3

B BB B 1 B B B

Q1 Halt Write Blank

1 1

State B 0 1

Q0 1,B,L 0,0,R 0,1,R

Q1 1,B,Halt 1,B,Halt 2,B,L

Q2 3,B,R 2,0,L 1,1,L

Q3 3,B,Halt 3,B,Halt 0,B,R