turing machines computability
play

Turing Machines & Computability Lecture 19 1 Course - PowerPoint PPT Presentation

Turing Machines & Computability Lecture 19 1 Course Trajectory Seen lots of algorithms, what can be done. But what cannot be done? Need a more precise definition of what a computer / computation is CS 374 2 Most General Computer? Not


  1. Turing Machines & Computability Lecture 19 1

  2. Course Trajectory Seen lots of algorithms, what can be done. But what cannot be done? Need a more precise definition of what a computer / computation is CS 374 2

  3. Most General Computer? Not all functions are computable, but which are? Is there a most general model of computer, such that any “physically realizable” model of computation is subsumed by it? Herbrand CS 374 Gödel Church Turing General Recursive Functions Lambda Calculus Turing Machine All these models turned out to be equivalent! 3

  4. Our Model So Far Not been very precise about our computational model so far Assumed that any integer and any array index fits into a “word”, and we can carry out arithmetic operations and 
 load/store operations with them But that requires our CPU to be infinitely large! Does the model get too powerful? We do want to allow access to arbitrarily large amounts of CS 374 memory (input maybe arbitrarily large), but without using arbitrarily long addresses… 4

  5. Solution CS 374 Sequential access 5

  6. Turing Machine move the head 
 left or right 
 by one cell sequentially accessed read write infinite memory finite memory (state) next- action look-up table CS 374

  7. Turing Machine input blanks a b c d e f g _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ next action: e.g., 
 q start δ ( q , a ) = ( q ʹ , b , R ) change state to q ʹ , 
 next- action write b in the cell look-up table scanned by head, 
 move head Right CS 374 Initial configuration

  8. Example Input alphabet : Σ = {0,1} Tape alphabet : Γ = {0,1,0 ʹ , 1 ʹ , _} What does this TM do? 0 / 0, R 1 / 1, R _ / 0, L 0 / 0 ʹ , R 0 / 0, L q 3 1 / 1 ʹ , R 1 / 1, L 0 ʹ / 0, R q 2 q 1 0 / 0, R _ / _, L 1 ʹ / 1, R 1 / 1, R CS 374 q 4 _ / 1, L

  9. Example 0 0 1 _ _ _ _ _ _ _ _ q 1 Input alphabet : Σ = {0,1} 0 ʹ 0 1 _ _ _ _ _ _ _ _ 0 ʹ 0 ʹ 1 Tape alphabet : Γ = {0,1,0 ʹ , 1 ʹ , _} _ _ _ _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, L Crashes! Head moves out of the tape.

  11. Example Input alphabet : Σ = {0,1} Tape alphabet : Γ = {0,1,0 ʹ , 1 ʹ , _} 0 ʹʹ , 1 ʹʹ ,_} Maps w to ww R 0 / 0, R 0 / 0, R 1 / 1, R 1 / 1, R _ / 0, L 0 / 0 ʹ , R 0 / 0, L q 3 q 5 1 / 1 ʹ , R 1 / 1, L 0 ʹʹ / 0, R _ / 0, R 0 ʹ / 0, R q 2 q start q 1 q halt 0 / 0, R 0 / 0, R _ / _, L 0 / 0 ʹʹ , R 1 ʹ / 1, R 1 ʹʹ / 1, R 1 / 1, R 1 / 1, R 1 / 1 ʹʹ , R CS 374 _ / 1, R q 4 q 6 _ / 1, L

  12. TM for Decision Problems M = ( Q, Σ , Γ , B, δ , q start, , q accept , q reject ) : A TM could write its output on the tape and Q is a finite set of states enter q halt Σ is a finite input alphabet But for decision Γ is a finite tape alphabet. ( Σ ⊆ Γ ) problems (when the output is required to be B ∈ Γ – Σ is the blank symbol a bit, yes/no), for convenience, we use δ : Q × Γ → Q × Γ × { L, R } two halt states , 
 q accept and q reject q start ∈ Q is the initial state CS 374 q accept , q reject ∈ Q accept/reject states 12

  13. TM for Decision Problems M = ( Q, Σ , Γ , B, δ , q start, , q accept , q reject ) : No transition out of q accept and q reject Q is a finite set of states δ : Q \ { q accept , q reject } × Γ 
 Σ is a finite input alphabet → Q × Γ × { L, R } Γ is a finite tape alphabet. ( Σ ⊆ Γ ) Convention: for ( q , a ) ∈ Q \ { q accept , q reject } × Γ , if B ∈ Γ – Σ is the blank symbol δ ( q , a ) is not specified, δ : Q × Γ → Q × Γ × { L, R } then define δ ( q , a ) to be ( q reject , B , R ) q start ∈ Q is the initial state CS 374 q accept , q reject ∈ Q accept/reject states 13

  14. 
 
 
 ID: Instantaneous Description Contains all necessary information to capture the 
 “current configuration of the computation” state, tape-contents & head-location Easy-to-read notation: xqy 
 x ∈ Γ * : tape contents left of the head 
 q ∈ Q : state 
 y ∈ Γ * : tape contents at & right of the head 
 CS 374 (till last non-blank) Initial ID: q start ⟨ input ⟩ 14

  15. Relations ⇒ & ⇒* on IDs ID 1 ⇒ ID 2 iff ID 1 evolves into ID 2 in one step. e.g., if δ ( q, a i ) = ( q ʹ ,b, L ) , then 
 a 1 a 2 … a i -1 q a i a i +1 … a n ⇒ a 1 a 2 … a i -2 q ʹ a i -1 b a i +1 … a n current ID next ID ⇒ * i s the reflexive & transitive closure of ⇒ CS 374 Thus, ID 1 ⇒ * ID 2 iff M , when run from ID 1 , reaches ID 2 after some finite number (0 or more) of moves 15

  16. 
 Definition of Acceptance M accepts w iff q start w ⇒ * α 1 q accept α 2 
 for some α 1 , α 2 ∈ Γ * Note that M is allowed to accept w without scanning all of w L ( M ) = { w | M accepts w } M does not accept w if starting from the ID q start w : 1. M halts in q reject , or 
 2. M crashes (head moves off the tape), or 
 CS 374 3. M never stops 16

  17. Deciding/Recognizing a Language L ( M ) = { w | M accepts w } is called the language recognized by M M decides L ( M ) if on input w ∉ L , M halts in q reject If a TM decides the language it recognizes, 
 then, on every input, it halts in q accept or q reject Easy to change “crashes” to rejects But turns out the we can’t avoid infinite CS 374 executions! (can’t tell if it is going to be infinite) 17

  18. Deciding/Recognizing a Language L ( M ) = { w | M accepts w } is called the language recognized by M M decides L ( M ) if on input w ∉ L , M halts in q reject Fundamental questions of computability: Recursively 
 Which languages are recognizable? Enumerable 
 Language Which languages are decidable? Recursive 
 CS 374 Language 18

  19. Deciding/Recognizing a Language ̅ are both recursively enumerable, Claim : If L and L then they are both decidable too ̅ = L ( M 2 ). Say L = L ( M 1 ) and L Can define a TM M which “simulates” M 1 and M 2 
 in parallel on the same input. 
 On any input, one of the simulated machines will eventually accept (and halt). 
 M accepts or rejects accordingly. CS 374 How? M has only one tape… 19

  20. What a TM can do A TM can do everything that can be done in a standard programming language 
 (and vice versa) Coming up: 
 A few programming tools for TMs and 
 some equivalent models which are easier to program in CS 374 20

  21. 
 Example TM to accept palindromes in {0,1}* Idea: Read first symbol into finite memory. 
 Then move the tape head to the first symbol from right, and compare with symbol in memory. If mismatch, reject. 
 Else, return to the next symbol from left, read it into memory and compare with next symbol from right, etc. How does the TM know which symbol is the “next”? 
 Can’t use finite memory to keep track of how many CS 374 positions already processed. 
 Need to use the tape itself. 21

  22. Example TM to accept palindromes in {0,1}* 0 / 0, R 1 / 1, R _ / _, R _ / _, L 0 / _, L 0 / 0, L 0 / _, R 1 / 1, L _ / _, R _ / _, R q accept q start 0 / 0, R 1 / 1, R _ / _, R 1 / _, R 1 / _, L _ / _, L CS 374 Fact: If TM not allowed to write on the tape, 
 then can recognize only regular languages 22

  23. Avoiding Crashing Given M (that may crash), an “equivalent” M ʹ 
 which goes to q reject instead of crashing Idea: Rewrite input w to be $ w , place the head on the first symbol of w and run M . If head ever scans $ , move to q reject (and move the head right) 0/0,R 0/0,L 1/1.L _/_,L R p 0 , $ / 0 $/$,R q 0 p start p 2 1/0,R 0/1,R CS 374 1/$,R L , _ p 1 / _ 1/1,R 23

  24. Shifting by k Positions Can do “shift-by-1” k times. But k scans of tape. To shift by k positions to the right in a single scan: Remember last k symbols. Overwrite current cell with symbol from k cells behind _/$,R p ʹʹ 0 1/$,R 0/0,L _/0,R _/0,R 1/1.L 0/$,R 1/0,R 0/$,R p 0 p 00 p 01 _/0,R p ʹ 0 _ / $/$,R 0 1/0,R , R 0/0,R 0/0,R 1/1,R p start _/1,R 0/1,R _/1,R 1/1,R 1 / $ p ʹ 1 p 10 , p 1 p 11 R R 1/$,R 0/1,R CS 374 _/1,R , 1 / _ 1/$,R p ʹʹ 1 _/$,R 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend