1 / 20

Limits of Algorithmic Computation

CS 3240 – Chapter 12. Limits of Algorithmic Computation. The Librarian Paradox The Mysteries of Self-Reference I.

janna-ryan
Download Presentation

Limits of Algorithmic Computation

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. CS 3240 – Chapter 12 Limits of Algorithmic Computation

  2. The Librarian ParadoxThe Mysteries of Self-Reference I An unfortunate library intern is given the task of creating a list of all books in the library that do not mention themselves. She toils all summer. In the end, she has a list. This she triumphantly adds to the reference section as “Non Self-Mentioning Books.” She is just about to head back to campus, when the head librarian asks, “Shouldn’t that book itself be added to the list?” But when the intern adds it to the list, the book is no longer non-self-mentioning. And yet, if it’s not added, it should be added.” CS 3240 - Chapter 12

  3. InterludeThe Mysteries of Self-Reference II • The Halting Dog Problem • see online document CS 3240 - Chapter 12

  4. The Halting Problem • Question: Is there a Universal TM (H) that takes another TM (M) as input, along with an input string (w), and decides whether or not M halts on w? • In other words, is there such an algorithm? • This would be very useful • Could detect infinite loops in bad code! • Could save us from wasting precious time CS 3240 - Chapter 12

  5. The Halting ProblemRedux • The halting algorithm, H, is depicted below: CS 3240 - Chapter 12

  6. The Halting ProblemDefining related procedures • Now define the TM, N(M) = H(M,M) The machine N CS 3240 - Chapter 12

  7. Forcing a TM to Loop CS 3240 - Chapter 12

  8. The Halting ProblemDefining related procedures • Now define the machine D(M) which calls N(M) and: • loops forever if Mdoes halt on M • returns No if M does not halt on M The Machine D CS 3240 - Chapter 12

  9. Question • What is the result of D(D)? CS 3240 - Chapter 12

  10. Contradiction! • If D halts on D, then it loops forever (doesn’t halt) • If D does not halt on D, it halts on D with the result “N” • Both cases are self-contradictory • Therefore, there is no such TM/procedure H • The Halting Problem is undecidable CS 3240 - Chapter 12

  11. A Pseudocode Version • Suppose h(M,w) is computable • the algorithm h tells whether M halts on w • Construct the function g(M,w):if h(M,w) loop forever else return false • Now compute g(g,g): • if g halts on g, then it doesn’t • if g doesn’t halt on g, then it does (returning false) CS 3240 - Chapter 12

  12. The Halting Problem is UndecidableThe Language Perspective If the halting problem were decidable, we could build the machine above. (H is the halting algorithm) For any recursively enumerable language, L, we feed its recognizing machine, M, and any string, w, to H. If M will halt on w, we return its answer. Otherwise we return No. This constitutes a procedure that decides any r.e. language (the “membership problem”). This implies that all r.e. languages are actually recursive. Contradiction! So H can’t exist. CS 3240 - Chapter 12

  13. Reducing One Problem to AnotherA Handy Technique for Showing Undecidability • Problem A is reducible to problem B if B’s decidability implies A’s decidability • in other words, we can use B to solve A • A ⪯ B if S(B) ➱S(A) (B solvable implies A solvable) • We did this earlier: • we just reduced the Membership Problem to the Halting Problem (by “solving”M with H) • S(H) ➱S(M) • Equivalent to ¬S(M) ➱¬S(H) (contrapositive) CS 3240 - Chapter 12

  14. The Blank-Tape Halting Problem • We will reduce H to B • “If B is solvable so is H” • We do so by using B to “solve” H • The construction of H from B in 2 steps: • Let Mw start with a blank tape and write w on it, then run M on w • Mw halts on a blank tape iff M halts on w • Construct H by taking (M,w) as input, building Mwand then feeding Mw to B (see next slide…) CS 3240 - Chapter 12

  15. S(B) implies S(H) CS 3240 - Chapter 12

  16. Process for Reducing A to B • Decide which unsolvable problem (A) to reduce • usually the Halting or Membership problems • key idea: arrange for M to accept w iff B succeeds • Modify M to interface with B • call the new machine Mw • you often run M on w inside Mw • Feed Mw and any other input (w) to B • show that the output of Mw solves A CS 3240 - Chapter 12

  17. Exercise 12.1-3 • Let R be the problem of deciding whether a TM, M, ever writes a given character, c, say, when applied to any string w. • We can reduce the Halting problem to R. • Modify M to always write a # whenever it halts. Call this machine Mw. Hence M halts iff Mw writes a #. • Now compute (M,w)->(Mw,#)->R • See next slide. CS 3240 - Chapter 12

  18. S(R) implies S(H) CS 3240 - Chapter 12

  19. The State Entry Problem • Does a given TM, M, ever enter a given state, q? • We can reduce the Halting Problem, H, to this problem (call it E) • Given M and w, build Mw to always halt in q’: • just draw an arrow for every letter from each halting state to a new state, q’ • arrange for w to be the input for Mw now feed Mw,q’ to E CS 3240 - Chapter 12

  20. S(E) implies S(H) CS 3240 - Chapter 12

More Related