1 / 13

David Evans http://www.cs.virginia.edu/evans

Class 26: Halting Problem.

sandra_john
Download Presentation

David Evans http://www.cs.virginia.edu/evans

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. Class 26: Halting Problem It is plain at any rate that the real mathematics (apart from the elements) has no direct utility in war. No one has yet found any war-like purpose to be served by the theory of numbers or relativity or quantum mechanics, and it seems very unlikely that anybody will do so for many years. G. H. Hardy (Turing’s advisor), Mathemetician’s Apology, 1940 By 1943, Turing had used number theory to break the Nazi Enigma code. David Evans http://www.cs.virginia.edu/evans CS200: Computer Science University of Virginia Computer Science

  2. Are there any undecidable problems? The Proof-Finding Problem: • Input: an axiomatic system, a statement S • Output: If S is true, output a valid proof. If S is not true, output false. CS 200 Spring 2004

  3. Undecidable Problems • We can prove a problem is undecidable by showing it is at least as hard as the proof-finding problem • Here’s a famous one: Halting Problem Input: a procedure P (described by a Scheme program) and its input I Output: true if executing P on I halts (finishes execution), false otherwise. CS 200 Spring 2004

  4. Alan Turing (1912-1954) • Published On Computable Numbers … (1936) • Introduced the Halting Problem • Formal model of computation (now known as “Turing Machine”) • Codebreaker at Bletchley Park • Broke Enigma Cipher • Perhaps more important than Lorenz • After the war: convicted of homosexuality (then a crime in Britain), committed suicide eating cyanide apple CS 200 Spring 2004

  5. Halting Problem Define a procedure halts? that takes a procedure and an input evaluates to #t if the procedure would terminate on that input, and to #f if would not terminate. (define (halts? procedure input) … ) CS 200 Spring 2004

  6. Examples > (halts? ‘(lambda (x) (+ x x)) 3) #t > (halts? ‘(lambda (x) (define (f x) (f x)) (f x)) 27) #f CS 200 Spring 2004

  7. Halting Examples > (halts? `(lambda (x) (define (fact n) (if (= n 1) 1 (* n (fact (- n 1))))) (fact x)) 7) #t > (halts? `(lambda (x) (define (fact n) (if (= n 1) 1 (* n (fact (- n 1))))) (fact x)) 0) #f CS 200 Spring 2004

  8. Can we define halts?? • We could try for a really long time, get something to work for simple examples, but could we solve the problem – make it work for all possible inputs? • Could we compute find-proof if we had halts? CS 200 Spring 2004

  9. I cheated a little here – we only know we can’t do this for “true”. find-proof (define (find-proof S axioms rules) ;; If S is provable, evaluates to a proof of S. ;; Otherwise, evaluates to #f. (if (halts? find-proof-exhaustive S axioms rules)) (find-proof-exhaustive S axioms rules) #f)) Where (find-proof-exhaustive S axioms rules) is a procedure that tries all possible proofs starting from the axioms that evaluates to a proof if it finds one, and keeps working if it doesn’t. CS 200 Spring 2004

  10. Another Informal Proof (define (contradict-halts x) (if (halts? contradict-halts null) (loop-forever) #t)) If contradict-halts halts, the if test is true and it evaluates to (loop-forever) - it doesn’t halt! If contradict-halts doesn’t halt, the if test if false, and it evaluates to #t. It halts! CS 200 Spring 2004

  11. This should remind you of… Russell’s Paradox • S: set of all sets that are not members of themselves • Is S a member of itself? • If S is an element of S, then S is a member of itself and should not be in S. • If S is not an element of S, then S is not a member of itself, and should be in S. CS 200 Spring 2004

  12. Undecidable Problems • If solving a problem P would allow us to solve the halting problem, then P is undecidable – there is no solution to P, since we have proved there is no solution to the halting problem! • There are lots of practical problems like this. Example: why virus detectors will never really work! CS 200 Spring 2004

  13. Charge • PS6 due Monday • Friday: • Finite state machines with infinite tape CS 200 Spring 2004

More Related