For (1)(a), a primitive recursive function is obtained by a finite construction from the zero function, successor function and projection functions, using function composition in recursion theory and primitive recursion. The recursion rule, with parameters , is
Here have already been constructed. All these functions are total on nonnegative integers: the initial functions are total, composition preserves totality, and ordinary mathematical induction proves totality of each recursion.
For (1)(b), use a shifted hyperoperation sequence, beginning with addition. Define
and, for each fixed , define
The first three members are therefore addition, multiplication and exponentiation:
The exponentiation convention includes , hence . The next member iterates exponentiation, with ; there is no need for an exceptional domain restriction at .
For (1)(c), is a primitive recursive function by its displayed recursion. If is a primitive recursive function, then
are primitive recursive functions, using constants, projection functions and function composition in recursion theory. Primitive recursion applied to gives . Mathematical induction on the fixed rank proves every member of the sequence is primitive recursive. This does not assert that the joint three-variable evaluator is a primitive recursive function.
For (2), as written, the answer is no: the empty set is semidecidable, whereas a total computable function from to always has a nonempty range. This is the only obstruction. To prove the stronger useful statement, suppose is a nonempty computably enumerable set and choose . Fix a Turing machine which halts exactly on the inputs in . Its bounded halting predicate
is primitive recursive: encode configurations arithmetically, iterate its total single-step operation times by primitive recursion, and check the halt state. A halted configuration is kept fixed. This is a bounded simulation, not unbounded waiting.
Fix a primitive recursive pairing function with primitive recursive inverse coordinate functions. For example, the Cantor pairing function has inverses obtained by bounded minimization. Define
The two coordinate functions, the bounded predicate, and the finite case distinction are primitive recursive functions, so is a primitive recursive function. Its values always lie in . Conversely, if , its computation halts within some finite , and . Thus
The range need not be a computable set; deciding whether a value occurs anywhere in this total enumeration is an unbounded search.
Represent a nonnegative integer by the Church numeral
A closed lambda term represents a partial computable function if, on inputs in its domain, reduces to the Church numeral of the value, and on other inputs it produces no Church numeral. We use untyped lambda calculus and normal-order beta reduction.
First every primitive recursive function has such a representation on all inputs. The zero function is represented by a constant , the projection functions by , and the successor function by
For function composition in recursion theory, substitute the represented inner functions into the represented outer function:
These constituent functions are total, so there is no undefined argument to be discarded.
For primitive recursion, use Church Booleans and Church pairs:
If represent the total functions defining a recursion, put
and
After iterations the Church pair contains the counter and the recursively computed value at , by mathematical induction. Thus this lambda definition of primitive recursion by pair iteration represents the recursion. A structural induction for primitive recursive functions now represents every primitive recursive function.
To pass to arbitrary partial computable functions, use the Kleene normal form theorem in the following form: for every , there are total primitive recursive functions such that
with undefined precisely when no such exists. The predicate checks codes of valid finite halting histories for the chosen program; extracts their common output. This expresses unbounded minimization of a total predicate, so no earlier undefined test can interfere with the search.
Let be the represented total functions. The Church numeral zero test and a fixed-point combinator are
Define the search lambda term
All displayed abbreviations expand to finite closed lambda terms; stands for the fixed finite tuple of input variables. Because , normal-order beta reduction tests . At the first successful test the Church Boolean selects , which reduces to the correct Church numeral. The unused recursive branch is discarded.
If no test succeeds, every finite search step returns to another head search, never exposing a numeral. The term has no head normal form and hence cannot be beta equivalent to a Church numeral. This last point is why the output operation occurs inside the successful branch: simply applying a possibly argument-discarding outer function to a divergent search would not justify undefinedness. Therefore every computable function is representable, including partial computable functions with their correct undefined inputs:
Use untyped lambda calculus and normal-order beta reduction. Write for the Church numeral of . We will construct a closed term such that
when is defined, and with no head normal form otherwise. The latter condition implies that the result is not in beta equivalence with any Church numeral, so both definedness and the output are represented.
First represent all total primitive recursive functions. The zero function is , the successor function is
and the th projection function is . Function composition in recursion theory is represented by . This composition claim is used here for total functions, whose inner terms all reduce to numerals.
For primitive recursion use Church pairs and iteration. Put
Suppose represent the total constituents of and . Define
After iterations the pair reduces to , by mathematical induction on . Its second projection is the required result. This lambda definition of primitive recursion by pair iteration and structural induction on the primitive recursive construction give terms for all primitive recursive functions.
For an arbitrary partial computable function use the Kleene normal form theorem with its program index fixed. There are total primitive recursive functions and such that is zero exactly when codes a valid halting computation history on , and extracts that history's output. Checking finite coded configurations and each transition is primitive recursive. Determinism ensures that every accepted history on an input has the same output. Hence
If the input computation never halts, no history is accepted. Let be the total numeral-representing terms already obtained. The Church numeral zero test is , returning exactly on zero. A Church Boolean applied to two arguments selects the appropriate branch without evaluating the other.
Take the fixed-point combinator . For the input tuple define
Expanding the displayed abbreviations gives a genuine finite combinator. At a numeral code , the total predicate computation terminates. If it returns a positive numeral, the false Church Boolean selects the next search code. If it returns zero, the true Church Boolean selects , which reduces to the output numeral. If the least accepted code is , a finite sequence of these tests reaches it and then produces .
If there is no accepted code, every test is false and head reduction moves through codes forever. At no finite point can a head variable or an outer numeral abstraction be produced: the applied search term must first unfold the fixed point and evaluate the next total test, and the decoder branch is always discarded. Thus it has no head normal form. The standard head-normalization property, or the Church-Rosser theorem together with normalization of normal-order reduction, rules out beta equivalence to a numeral. In particular, we have avoided a lazy-composition pitfall: an outer function that discards an argument need not force a divergent inner computation. The decoder is reached only after the guarded search succeeds. This proves lambda representation of partial computable functions:
The machine characterization is computation by a Turing machine: the machine halts with exactly on inputs in the domain of a partial function and does not halt elsewhere. The syntactic characterization is the least class containing the initial functions of recursion theory and closed under composition of partial functions, primitive recursion and unbounded minimization. Such functions are the partial recursive functions, equivalently the partial computable functions.
For clarity, composition here is strict: is defined only when every inner value is defined and is defined on the resulting tuple. Likewise primitive recursion requires all preceding recursive values. The partial minimization is defined when such a exists and all earlier values are defined and nonzero; an undefined earlier value blocks the search.
A lambda-definable partial function is represented by a closed untyped lambda calculus term satisfying
On an input outside its domain there must be no Church numeral beta-equivalent to the result. A stronger representation can be arranged: undefined inputs have no head normal form.
Here are the components for proving that every partial recursive function is lambda-definable. Zero and projections are immediate; lambda definition of the successor function uses . Church Booleans encode a conditional by , with and . Put
Iteration takes to for , proving that encodes the predecessor function and that correctly tests zero.
Use a fixed-point combinator and the strict sequencing operation
For any numeral , reduces to . If the first argument has no head normal form, neither does the whole expression. Thus composition is implemented by nesting on every inner result before applying the outer representing term. This guard is important: an unguarded projection could discard an undefined inner computation.
For lambda definition of primitive recursion, with already represented by , take
The tuple notation abbreviates successive abstractions and applications. On numeral inputs, induction on proves the required recursion equations, including strict propagation of undefined preceding values. The beta reduction follows the selected conditional branch only.
For lambda definition of unbounded minimization, use
This searches in increasing order. An undefined value blocks the zero test; an infinite sequence of nonzero values continues forever; the first zero returns its numeral. Under normal-order beta reduction, both failure cases have no head normal form. Structural induction on partial-recursive declarations now supplies the stronger representation claimed above.
Conversely, beta reduction is an effective operation on finitely encoded lambda terms. Enumerate all finite reduction sequences from , stopping when a result is a Church numeral in beta-normal form. If , the Church-Rosser theorem gives a reduction to that numeral. It also makes the output unique. The enumeration therefore computes exactly the represented partial function; by the equivalence of the first two characterizations it is partial recursive. Hence
Let be the successor function. Define by primitive recursion
Induction gives . Then define
by composition. Initial functions, composition, and primitive recursion produce primitive recursive functions, so and are partial recursive functions and are visibly defined for every . Both functions are total.
Fix a register machine with inputs. By the permitted result, its complete configuration after steps,
is a recursive function of the inputs and time. The predicate saying that this configuration is halted is therefore recursive. Its halting time is the partial recursive function
where unbounded minimization is undefined when no halting time exists. Extracting the output register from a configuration is recursive, so
is partial recursive. Hence every partial computable function is partial recursive.
The structural induction principle says that a property holds for every primitive recursive function if it holds for every initial function of recursion theory and is preserved by function composition in recursion theory and primitive recursion. This is justified because primitive recursive functions are, by definition, the smallest class closed under those constructors; equivalently, every such function has a finite construction tree, and ordinary induction on its height proves .
Take to mean that is total. The zero, successor, and projection functions are total. A composition of total functions is total. Finally, suppose and are total and is defined from them by primitive recursion. For fixed , induction on proves that exists: the value at zero is , and from the existing value at , totality of gives the value at . Therefore every primitive recursive function is total.
Using the zero test from part (i), define by primitive recursion
Since and , the values alternate:
Thus is the required parity function and, like , is primitive recursive without minimization.
A partial recursive function is obtained from the three kinds of initial function of recursion theory—
the zero function, successor function, and projection function—by finitely many applications of function composition in recursion theory, primitive recursion, and unbounded minimization. Explicitly, primitive recursion has the form
while minimization takes the least for which and is undefined if no such is found.
For the function in part (i), define
The initial value and the identically zero recursion step are primitive recursive, so this is a primitive-recursive definition of the required zero test. It uses no minimization.
A valid finite construction expression from the initial functions of recursion theory by function composition in recursion theory and primitive recursion. Its extension is a primitive recursive function. The construction grammar supplies both a decidable syntax and a total computable interpreter, but no uniformly primitive recursive interpreter for all valid codes.