Advertisement
timothy235

sicp-4-1-5-data-as-programs

Mar 13th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.66 KB | None | 0 0
  1. #lang racket
  2.  
  3. ;;;;;;;;;;
  4. ;; 4.15 ;;
  5. ;;;;;;;;;;
  6.  
  7. ;; Suppose we had such a program 'halts?', such that (halts? p a) always returns true
  8. ;; when p halts on a, or false if p does not halt on a.
  9.  
  10. ;; Consider:
  11.  
  12. ;; (define (try p)
  13.   ;; (if (halts? p p)
  14.     ;; (run-forever)
  15.     ;; 'halted))
  16.  
  17. ;; and
  18.  
  19. ;; (halts? try try)
  20.  
  21. ;; If (halts? try try) is true, then, by the definition of try, (try try) would run
  22. ;; forever, a contradiction.  And, if (halts? try try) is false, then (try try) would
  23. ;; return 'halted and thus halt, another contradiction.  Either way, we get a
  24. ;; contradiction, so the premise, that a function like halts? exists, is impossible.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement