compsci: Simple illustration of halting problem (from SICP)

Tags: til compsci

The halting problem asks whether we can write a general function halts(fn) that returns whether or not a given function would ever halt.

If halts(fn) existed then the following would prove it can't work:

fun strange(fn) =
  halts(fn)
    ? spinForever()
    : "done"

Notice that strange(strange) is a contradiction!

Published on: 21 Apr 2025