evinda said:
We have that $k$ is an arbitrary natural number and $p(k)=(m,n)$. There are two possible cases:
- $A(m)$ terminates within $n$ steps. Then $g(k)=m$.
- $A(m)$ does not terminate within $n$ steps. Then $g(k)=x_0$.
These are the only possible cases and since $k \in \mathbb{N}$ is arbitrary, we deduce that the function $g$ is total. Is tis right?
Yes, either $A(m)$ terminates within $n$ steps or it does not. In both cases $g(k)$ is defined. Therefore, $g$ is total: it is defined for every $k$. But totality of $g$ is much weaker than what has to be shown. The problem asks to prove that $g$ is total
and recursive (computable). It is very easy to come up with a not necessarily computable function whose image is the domain of $f$ ($f$ is the original partial recursive function). For example, if $\text{dom}(f)$ is finite, say, $\{m_0,m_1,\dots,m_{p-1}\}$, then define $g(k)=m_r$ where $r$ is the remainder when $k$ is divided by $p$. That is, $g$ is a periodic function taking values $m_0,\dots,m_{p-1}$ repeatedly. In this case, $g$ is recursive. If, on the other hand, $\text{dom}(f)$ is infinite, then, since $\text{dom}(f)\subseteq\mathbb{N}$, there is a bijection $g$ from $\mathbb{N}$ to $\text{dom}(f)$. However, there is no guarantee that such $g$ is recursive.
It is important that "$A(m)$ terminates within $n$ steps" is a decidable statement. That is, there is a Turing machine $M$ (or a Java method, C function, etc.) that for given $m$ and $n$ will always terminate and return "yes" or "no" depending on whether this statement is true or false. Here $A$ is a fixed Turing machine (algorithm) that computes $f$, so it can be incorporated into $M$. The informal description of $M$ is simple: run $A$ on $m$ for $n$ steps; if it terminates, return "yes"; otherwise, return "no". The finite number $n$ of steps is crucial. Therefore, $g(k)$, which has to decide statements in the first sentence of this paragraph, is computable.
evinda said:
I was trying to understand this proposition. I was wondering, whether we could deduce if the function $g$ is total if the number of steps needed, $n$, wouldn't be known, i.e. if we had this function$\left\{\begin{matrix}
m, & A(m) \text{ terminates}\\
x_0 ,& \text{ otherwise}
\end{matrix}\right.$
But I think that we could since we check if the function is defined for all elements of the domain in order to check if it is total. We don't look at its image. Right?
Such function is total, but it is not a priori computable because there is no obvious algorithm for deciding whether $A(m)$ terminates.