I am studying the theory of computation. Here are some terminologies that I am confused about.
Are total recursive function and primitive recursive function equivalent? I think they are equal because their domains are both total and they always generate output.
Can anyone tell me if there is some difference?
There is another example of a non-primitive-recursive but total computable function that explains better what the restricted definition of primitive recursion entails.
Each primitive recursive function is defined by a particular finite set of recursion equations, in terms of a fixed set of basic functions. We can use this to define an effective scheme for indexing all the primitive recursive functions. Let $(f_e : e \in \mathbb{N})$ be an effective indexing of the unary primitive recursive functions, meaning that
Every unary primitive recursive function is of the form $f_{e_f}(n)$ for some fixed $e_f$.
There is a single algorithm to compute $f_e(n)$ given $e$ and $n$.
Let $g(e,n)$ be the function that computes $f_e(n)$. We call $g$ a universal binary function. It is universal in the sense that it encapsulates all unary primitive recursive functions.
The function $g(e,n) = f_e(n)$ is certainly a total computable function. But it is not primitive recursive:
Suppose that $g(e,n)$ is primitive recursive. Then the function $f(n) = g(n,n)+1$ is also primitive recursive, as you can verify. But this function $f(n)$ cannot be of the form $g(e,n)$ for any fixed $e$, because for every $e$ we have $f(e) = g(e,e) + 1 \not = g(e,e)$, by the definition of $f$. Thus $g$ is total computable but not primitive recursive.
This diagonalization proof can be used in any system that is closed under a few basic operations. The moral of this construction is a key fact in computability theory:
The point is that there is a fundamental incompatibility between the goal of making a system concrete enough that every function is total, and making a system strong enough that it includes universal functions for itself. Only one of these goals can be achieved at a time.
There is a universal binary partial function for the set of unary total computable functions. In fact there is a universal binary partial function for the set of unary partial computable functions, a larger class. This fact is essentially equivalent to the existence of a universal Turing machine.