Why are computable functions finite

computabilitycomputer sciencelogic

The definition of a computable function (according to Wikipedia) states "… a function is computable if its value can be obtained by an effective procedure. … A procedure is formally called effective for a class of problems when it consists of a finite number of instructions."

Why is the restriction "finite number of instructions" necessary? Aren't the essential requirements computable in finite time and correct results? I can come up with programs that are infinitely long but terminate in finite time for any input, e.g., the function on the positive integers

// return 1 if x is odd, otherwise 0
if (x==1) {  return 1 }
else if (x==2) {  return 0 }
else if (x==3) {  return 1 }
...

Although this code is infinitely long that poses no problem as it can be generated on the fly until termination. One argument against this example could be that it has an equivalent finite counterpart.

However, given an infinite list of finite sized computer programs I can also define a function on the positive integers $i\in\mathbb{N}$ that returns the output of the $i$-th computer program for input $i$. Again, this algorithm terminates in finite time. Why is this function not considered computable.

(I'm interested in this questions in the context of Gödel's first incompleteness theorem, which also requires that the formal system is effectively axiomatized.)

Best Answer

If your infinite list of instructions can be generated by a finite program, then whatever those instructions do can also be done by a finite program, so your function is still computable. It's only non-computable if it has no finite algorithmic description.

If we allowed infinitely long programs, then every function on $\Bbb N$ would be obviously computable (by an infinite sequence of cases, as in your "odd numbers" example), so "computable" wouldn't mean anything.

Related Question