Turing Machine Read/Write – Move Left/Right BB Read/Write Head State Qi
State Diagram for Modulus 3 shows only the tape input Q0 Q1 Q2 Start Q3 Q4 B B B B,0,1
Turing Machine Program To Compute Values Modulus 3 State, Write, Direction State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3 Halt Halt Halt Q43,1,L3,1,L3,1,L
Modulus 3 53 % 3 BB State Q0 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L New State – Write B
Modulus 3 53 % 3 BBB10101 State Q1 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L
Modulus 3 53 % 3 BBBB0101 State Q0 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L Write B
Modulus 3 53 % 3 BBBBB101 State Q0 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L New State – Write B
Modulus 3 53 % 3 BBBBBB01 State Q1 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L New State – Write B
Modulus 3 53 % 3 BBBBBBB1 State Q2 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L Write B
Modulus 3 53 % 3 BBBBBBBB State Q2 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L New State – Write 0
Modulus 3 53 % 3 B0BBBBBB State Q4 State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L New State – Write 1
Modulus 3 53 % 3 B0BBBBB1 Q3 Halt State B 0 1 Q03,0,L,0,B,R1,B,R Q13,1,L2,B,R0,B,R Q24,0,L1,B,R2,B,R Q3Halt Halt Halt Q43,1,L3,1,L3,1,L
Turing Machine Program To Add Unary Numbers State, Write, Direction State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3 3,1,Halt Halt3,1,L
Adding Two Unary Numbers = 5 BB State Q0 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB State Q0 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB State Q0New State – Write B State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B111 State Q1 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B111 State Q1 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B111 State Q1 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B111 State Q1New State State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B111 State Q2 New State – Write B State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B11B State Q3 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11B11B State Q3 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Adding Two Unary numbers = 5 BB11111B Q3 HALT HALT – Write 1 State B 0 1 Q0Halt1,B,R0,1,R Q12,B,L Halt1,1,R Q2Halt Halt3,B,L Q3- 1,Halt Halt3,1,L
Turing Machine Program To Subtract Unary Numbers State, Write, Direction State B 0 1 Q01,B,L0,0,R0,1,R Q1 1,B,Halt 1,B,Halt2,B,L Q23,B,R 2,0,L2,1,L Q3 3,B,Halt 3,B,Halt0,B,R
Turing Machine with Halt State Program To Subtract Unary Numbers State, Write, Direction State B 0 1 Q01,B,L0,0,R0,1,R Q1 1,B,4 1,B,42,B,L Q23,B,R 2,0,L2,1,L Q33,B,4 3,B,40,B,R Q4 Halt Halt Halt
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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...
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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...
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB 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...
Subtracting Two Unary Numbers 5 − 2 = 3 BB B 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB B 11 0B 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB B 11 0B 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...
Subtracting Two Unary Numbers 5 − 2 = 3 BB B 11 0B 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB B B1 0B 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB B B1 0B 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...
Subtracting Two Unary Numbers 5 − 2 = 3 BB B B1 0B 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
Subtracting Two Unary Numbers 5 − 2 = 3 BB B B1 BB B Q1 HaltWrite 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