(a). FUNNY(f) takes as input a function $f$. Now we have a function HALTS which tells us whether $f$ halts or not. i.e., if HALTS returns TRUE $f$ halts and if HALTS returns FALSE $f$ won't halt.
So, in FUNNY, we can call HALT(f) and if the return value is
- TRUE, then we call function $f$ and return its negated value.
- FALSE, then we just return TRUE
Since, HALT function exist and is guaranteed to return for any input function and since we are calling $f$ only when it is known to terminate, FUNNY(f) will terminate for any input function $f.$
(b). We can use FUNNY(f) to determine is a function $f$ does not terminate (non-halting problem) which is a known undecidable (not even semi-decidable) problem.