r/computerscience • • Dec 31 '25

Halting problem (Can a program contain itself?)

Please correct me if I'm wrong here. The usual proof is about a program passing its own source code to the machine and then changing the result to be wrong... But what if the running program and the source code it passes are not the same program?

If a running program reads its source code from an external file after it already started running, how do you know that its the same exact code as what is already running? It could be a different program.

If the source code of the program contained a copy of its own source code, it wouldn't actually be the same source code as the original program unless infinitely recursive and therefore impossible.

Basically my thinking is that the whole thing requires a program to contain itself which is impossible.

Does this break the proof?

1 Upvotes

47 comments sorted by

View all comments

Show parent comment

1

u/dcpugalaxy Jan 01 '26

You might draw a Turing Machine that operates on the alphabet {0,1} as a bunch of nodes on a piece of paper linked by arrows pointing from one node to another, which are labelled.

That Turing Machine can be encoded as a sequence of zeroes and ones. Then that sequence of zeroes and ones can be made the initial tape for that TM.