1 / 23

8. Introduction to Turing Machines

8. Introduction to Turing Machines. CIS 5513 - Automata and Formal Languages – Pei Wang. Extending PDA. PDA cannot accept {0 n 1 n 2 n } or {ww} The restrictions in the power of PDA are in us ing the memory as a stack, and processing the input string character by character Extensions:

jonesjason
Download Presentation

8. Introduction to Turing Machines

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. 8. Introduction to Turing Machines CIS 5513 - Automata and Formal Languages – Pei Wang

  2. Extending PDA PDA cannot accept {0n1n2n} or {ww} The restrictions in the power of PDA are in using the memory as a stack, and processing the input string character by character Extensions: • The memory allows access at any position • The memory contains the input, the intermediate results, and the output

  3. Turing machine • Input: a finite string on an infinite tape • Tape head: can move and access a cell • Transition: from (state, symbol) to (state, symbol, move)

  4. TM definition A (deterministic) Turing machine (TM) M = (Q, Σ, Γ, δ, q0, B, F) where • Γ: A finite tape alphabet, and Σ Γ • B: The blank symbol on tape, in Γ – Σ • δ: A partial function from (Q – F) × Γto Q × Γ× {L,R}, specifying the next state, the changed symbol, and the moving direction The other components are like those of a DFA

  5. Instantaneous descriptions of TM The ID of a TM: X1X2…Xi-1qXiXi+1…Xn • The current state is q • The current symbol under head is Xi • X1 and Xn are the leftmost and rightmost non-blank symbols on tape, respectively • Order of changes: (1) tape symbol, (2) head location, (3) current state

  6. Moves of TM: to left If δ(q, Xi) = (p, Y, L), then X1X2…Xi-2Xi-1qXiXi+1…Xn ˫M X1X2…Xi-2pXi-1YXi+1…Xn • If i = 1, then a blank is added: qX1X2…Xn˫MpBYX2…Xn • If i = n and Y = B, then a blank is omitted: X1X2…Xn-1qXn˫MX1X2…Xn-2pXn-1

  7. Moves of TM: to right If δ(q, Xi) = (p, Y, R), then X1X2…Xi-1qXiXi+1…Xn ˫MX1X2…Xi-1YpXi+1…Xn • If i = n, then a blank is added: X1X2…Xn-1qXn˫MX1X2…Xn-1YpB • If i = 1 and Y = B, then a blank is omitted: qX1X2…Xn˫MpX2…Xn

  8. TM Example 1: TM definition

  9. TM Example 1: transition diagram

  10. TM Example 1: ID derivations

  11. TM Example 2: TM definition Proper subtraction: max(m – n, 0) M = ({q0, …,q6}, {0,1}, {0,1,B}, δ, q0, B) It does not accept any input (0m10n), but stops at q6 with an output (0m–n or blank) on the tape

  12. TM Example 2: transition diagram

  13. TM Example 2: ID derivations • q0000100 ˫q100100 ˫0q10100 ˫00q1100 ˫001q200 ˫00q3110 ˫0q30110 ˫q300110 ˫q3B00110 ˫q000110 ˫q10110 ˫0q1110 ˫01q210 ˫011q20 ˫01q311 ˫0q3111 ˫q30111 ˫q3B0111 ˫ q00111 ˫q1111 ˫1q211 ˫11q21 ˫111q2B ˫11q41 ˫1q41 ˫q41 ˫q4B ˫q60 • q00100 ˫q1100 ˫1q200 ˫q3110 ˫q3B110 ˫q0110 ˫q510 ˫q50 ˫q5B ˫q6B

  14. The language of a TM The language a TM M accepts: L(M) = { w | q0w˫*Mαpβ } where pF, wΣ*, and α, βΓ* L(M) belongs to recursively enumerable (RE) languages A TM halts where the next move is undefined, like an NFA or PDA, while a DFA stops only when the input is exhausted

  15. TM and algorithm Those languages with TM’s that do halt (accepting or not) are called recursive A TM that halts for all input is an algorithm, which consists of executable operations, and is both deterministic and finite A problem is decidable if and only if it has an algorithm A DFA/NFA/PDA always stops

  16. TM programming Some techniques in TM programming • States can be used as limited storage • The input/output tape can be split into multiple tracks that can be processed separately • A TM can contain another TM as a “subroutine” These ideas do not change the definition of TM, nor its capability, but simplify the description

  17. TM extensions The definition of TM can be further extended • with multiple tapes and heads that can be used independently • with a nondeterministic transition function that specifies multiple possible moves These extensions do not change the languages accepted by TM

  18. Restricted TM The following automata have the same capability as a TM: • A TM with a tape that is infinite in one direction but finite in the other direction • A multi-stackPDA • A counter machine with finite states and two or more counters, each can do ++, --, and =0? A 1-counter machine is equivalent to a DPDA

  19. Universal TM A Universal Turing Machine (UTM) is a TM that can simulate an arbitrary Turing Machine on arbitrary input The universal machine essentially achieves this by reading both the description of the machine to be simulated as well as the input, then simulating the former on the latter So a “program” can become the “data” of another program

  20. Use a TM to simulate a computer

  21. Simulating a program in a TM • Get the instruction from the memory • Interpret the instruction • Get the memory address of data • Execute the instruction, which may lead to changes in the content of the tapes • Update the instruction counter, and repeat the process

  22. Computer and TM • A TM can be simulated by a computer program • An instruction cycle in a computer can be simulated by a TM • A computer program can be simulated by a TM as a sequence of instruction cycles • A computer system can be simulated by a TM as a set of programs

  23. Church–Turing Thesis Every function which would naturally be regarded as computable is computable by a TM Many other computational models are TM equivalents, including Lambda calculus Computation can be implemented in unconventional ways

More Related