4.15 Exercise 4.15

Suppose we have a procedure halts which determines whether the one-argument procedure p terminates when given the input a. Suppose we then had the given example program:

(define (run-forever) (run-forever))
 
(define (try p)
  (if (halts? p p)
      (run-forever)
      'halted))

Now suppose we do as they suggest and evaluate (try try). This will either call run-forever if (halts? try try) returns true – that is, if (try try) does not run forever – or will halt if it does run forever. This is a contradiction, and guarantees that implementing halts? is impossible.