What is the strongest weaker version of the halts() function? I was wondering about some questions related to the Halting problem. I might have not understood all the assumptions in it fully. Would you kindly help me, please?
I understand that the construction in the proof leads to a contradiction. My thoughts are:

If one runs these theoretical programs in the real world, I would expect that the output of halts(f()) will oscillate between true and false with a frequency dependent on the processing speed. This all happens because the execution of f() is made dependent on the output of halts(f()). Self-referenced.

Obviously there are programs which do not need to be run by a testing halts() function and they can be still decided if they halt or not. For example the following will obviously not halt and there are IDEs which already detect it:
while(true)
;

Based on the previous 2 thoughts, can we state that there can be such halts() program that tells us if a program halts or not and oscillates between the two values only if the input program code takes the output of a halts(f()) function as an input in the inside?


Such halts() is still useful. Even if it cannot tells us a certain answer for a constructed, self-referenced pathological case.
Basically I am trying to figure out what is the strongest weaker version of the halts() function. What can we expect from it?
The gist of the argument is that the assumption that a one can write a function halt(f) that always halts and always answers correctly if f halts leads to a contradiction (by way of self-reference, applying it to a variant of itself), thus such function can't be written.
Sure, you can write functions that answer &quot;Yes&quot;, &quot;No&quot;, or &quot;Don't know&quot; (or even never stop) always correctly. Say we consider C programs only, it is (more of less) easy to check they are just a main function that doesn't include any loops, and so answer &quot;Yes&quot; for them, and &quot;Don't know&quot; for anything else. You can certainly refine the above a lot, and each refinement can in itself be further refined (if a program could identify the cases where all have to answer &quot;Don't know&quot;, it'd know that for them the answer is &quot;No&quot; --just running the program would tell eventually if the answer is &quot;Yes&quot;). The point is there can't be a way to answer all cases correctly.