To be able to determine properly if a function is non-computable, we need to reduce it to what we already know to be non-computable: our favourite function, halt().
Let us look at the following example:
def is_bigger_than_five(f, v)
"""
Return True iff f(v) returns an int that is bigger than 5
"""
#code here
return True
At simple sight, we can tell that, if f(v) does not stop, then the function should return False. To be sure, we need to reduce it to halt in the following way:
def halt(f, i)
def is_life(g, v)
"""
Return True iff f(v) returns "life"
"""
#code here
return True
def f_prime(x)
"""
Ignore the argument x, call f with the fixed argument i (the one passed into halt)
"""
f(i)
return "life"
return is_life(f_prime, v)
From the following, we can conclude:
- If f(i) halts, then is_life(f_prime, v) is True
- If f(i) does not halt, then is_life(f_prime, v) is False
Therefore, is_life() is not computable!