1 / 31

Simulating 2-way Infinite Tape TM with Basic TM

This lecture explores the approach of simulating a 2-way infinite tape Turing Machine using a basic Turing Machine. The construction and techniques involved in simulating the 2-way infinite tape TM are discussed.

brownjane
Download Presentation

Simulating 2-way Infinite Tape TM with Basic TM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 22 UofH - COSC 3340 - Dr. Verma

  2. Simulating 2-way infinite tape TM with Basic TM In the following slides we will study the approach of Lewis and Papadimitriou. [Full reference appears in syllabus] UofH - COSC 3340 - Dr. Verma

  3. Illustration of 2-way infinity tape TM … … □ a b b a a b □ □ q0 h q1 q3 q2 UofH - COSC 3340 - Dr. Verma

  4. 2-way infinite tape TM • Assumption: All TMs can, in one move either write a symbol on tape or move the head one cell but not both. • No distinguished leftmost square • Input string anywhere on the tape • Position of the head on the blank just to its right UofH - COSC 3340 - Dr. Verma

  5. 2-way infinite tape TM (contd.) • Computation will proceed as just as for one-way infinite tape • Yield relation |─M between configurations |─M* - Reflexive closure |─M. – Transitive closure UofH - COSC 3340 - Dr. Verma

  6. 2-way infinite tape TM (contd.) • Formally, TM T = (K, , , s) as before Since left and right are symmetric, we would define a configuration of such a machine to be a quadruple (q, w, a, u), where • q K, • w, u  * • a   • w does not begin with □ and u does not end with □ UofH - COSC 3340 - Dr. Verma

  7. Simulating 2-way infinite tape TM with basic TM • Divide the tape into two tracks and copy the input onto the upper track, placing the end-marker $ on the leftmost square. • Simulate TM M1 on the divided tape • When and if M1 would halt, restore the tape to “single-track” format. … … Tape of M1 -3 -2 -1 0 1 2 3 … $ 0 1 2 3 Tape of M2 … -1 -2 -3 -4 UofH - COSC 3340 - Dr. Verma

  8. Schema for M2 • Step 1 is easy – let I be the TM for this step. • Step 3 is a little harder – let F be the TM for this step. • Let M1’ be the TM for Step 2, then M2 is: >I M1’F We discuss details of Step 2. UofH - COSC 3340 - Dr. Verma

  9. Implementing the 2-track Idea Construction of M1’ shows a number of useful techniques: Let 1 = {a: a  1} Let 2 = {$}  1  (1 X 1)  (1 X 1)  (1 X 1) Let state set of M1’ = (K1  {h}) X {1, 2} 1 – upper track, 2 – lower track UofH - COSC 3340 - Dr. Verma

  10. Simulating 2-way infinite tape TM Step 2: a. Simulate M1 on the upper track • A move of the tape head to the left or right by M1 is simulated by a move of the tape head in the same direction by M1’ and if M1 would rewrite a tape square, M1’ changes only the upper track b. Simulate M1 on the lower track • When M1 moves its head, M1’ moves its head in the opposite direction and if M1 write in a tape square, M1’ changes only the lower track. UofH - COSC 3340 - Dr. Verma

  11. Simulate the 2-way infinite tape TM with a basic TM (contd.) Step 2: a. Simulate M1 on the upper track • A move of the tape head to the left or right by M1 is simulated by a move of the tape head in the same direction by M1’ and if M1 would rewrite a tape square, M1’ changes only the upper track • If q K1, (a1, a2)  1 X 1, and 1 (q, a1) = (p, b), then (<p,1>, L)’ if b is L 1’(<q,1>, (a1, a2 ))= (<p,1>, R)’ if b is R (<p,1>, (b, a2))’ if b is 1 UofH - COSC 3340 - Dr. Verma

  12. Simulating 2-way infinite tape b. Simulate M1 on the lower track • When M1 moves its head, M1’ moves its head in the opposite direction and if M1 write in a tape square, M1’ changes only the lower track. • If q K1, (a1, a2)  1 X 1, and 1 (q, a2) = (p, b), then (<p,2>, R)’ if b is L 1’(<q,2>, (a1, a2 ))= (<p,2>, L)’ if b is R (<p,2>, (a1 ,b))’ if b is 1 UofH - COSC 3340 - Dr. Verma

  13. Simulating 2-way infinite tape TM with basic TM (contd.) c. Changing tracks • If head of M1’ is on $ then the head is moved to the right one square, and the information that the other track is being inspected is recorded in the state of M1’ d. Extend the tape to the right • M1’ moves its head to the right onto tape square which contains ordinary blanks rather than member of the alphabet. Blanks are changed to pairs of blank before proceeding. UofH - COSC 3340 - Dr. Verma

  14. Simulating the 2-way infinite tape TM with a basic TM (contd.) c. Change track • If head of M1’ is on $ then the head is moved to the right one square, and the information that the other track is being inspected is recorded in the state of M1’ • If q K1  {h}, then 1’(<q,1>, $)’ = (<q,2>, R)’1’(<q,2>, $)’ = (<q,1>, R)’ UofH - COSC 3340 - Dr. Verma

  15. Simulating the 2-way infinite tape TM with a basic TM (contd.) d. Extend the tape to the right • M1’ moves its head to the right onto tape square which contains ordinary blanks rather than member of the alphabet. Blanks are changed to pairs of blank before proceeding. • If q K1  {h}, then 1’(<q,1>, #)’ = (<q,1>, (#, #))’1’(<q,2>, #)’ = (<q,2>, (#, #))’ UofH - COSC 3340 - Dr. Verma

  16. Simulate the 2-way infinite tape TM with a basic TM (contd.) e. Halt and record head position • M1’ may move into a state which is not the true halt state. M1’ moves from these states into the halt state while recording the head position on the upper or lower track. • If a1,a2  1 , then 1’(<h,1>, (a1,a2))’ = (h, (a1,a2))’1’(<h,2>, (a1,a2))’ = (h, (a1,a2))’ f. All other values of 1’ may be defined arbitrarily UofH - COSC 3340 - Dr. Verma

  17. (ii) Multiple tape TM Tape 1 … Tape 2 … . . . … Tape k q0 Finite control h q1 q3 q2 UofH - COSC 3340 - Dr. Verma

  18. Multiple tape TM • Like ordinary TM but with several tapes. • Each tape with its own read/write head. • Input on tape number 1 initially. UofH - COSC 3340 - Dr. Verma

  19. Example: 2-tape TM for Copying Assume there are 2-tapes: • Move the head on the first tape leftuntil a blank is found. • Move the head on bothtapes to the right, copying each symbol on the first tape onto the second tape, until a blank is found on the first tape. The first square of the second tape should be left blank. UofH - COSC 3340 - Dr. Verma

  20. Example (contd.) • Move the head on the second tape to the leftuntil a blank is found. • Again move the heads on bothtapes to the right, this time copying symbols from the second tape onto the first tape. Halt when a blank is found on the second tape. UofH - COSC 3340 - Dr. Verma

  21. Example (contd.): (1)  # L#(1) #(2) R(1)R(2) (2) 1 2 4 #(1) (2)  # L#(2) R(1)R(2) (1) 3 UofH - COSC 3340 - Dr. Verma

  22. Example (contd.) At the beginning: First tape #w# Second tape # After(1) First tape #w# Second tape # After(2) First tape #w# Second tape #w# After(3) First tape #w# Second tape #w# After(4) First tape #w#w# Second tape #w# UofH - COSC 3340 - Dr. Verma

  23. Simulation of Multiple tape TM with Basic TM We study two approaches: • Given in the text (Sipser) • Given in the reference (Lewis and Papadimitriou). UofH - COSC 3340 - Dr. Verma

  24. Idea behind simulation of Multiple tape TM with Basic TM (Sipser) • Let TM M have k tapes • S simulates the effect of k tapes by storing their information on its single tape using □ as a delimiter. • S must keep track of the location of the heads UofH - COSC 3340 - Dr. Verma

  25. Idea behind simulation of Multiple tape TM with Basic TM … 0 1 0 1 0 □ M … a a a □ … b a □ S □ 0 1 0 1 0 □ a a a □ b a □ UofH - COSC 3340 - Dr. Verma

  26. Simulation of Multiple tape TM with Basic TM • First S puts its tape into the format that represents all k tapes of M • To simulate a single move, S scans its tape from the first in order to determine the symbols under the virtual heads. Then make a second pass to update the M’s transition function • If at any point S moves one of the virtual heads to the right onto a □, it writes a blank symbol on this tape cell and shifts the tape contents to the rightmost □. Then it continues the simulation as before UofH - COSC 3340 - Dr. Verma

  27. (ii) K-tape TM simulated by basic TM Given input w  (1 – {#})*, M2 follows: • Put an endmarker on the leftmost tape square. a # b a # # # 2 = 1  (1 X {0,1})k  {$} … b b b # # # # … $ a # b a # # # # # … 0 0 1 0 0 0 # … b b b # # # # … 0 1 0 0 0 0 # UofH - COSC 3340 - Dr. Verma

  28. K-tape TM simulated by a basic TM • Divide the next |w| + 2 tape square into 2k tracks, putting #w# into the first track and marking the positions of the k heads appropriately. … … $ # a1 a2 an-1 an # # # # … … 0 0 0 0 0 1 # … … # # # # # # # … … 1 0 0 0 0 0 # UofH - COSC 3340 - Dr. Verma

  29. K-tape TM simulated by a basic TM • Simulate the computation by M1, until M1 would halt. Repeat the following sequence of operations, beginning each time with • Scan left down the tape, gathering information about the symbol scanned by the k tape heads of M1. • Go right to the right end of the part of the tape that has been divided into tracks. No writing on the tape occurs during this part of the operation of M2, but when the head has returned to the end, the state finite control has changed to reflect the k-tuple of symbol form 1 in the k tracks at the marked head positions. … UofH - COSC 3340 - Dr. Verma

  30. Simulation of k-tape TM (contd.) • Scan left and then right down the tape to update the tracks in accordance with the move of M1 that is to be simulated. • On each pair of tracks, this involves either moving the head position marker one square to the right or left, or rewriting the symbol from 1 UofH - COSC 3340 - Dr. Verma

  31. K-tape TM simulated by a basic TM • When M1would halt, M2 first converts its tape from track into single symbol format, position its head where M1, would have placed its first head, and then halts. UofH - COSC 3340 - Dr. Verma

More Related