Decidability & Computability


Shared context
Assume a total, correct procedure HALTS(f,x) reports whether f(x) terminates. Define FUNNY(f)=IF HALTS(f,f) THEN NOT(f(f)) ELSE TRUE. Show FUNNY terminates for every f.
Answer & solution
Answer: Under the hypothetical HALTS assumption, both selected branches terminate. (no official key was published)
Interpret f as a program that can be supplied its own description as input; for the NOT expression restrict attention to programs returning Boolean values when they halt. This restricted class already suffices for the impossibility proof.
HALTS(f,f) terminates by the assumed totality of the decision procedure. If it returns FALSE, FUNNY immediately returns TRUE without running the nonterminating f(f). If it returns TRUE, its correctness guarantees that f(f) terminates. Evaluating that result and applying Boolean NOT therefore also terminates.
Thus for every such input program f, FUNNY(f) terminates and returns a Boolean. This is a conclusion conditional on the assumed existence of HALTS, not an independently implementable algorithm. Short-circuit branch selection is essential: the unselected branch must not evaluate f(f).