Foundations of Computer Science Lecture 26 Turing Machines The - - PowerPoint PPT Presentation

foundations of computer science lecture 26 turing machines
SMART_READER_LITE
LIVE PREVIEW

Foundations of Computer Science Lecture 26 Turing Machines The - - PowerPoint PPT Presentation

Foundations of Computer Science Lecture 26 Turing Machines The Turing Machine: DFA with Random Access Memory (RAM) Transducer Turing Machines Infinite Loops Encodings of Turing Machines Last Time: CFGs and Pushdown Automata L = { w # w r | w


slide-1
SLIDE 1

Foundations of Computer Science Lecture 26 Turing Machines

The Turing Machine: DFA with Random Access Memory (RAM) Transducer Turing Machines Infinite Loops Encodings of Turing Machines

slide-2
SLIDE 2

Last Time: CFGs and Pushdown Automata

L = {w#wr | w ∈ {0, 1}∗} S → # | 0S0 | 1S1

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 0 # 0 1 1

DFA with stack memory (push, pop, read). Push the first half of the string. For each bit in the second half, pop the stack and compare.

DFAs with stack memory closely related to CFGs.

Creator: Malik Magdon-Ismail Turing Machines: 2 / 13 Non Context Free →

slide-3
SLIDE 3

Non Context Free

{w#w}

repetition

{0•n1•n0•n}

multiple-equality

{0•n2}, {0•n1•n2}

squaring

{0•2n}, {0•n1•2n}

exponentiation

w#wr w#w 0•n1•n0•n

Creator: Malik Magdon-Ismail Turing Machines: 3 / 13 Today →

slide-4
SLIDE 4

Non Context Free

{w#w}

repetition

{0•n1•n0•n}

multiple-equality

{0•n2}, {0•n1•n2}

squaring

{0•2n}, {0•n1•2n}

exponentiation

w#wr w#w 0•n1•n0•n

1 1

0 0 1 1

1 1

0 0 1 1

1 1 1

0 0 0 1 1 1

0011 is pushed. 0011 is pushed. 000111 is pushed onto the stack.

Creator: Malik Magdon-Ismail Turing Machines: 3 / 13 Today →

slide-5
SLIDE 5

Non Context Free

{w#w}

repetition

{0•n1•n0•n}

multiple-equality

{0•n2}, {0•n1•n2}

squaring

{0•2n}, {0•n1•2n}

exponentiation

w#wr w#w 0•n1•n0•n

1 1

0 0 1 1 0 0 1 1#1 1 0 0

m a t c h ; p

  • p

1 1

0 0 1 1

1 1 1

0 0 0 1 1 1

0011 is pushed. DFA matches 1100 by popping. 0011 is pushed. 000111 is pushed onto the stack.

Creator: Malik Magdon-Ismail Turing Machines: 3 / 13 Today →

slide-6
SLIDE 6

Non Context Free

{w#w}

repetition

{0•n1•n0•n}

multiple-equality

{0•n2}, {0•n1•n2}

squaring

{0•2n}, {0•n1•2n}

exponentiation

w#wr w#w 0•n1•n0•n

1 1

0 0 1 1 0 0 1 1#1 1 0 0

m a t c h ; p

  • p

1 1

0 0 1 1 0 0 1 1#0 0 1 1

match; pop 1 1 1

0 0 0 1 1 1

0011 is pushed. DFA matches 1100 by popping. 0011 is pushed. DFA needs bottom-access to match. 000111 is pushed onto the stack.

Creator: Malik Magdon-Ismail Turing Machines: 3 / 13 Today →

slide-7
SLIDE 7

Non Context Free

{w#w}

repetition

{0•n1•n0•n}

multiple-equality

{0•n2}, {0•n1•n2}

squaring

{0•2n}, {0•n1•2n}

exponentiation

w#wr w#w 0•n1•n0•n

1 1

0 0 1 1 0 0 1 1#1 1 0 0

m a t c h ; p

  • p

1 1

0 0 1 1 0 0 1 1#0 0 1 1

match; pop 1 1 1

0 0 0 1 1 1 0 0 0 1 1 1 0 0 0

match; pop

0011 is pushed. DFA matches 1100 by popping. 0011 is pushed. DFA needs bottom-access to match. 000111 is pushed onto the stack. DFA needs random access to match.

The file clerk who only has access to the top of his stack of papers has fundamentally less power than the file clerk who has a filing cabinet with access to all his papers.

We need a new model, one with Random Access Memory (RAM).

Creator: Malik Magdon-Ismail Turing Machines: 3 / 13 Today →

slide-8
SLIDE 8

Today: Turing Machines

1

Solving a non context free language: w#wr.

2

Transducer Turing Machines.

3

Infinite Loops

4

Encodings of Turing Machines

Creator: Malik Magdon-Ismail Turing Machines: 4 / 13 Turing’s 1936 Miracle →

slide-9
SLIDE 9

Turing’s 1936 Miracle

“On Computable Numbers with an Application to the Entscheidungsproblem” A classic which epitomizes the beauty of pure thought, where Alan Turing Invented a notion of what it means for a number to be computable. Invented the computer. Invented and used subroutines. Invented the programmable computer. Gave a negative answer to Hilbert’s Entscheidungsproblem. All this before the world even saw its first computer. Wow!

(Oh, and by the way, he helped Britain win WWII against Hitler by decrypting the Enigma machine.)

. . . and for all this, society drove him to suicide. Go figure!

Creator: Malik Magdon-Ismail Turing Machines: 5 / 13 Turing’s Machine →

slide-10
SLIDE 10

Turing’s Machine

*

1 # 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ q0 q5 q4 q3 q2 q1 L R

States. Can move L/R (or stay put) giving random access to an infinite read-write tape. Input written on the tape to start. Instructions specify what to do based on state and what is on the tape. Beacon symbol ∗ (start of the tape). Let’s see the capabilities of this machine on the non context free problem

L = {w#w}.

Creator: Malik Magdon-Ismail Turing Machines: 6 / 13 Solving w#w →

slide-11
SLIDE 11

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-12
SLIDE 12

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-13
SLIDE 13

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-14
SLIDE 14

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-15
SLIDE 15

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-16
SLIDE 16

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-17
SLIDE 17

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-18
SLIDE 18

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-19
SLIDE 19

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-20
SLIDE 20

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-21
SLIDE 21

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 3,5: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-22
SLIDE 22

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 3,5: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-23
SLIDE 23

Solving w#w

001#001

1: Check for one “#”, otherwise reject (a DFA can do this). 2: Return to “∗”. 3: Move right to first non-marked bit before “#”. Mark the location and remember the bit. (If you reach “#” before any non-marked bit, goto step 5.) 4: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, reject. If the bit does not match the bit from step 3, reject. Otherwise (bit matches), mark the location. goto step 2. 5: Move right to first non-marked bit after “#”. If you reach “␣” before any non-marked bit, accept. If you find a bit (string on the right is too long), reject.

* 0 0 1 # 0 0 1 ␣ * 0 0 1 # 0 0 1 ␣

* 0 0 1 # 0 0 1 ␣

✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ 3: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ 4: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 2: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓ 3,5: * 0 0 1 # 0 0 1 ␣ ✓ ✓ ✓ ✓ ✓ ✓

yes

Creator: Malik Magdon-Ismail Turing Machines: 7 / 13 Turing Machine Instructions →

slide-24
SLIDE 24

Turing Machine Instructions

DFA instruction: q10q3

← if in q1 and read 0, transition to q3

Creator: Malik Magdon-Ismail Turing Machines: 8 / 13 Building the Turing Machine →

slide-25
SLIDE 25

Turing Machine Instructions

DFA instruction: q10q3

← if in q1 and read 0, transition to q3

{q1} {0} → {q3} {1} {R}

current state read next state write move q1 q3

{0}{1}{R}

* 0 0 1 # 0 0 1

␣ ␣ q0 q3 q2 q1

Creator: Malik Magdon-Ismail Turing Machines: 8 / 13 Building the Turing Machine →

slide-26
SLIDE 26

Turing Machine Instructions

DFA instruction: q10q3

← if in q1 and read 0, transition to q3

{q1} {0} → {q3} {1} {R}

current state read next state write move q1 q3

{0}{1}{R}

* 0 0 1 # 0 0 1

␣ ␣ q0 q3 q2 q1

* 1 0 1 # 0 0 1

␣ ␣ q0 q3 q2 q1

Creator: Malik Magdon-Ismail Turing Machines: 8 / 13 Building the Turing Machine →

slide-27
SLIDE 27

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-28
SLIDE 28

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

step 1

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-29
SLIDE 29

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

step 1 {∗,0,1}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-30
SLIDE 30

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

step 1 q1 E {∗,0,1}{}{R} {#}{}{R} {␣}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-31
SLIDE 31

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

step 1 q1 E {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-32
SLIDE 32

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-33
SLIDE 33

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-34
SLIDE 34

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 {␣,0,1,#}{}{L}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-35
SLIDE 35

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-36
SLIDE 36

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-37
SLIDE 37

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 {∗,✓}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-38
SLIDE 38

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

{∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-39
SLIDE 39

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-40
SLIDE 40

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-41
SLIDE 41

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

{0,1}{}{R} {0,1}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-42
SLIDE 42

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

{0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-43
SLIDE 43

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

{0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-44
SLIDE 44

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-45
SLIDE 45

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-46
SLIDE 46

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

5

Move right to first non-marked bit after “#”. If you reach “␣”, accept. If you come to a non-marked bit, reject.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{} step 5

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-47
SLIDE 47

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

5

Move right to first non-marked bit after “#”. If you reach “␣”, accept. If you come to a non-marked bit, reject.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{} step 5 {✓}{}{R}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-48
SLIDE 48

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

5

Move right to first non-marked bit after “#”. If you reach “␣”, accept. If you come to a non-marked bit, reject.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{} step 5 {✓}{}{R} {0,1}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-49
SLIDE 49

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

5

Move right to first non-marked bit after “#”. If you reach “␣”, accept. If you come to a non-marked bit, reject.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{} step 5 A {✓}{}{R} {0,1}{}{} {␣}{}{}

Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-50
SLIDE 50

Building the Turing Machine that Solves w#w

1

Check for one “#”, otherwise reject (a DFA can do this).

2

Return to “∗”.

3

Move right to first non-marked bit before “#”. Mark and remember the bit. If you reached “#” before any non-marked bit, goto step 5.

4

Move right to first non-marked bit after “#”. If you reach “␣” or bit does not match, reject. If bit matches, mark the location. goto step 2.

5

Move right to first non-marked bit after “#”. If you reach “␣”, accept. If you come to a non-marked bit, reject.

step 1 q1 E step 2 {∗,0,1}{}{R} {#}{}{R} {␣}{}{} {0,1}{}{R} {␣}{}{} {#}{}{} step 2 step 3 {␣,0,1,#}{}{L} {∗}{}{} step 3 step 4 z4

  • 4

step 5 {∗,✓}{}{R} {0}{✓}{R} {1}{✓}{R} {#}{}{R} z4

  • 4

z5

  • 5

E step 2 {0,1}{}{R} {0,1}{}{R} {#}{}{R} {#}{}{R} {✓}{}{R} {✓}{}{R} {0,␣}{}{} {1,␣}{}{} {1}{✓}{} {0}{✓}{} step 5 A {✓}{}{R} {0,1}{}{} {␣}{}{}

A

halt and accept

E

halt and reject Creator: Malik Magdon-Ismail Turing Machines: 9 / 13 Turing Machine for Multiplication →

slide-51
SLIDE 51

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-52
SLIDE 52

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-53
SLIDE 53

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-54
SLIDE 54

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-55
SLIDE 55

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-56
SLIDE 56

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-57
SLIDE 57

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-58
SLIDE 58

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-59
SLIDE 59

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-60
SLIDE 60

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-61
SLIDE 61

Turing Machine for Multiplication

Lmult = {0•i#1•j#0•k | i, j > 0 and k = i × j}

*

# 1 1 1 # ␣ ␣

Multiplication is repeated addition. Pair each left-0 with a block of right-0s equal to the number of 1s 1: Verify the input format is 0•i#1•j#0•k (A DFA can solve this). 2: Return to ∗. 3: Move right to mark first unmarked left-0, then right to “#”. If no unmarked left-0’s (you reach “#”), goto step 6. 4: Move right and mark first unmarked 1. If all 1’s marked (reach “#”) move left, unmarking 1’s. goto step 2. 5: Move right to find an unmarked right-0. If no unmarked right-0’s (come to “␣”), reject Otherwise, mark the 0, move left to first marked 1. goto step 4. 6: Move right to verify there are no unmarked right-zeros. If come to unmarked right-zero, reject; if come to “␣” accept.

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓ ✓ ✓ ✓

* 0 0 # 1 1 1 # 0 0 0 0 0 0

␣ ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 10 / 13 Transducer Turing Machine →

slide-62
SLIDE 62

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-63
SLIDE 63

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-64
SLIDE 64

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-65
SLIDE 65

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-66
SLIDE 66

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-67
SLIDE 67

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-68
SLIDE 68

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-69
SLIDE 69

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-70
SLIDE 70

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-71
SLIDE 71

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-72
SLIDE 72

Transducer Turing Machine That Multiplies

*

# 1 1 1 ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣ ␣

*

# 1 1 1 # ␣ ␣

Algorithm is basically the same. Instead of marking right-0s, write.

* 0

# 1 1 1 # # 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓ ✓ ✓ ✓

* 0

# 1 1 1 # ␣ ␣ ␣ ␣ ␣ ✓

Creator: Malik Magdon-Ismail Turing Machines: 11 / 13 Infinite Loops →

slide-73
SLIDE 73

Infinite Loops

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

What happens if the input is 01?

Creator: Malik Magdon-Ismail Turing Machines: 12 / 13 Encoding a Turing Machine →

slide-74
SLIDE 74

Infinite Loops

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

What happens if the input is 01? M(w) =

                

Halts in an accept state → accept Halts in a reject state → reject Loops forever → ?

Creator: Malik Magdon-Ismail Turing Machines: 12 / 13 Encoding a Turing Machine →

slide-75
SLIDE 75

Infinite Loops

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

What happens if the input is 01? M(w) =

                

Halts in an accept state → accept Halts in a reject state → reject Loops forever → ?

Turing Machine M is a recognizer for language L(M):

w ∈ L(M) ↔ M(w) = halt with a yes; w ∈ L(M) ↔ M(w) = halt with a no or loop forever.

Creator: Malik Magdon-Ismail Turing Machines: 12 / 13 Encoding a Turing Machine →

slide-76
SLIDE 76

Infinite Loops

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

What happens if the input is 01? M(w) =

                

Halts in an accept state → accept Halts in a reject state → reject Loops forever → ?

Turing Machine M is a recognizer for language L(M):

w ∈ L(M) ↔ M(w) = halt with a yes; w ∈ L(M) ↔ M(w) = halt with a no or loop forever.

Turing Machine M is a decider for language L(M):

w ∈ L(M) ↔ M(w) = halt with a yes; w ∈ L(M) ↔ M(w) = halt with a no.

Practical algorithms must halt! Practical algorithms correspond to deciders.

Creator: Malik Magdon-Ismail Turing Machines: 12 / 13 Encoding a Turing Machine →

slide-77
SLIDE 77

Encoding a Turing Machine as A Bit-String

Mathematical Description of a Turing Machine

1.

States Q. The first state is the start state, the halting states are a,r.

1

  • States. {q0, q1, a, e}

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

Creator: Malik Magdon-Ismail Turing Machines: 13 / 13

slide-78
SLIDE 78

Encoding a Turing Machine as A Bit-String

Mathematical Description of a Turing Machine

1.

States Q. The first state is the start state, the halting states are a,r.

2.

Symbols Σ. By default these are {∗, 0, 1, ␣, #}.

1

  • States. {q0, q1, a, e}

2

  • Symbols. {∗, 0, 1, ␣, #}

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

Creator: Malik Magdon-Ismail Turing Machines: 13 / 13

slide-79
SLIDE 79

Encoding a Turing Machine as A Bit-String

Mathematical Description of a Turing Machine

1.

States Q. The first state is the start state, the halting states are a,r.

2.

Symbols Σ. By default these are {∗, 0, 1, ␣, #}.

3.

Machine-level transition instructions. Each instruction has the form {state}{read-symbol}{next-state}{written-symbol}{move} The instructions map each (state,symbol) pair to a (state,symbol,move) triple and thus form a transition function δ : Q × Σ → Q × Σ × {L,R,S}.

1

  • States. {q0, q1, a, e}

2

  • Symbols. {∗, 0, 1, ␣, #}

3

Machine-level transition instructions.

{q0}{∗}{q0}{∗}{R} {q0}{1}{q0}{1}{R} {q0}{0}{q1}{0}{R} {q0}{#}{e} {#}{S} {q0}{␣}{e} {␣}{S} {q1}{1}{q0}{1}{L} {q1}{0}{a} {0}{S} {q1}{#}{a} {#}{S} {q1}{␣}{a} {␣}{S}

q0 q1 A E {0}{}{R} {#,␣}{}{} {0,#,␣}{}{} {∗,1}{}{R} {1}{}{L}

The description of a Turing Machine is a finite binary string. Turing machines are countable and can be listed: {M1, M2, . . .}. The problems solvable by an algorithm are countable: {L(M1), L(M2), . . .}.

Creator: Malik Magdon-Ismail Turing Machines: 13 / 13