r/computerscience • u/Am-Hooman • Jul 07 '26
Discussion There's a part in Turing's halting problem proof that I don't understand
So the proof to my understanding goes like this:
Imagine a machine A which takes in a machine B's code and that B's input as its own input and tells us if the problem halts exists
Place A into a greater machine C which takes the output of A and if A returns "halts" it goes into an infinite loop, and if it returns "does not halt" C halts.
Use C as an input to C and create a paradox.
The part I don't understand is how exactly the last step is a paradox. A, and therefore C don't just take in a machine as an input, but also that machines input, so you can't just put the machine C into itself without the context of what is being put into C.
Therefore C(C(B)) is not the same program as C(B), so why do they need to have the same result in order for it not to be a paradox?
Edit: i think i get it now, C modifies A not just in how it reacts to the output but it also modifies the input to be the same for both the program and the program's input
Thanks to u/OpiskionThemed, u/Aminumbra and u/stevemegson for explaining it
14
u/OpsikionThemed Jul 07 '26
You've slightly mixed up the definition of C. It also duplicates its input. C is defined as
C(x) = if A(X, X) == "halts" then loop() else halt()
Then C(C) depends on the behaviour of A(C, C), which in turn determines halting for C(C), and thence the contradiction.
1
u/Late-Leather6262 Jul 09 '26
Here's a better example: a program thats is just a while loop and will only stop if you press "C", because it's depend if you wanna press or no it's impossível to know if the program gonna halt.
-3
u/YanVe_ Jul 07 '26
Ah, the halting problem frustrated me so much in uni.
Never really understood why are people so obsessed with it, given that it is completely obvious that potentially infinite programs take potentially infinite time to halt, and that it has no real life practical application, because no real system will ever have infinite amount of memory.
-3
u/SRART25 Jul 07 '26
I take a more practical view of the issue. If program halts, it can't tell you it halted, therefore you don't know if it did or not. In this case, C is a stand in for you with the same issue.
-6
u/Dusty_Coder Jul 07 '26
In a finite state machine, the machine will eventually visit a state a second time, guaranteed, and then the machine is forever in a loop. A loop with a length of 1 is a "halt." All finite state machines loop.
The halting problem manifests because an infinite state machine can be constructed that never visits the same state twice. You may never know if it may eventually loop, or if its one of these infinite constructions, until it loops.
For all practical purposes, there is nothing profound about any of this outside of hardcore math circles, as in the computer science circles its always a finite state machine, and the entire practice is in the optimization of the number of states needed to be visited in order to arrive at a state that meets a problem-specific metric. Algorithms converge because they are designed to. There is no profoundness.