I am studying algorithms and I came across this exercise:
'Prove that there is no program/algorithm that determines if a program P uses an uninitialized variable on a given input x.'
Here is the proof I came up with:
Let's assume that there is an algorithm Det to determine if a program P uses an uninitialized variable on a given input x.
Let the program be
P(x) if Det(P,x) is true do nothing else variable i print i
Here we see a contradiction. If Det(P,x) is false then we have used an uninitialized variable. We have not used uninitialized variable elsewhere so whenever it returns true, its wrong.
I am not sure if I am thinking in the right way.