1 / 93

Turing Machines

Turing Machines. Motivation. Our main goal in this course is to analyze problems and categorize them according to their complexity . Motivation. We ask question such as “how much time it takes to compute something?”. Motivation.

salena
Télécharger la présentation

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. Turing Machines

  2. Motivation Our main goal in this course is to analyze problems and categorize them according to their complexity.

  3. Motivation We ask question such as “how much time it takes to compute something?”

  4. Motivation But in order to answer them we must first have a computational model to relate to.

  5. Introduction • Objectives: • To introduce the computational model called “Turing Machine”. • Overview: • DeterministicTuring machines • Multi-tape Turing machines • Non-deterministic Turing machines • The Church-Turing thesis • Complexity classes as bounds on resources required by TMs.

  6. Schematic of a Turing Machine Read/Write head There’s b here! moves: left/right a infinite tape

  7. SIP 128-129 Formal Definition of a TM A deterministic Turing Machine is a tuple consisting of several objects.

  8. Formal Definition of a TM 1. Q - a finite set of states.

  9. Formal Definition of a TM 2.  - the input alphabet, finite set not containing the blank symbol _. b a c d

  10. Formal Definition of a TM 3.  - the tape alphabet, where  and _. B _ A b a C c d

  11. Formal Definition of a TM 4. :QQ{L,R} - the transition function. q0 q0 a

  12. Formal Definition of a TM 5. q0 - the start state

  13. Formal Definition of a TM 6. qacceptQ - the accept state.

  14. Formal Definition of a TM 7. qrejectQ - the reject state. qrejectqaccept.

  15. Formal Definition of a TM Summary 1. Q - the set of states. 2.  - the input alphabet. 3.  - the tape alphabet 4. :QQ{L,R} - the transition function. 5. q0- the start state. 6. qacceptQ - the accept state. 7. qrejectQ - the reject state.

  16. ComputationsThe Start Configuration start state q0 head: on the leftmost square the input: starting from left

  17. ComputationsExample (q0,a)=(q0,b,R) q0 q0 b Note: the head cannot move to the left of this square!

  18. ComputationsAccepting Configuration If the computation ever enters the accept state, it halts. qaccept

  19. Note: the machine may loop and not reach any of these two! ComputationsRejecting Configuration If the computation ever enters the reject state, it also halts. qreject

  20. The Language a TM Accepts • A Turing Machine accepts its input, if it reaches an accepting configuration. • The set of inputs it accepts is called its language.

  21. the state the content of the tape the position of the head Configurations • How many distinct configurations may a Turing machine which uses N cells have?   ||N N |Q|

  22. Examples: Member of L: aaabbbccc Non-Member of L: aaabbcccc Building a TM for a Simple Language L = { anbncn | n0 }

  23. The Turing Machine 1. Q = {q0,q1,q2,q3,q4,qaccept,qreject} 2.  = {a,b,c} 3.  = {a,b,c,_,X,Y,Z} 4.  will be specified shortly. 5. q0 - the start state. 6. qacceptQ - the accept state. 7. qrejectQ - the reject state.

  24. aa, R bb, R YY, R ZZ, R q1 bY,R q2 aX,R q0 cZ,L XX, R q3 bb, L aa, LYY, L YY, R qac q4 ZZ, L __, R YY, R ZZ, R The Transitions Function aa, R bb, R YY, R ZZ, R q1 bY,R transitions not specified here yield qreject q2 aX,R q0 cZ,L XX, R __, R q3 bb, L aa, LYY, L YY, R qac q4 ZZ, L __, R YY, R ZZ, R

  25. aa, R YY, R Demonstration bb, R ZZ, R q1 q1 q1 bY,R aX,R q2 q2 q2 q0 q0 q0 q0 q0 cZ,L XX, R __, R q3 q3 q3 ZZ, L bb, L YY, L aa, L YY, R qac qac __, R q4 q4 q4 YY, R ZZ, R . . . X a Y b Z c _ _

  26. Equivalent Models • Deterministic Turing machines are extremely powerful. • We can simulate many other models by them and vice-versa with only a polynomial loss of efficiency. • Next we’ll see an example for such model.

  27. SIP 136-138 Multi-Tape Turing Machines The input is written on the first tape . . . . . . . . .

  28. Multi-Tape Turing Machines 1. Q - the set of states. 2.  - the input alphabet. 3.  - the tape alphabet 4. :QkQ({L,R})k- the transition function, where k (the number of tapes) is some constant. 5. q0- the start state. 6. qacceptQ - the accept state. 7. qrejectQ - the reject state.

  29. Robustness • Multi-tape machines are polynomially equivalent to single-tape machines. • We can state a much stronger claim concerning the robustness of the Turing machine model:

  30. The Church-Turing Thesis  Intuitive notion of algorithms Turing machine algorithms

  31. What’s Next? • We proceed with a less realistic computational model, • Which can be simulated by DTMs • However, with an exponential loss of efficiency.

  32. Non-deterministic Turing Machines 1. Q - the set of states. 2.  - the input alphabet. 3.  - the tape alphabet 4. :QP(Q{L,R}) - the transition function. 5. q0- the start state. 6. qacceptQ - the accept state. 7. qrejectQ - the reject state. power set P(A)={B | BA}

  33. . . . Computations deterministic computation non-deterministic computation tree accepts if some branch reaches an accepting configuration time Note: the size of the tree is exponential in its height

  34. Alternative Description A non-deterministic machine always guesses correctly the ultimate choice.

  35. Example • A non-deterministic TM which checks if two vertices are connected in a graph may simply guess a path between them. • Now it only needs to verify this is a valid path.

  36. SIP 138-140 Simulating a Non-deterministic machine by a Deterministic One • We’ll describe a deterministic 3-tapes Turing machine which simulates a given non-deterministic machine.

  37. Simulating a Non-deterministic machine by a Deterministic One . . . input tape . . . simulation tape . . . address tape

  38. Addresses 1 non-deterministic computation 1 2 3 111 1 1 2 1 1312 1 1 2 1 2 1 1 1 2

  39. Simulation • Write 111…1 on the address tape. • Copy the input to the simulation tape. • Simulate the NTM: use the choices dictated by the address tape (if valid). • If it accepted – accept. • Replace the address string with the lexicographically next string. If there is no such – reject. • Go to step 2.

  40. Complexity Classes • Now that we have a formal computational model • We may begin to categorize problems • According to the resources TMs which compute them require.

  41. Time Complexity Definition: Let t:nn be a function. TIME(t(n))={L | L is a language decidable by a O(t(n)) deterministic TM} NTIME(t(n))={L | L is a language decidable by a O(t(n)) non-deterministic TM}

  42. Example: { anbncn | n0 }  P Polynomial Time Definition:

  43. The Towers of Hanoi The Halting Problem Minimum Spanning Tree Which are in P and Which aren’t?   

  44. Non-Deterministic Polynomial Time Definition: Examples: • the TSP problem • the ILP problem

  45. Observation • Claim:PNP • Proof: A deterministic Turing machine is a special case of non-deterministic Turing machines. 

  46. Exponential Time Definition:

  47. Space Complexity Definition: Let f:nn be a function. SPACE(f(n))={L | L is a language decidable by an O(f(n)) space deterministic TM} NSPACE(f(n))={L | L is a language decidable by an O(f(n)) space non-deterministic TM}

  48. 3Tape Machines input work output . . . read-only Only the size of the work tape is counted for complexity purposes read/write . . . write-only . . .

  49. Logarithmic Space Definition:

  50. Example: { anbncn | n0 }  PSPACE Polynomial Space Definition:

More Related