Cite

This course has no released version yet: the text at this address may change. Cite a released version when one exists.

/courses/models-of-computation/mu-recursion
@misc{models-of-computation-mu-recursion,
  title = {{Minimization and partial recursive functions}},
  howpublished = {Lesson 8 of \emph{Models of computation}, Computability Theory course notes},
  url = {/courses/models-of-computation/mu-recursion},
  note = {Unreleased working version}
}

To cite a single statement, use the # link that appears next to its heading.

Lesson 8 of 13

Minimization and partial recursive functions

The minimization operator, the partial recursive functions, recursive functions and predicates, and the statement of Kleene's normal form theorem.

35 min5 questions
Before this lesson:The Ackermann function
Models of computation · lesson 8 of 13
  1. Algorithms and partial functions
  2. Turing machines
  3. Programming Turing machines
  4. Register machines
  5. Primitive recursive functions
  6. Coding finite sequences
  7. The Ackermann function
  8. Minimization and partial recursive functions
  9. LOOP and WHILE programs
  10. The λ-calculus
  11. Computing with λ-terms
  12. Equivalence of the models
  13. The Church–Turing thesis

Primitive recursion corresponds to for loops: the number of iterations is fixed before the loop starts. The Ackermann function shows that this is not enough to obtain all total computable functions. What is missing is the while loop, or equivalently the unbounded search: try y=0,1,2,…y = 0, 1, 2, \dots until some condition holds. Adding this operation leads to the class of partial recursive functions, introduced by Kleene in 1936.

8.1 The minimization operator

Definition 8.1.#

Let g:Nk+1⇀Ng : \nat^{k+1} \rightharpoonup \nat be a partial function. The partial function f:Nk⇀Nf : \nat^k \rightharpoonup \nat obtained from gg by minimization, written

f(x⃗)≃μy [g(x⃗,y)=0],f(\vec x) \simeq \mu y\, [g(\vec x, y) = 0],

is defined as follows: f(x⃗) ⁣ ⁣↓=yf(\vec x)\converge = y if and only if

  • g(x⃗,y) ⁣ ⁣↓=0g(\vec x, y)\converge = 0, and
  • for every z<yz < y, g(x⃗,z) ⁣ ⁣↓g(\vec x, z)\converge and g(x⃗,z)≠0g(\vec x, z) \neq 0.

If there is no such yy, then f(x⃗) ⁣ ⁣↑f(\vec x)\diverge.

The definition describes exactly the result of the following procedure: compute g(x⃗,0)g(\vec x, 0), then g(x⃗,1)g(\vec x, 1), and so on, and return the first yy for which the value is 00. The procedure fails to return in two different ways: either all values are defined and non-zero, or some computation g(x⃗,z)g(\vec x, z) does not terminate before a zero has been found.

For a predicate P⊆Nk+1P \subseteq \nat^{k+1} we write μy P(x⃗,y)\mu y\, P(\vec x, y) for μy [sg‾(χP(x⃗,y))=0]\mu y\, [\overline{\mathrm{sg}}(\chi_P(\vec x, y)) = 0], the least yy such that P(x⃗,y)P(\vec x, y).

8.2 Partial recursive functions

The schemes of composition and primitive recursion extend to partial functions, with the convention that an expression is undefined as soon as one of its subexpressions is:

  • composition: f(x⃗)≃h(g1(x⃗),…,gm(x⃗))f(\vec x) \simeq h(g_1(\vec x), \dots, g_m(\vec x));
  • primitive recursion: f(x⃗,0)≃g(x⃗)f(\vec x, 0) \simeq g(\vec x) and f(x⃗,y+1)≃h(x⃗,y,f(x⃗,y))f(\vec x, y + 1) \simeq h(\vec x, y, f(\vec x, y)). In particular, if f(x⃗,y) ⁣ ⁣↑f(\vec x, y)\diverge then f(x⃗,y′) ⁣ ⁣↑f(\vec x, y')\diverge for all y′≥yy' \geq y.
Definition 8.2.#

The class of partial recursive functions is the smallest class of partial functions Nk⇀N\nat^k \rightharpoonup \nat (k≥1k \geq 1) containing the basic functions ZZ, SS, pikp^k_i, and closed under composition, primitive recursion and minimization. A partial recursive function which is total is called a (total) recursive function. A predicate is recursive if its characteristic function is recursive.

The terminology varies: partial recursive is also called partial computable, and recursive is also called computable, the modern usage preferred in the following courses. In Kleene’s original work, the total functions obtained from Herbrand–Gödel systems of equations were called general recursive; Kleene proved that they are exactly the total partial recursive functions.

Proposition 8.3.#

Every partial recursive function is computable: there is an algorithm which, on input x⃗\vec x, terminates with output f(x⃗)f(\vec x) if f(x⃗) ⁣ ⁣↓f(\vec x)\converge, and does not terminate otherwise.

Proof of Proposition 8.3.

By induction on the definition of ff, as for Proposition 5.4, with one additional case: for minimization, the algorithm runs the computations of g(x⃗,0),g(x⃗,1),…g(\vec x, 0), g(\vec x, 1), \dots one after the other, as described above. In the composition and recursion cases, the algorithm computes the subexpressions in order and does not terminate if one of them does not. A precise version of this proof, for WHILE programs, is given in the lesson LOOP and WHILE programs.

Every primitive recursive function is recursive. The converse fails:

Proposition 8.4.#

The Ackermann function is recursive.

Proof of Proposition 8.4.

By the last exercise of the lesson The Ackermann function, the graph G={(x,y,z):A(x,y)=z}G = \{(x, y, z) : A(x, y) = z\} is primitive recursive. Hence A(x,y)=μz G(x,y,z)A(x, y) = \mu z\, G(x, y, z), and the search terminates since (x,y,A(x,y))∈G(x, y, A(x, y)) \in G.

This is an instance of a general principle: a total function whose graph is recursive is recursive, by searching for the value.

8.3 Examples

  1. μy [x−˙y=0]=x\mu y\, [x \dotminus y = 0] = x, since x−˙y=0x \dotminus y = 0 iff y≥xy \geq x.
  2. With ∣a−b∣=(a−˙b)+(b−˙a)|a - b| = (a \dotminus b) + (b \dotminus a), the function r(x)≃μy [ ∣y⋅y−x∣=0 ]r(x) \simeq \mu y\, [\,|y \cdot y - x| = 0\,] is the square root of xx if xx is a perfect square, and is undefined otherwise.
  3. μy [x+y+1=0]\mu y\, [x + y + 1 = 0] is the nowhere defined function of xx. In particular the empty function is partial recursive.
  4. If f:N→Nf : \nat \to \nat is a recursive bijection, its inverse f−1(y)=μx [f(x)=y]f^{-1}(y) = \mu x\, [f(x) = y] is recursive.

8.4 Regular minimization

Kleene originally defined the total recursive functions using minimization only in the regular case.

Definition 8.5.#

A total function g:Nk+1→Ng : \nat^{k+1} \to \nat is regular if for every x⃗\vec x there is yy with g(x⃗,y)=0g(\vec x, y) = 0.

Minimization applied to a regular total function yields a total function. Let R\mathcal{R} be the smallest class of total functions containing the basic functions and closed under composition, primitive recursion and regular minimization. Every function of R\mathcal{R} is recursive, since regular minimization is a special case of minimization. The converse — every total partial recursive function belongs to R\mathcal{R} — is not obvious: a partial recursive definition of a total function may use partial functions in intermediate steps. It is a consequence of the normal form theorem below.

8.5 Kleene’s normal form

The following theorem, proved in the lesson Equivalence of the models, shows that a single unbounded search suffices to compute any partial recursive function.

Theorem 8.6 (Kleene’s normal form, statement).#

There are a primitive recursive predicate Tk⊆Nk+2T_k \subseteq \nat^{k+2} for each k≥1k \geq 1, and a primitive recursive function U:N→NU : \nat \to \nat, such that for every partial recursive f:Nk⇀Nf : \nat^k \rightharpoonup \nat there is e∈Ne \in \nat with

f(x⃗)≃U(μs Tk(e,x⃗,s))for all x⃗.f(\vec x) \simeq U\big(\mu s\, T_k(e, \vec x, s)\big) \quad \text{for all } \vec x.

Informally: ee codes a program for ff; Tk(e,x⃗,s)T_k(e, \vec x, s) states that ss codes a complete halting computation of the program ee on input x⃗\vec x; and U(s)U(s) extracts the output from the computation ss. Checking that a given number codes a correct halting computation only requires bounded loops, hence TkT_k is primitive recursive. Only finding the computation requires an unbounded search.

Corollary 8.7.#

Every total recursive function belongs to the class R\mathcal{R} defined with regular minimization.

Proof of Corollary 8.7.

If ff is total, then for every x⃗\vec x there is ss with Tk(e,x⃗,s)T_k(e, \vec x, s), so the function (x⃗,s)↦sg‾(χTk(e,x⃗,s))(\vec x, s) \mapsto \overline{\mathrm{sg}}(\chi_{T_k}(e, \vec x, s)) is regular. Hence f=U∘μs [sg‾(χTk(e,x⃗,s))=0]f = U \circ \mu s\, [\overline{\mathrm{sg}}(\chi_{T_k}(e, \vec x, s)) = 0] is obtained from primitive recursive functions by one regular minimization and one composition.

8.6 Exercises

Exercise 8.8 ★.

Show that the recursive predicates are closed under the boolean connectives and bounded quantification, and that the recursive functions are closed under bounded minimization over recursive predicates.

Solution

The total recursive functions contain the primitive recursive functions and are closed under composition and primitive recursion, since these operations preserve totality. The proofs given for primitive recursive predicates and functions in the lesson Primitive recursive functions only use these closure properties, applied to characteristic functions, which are total. They therefore apply verbatim to recursive predicates and functions.

Exercise 8.9 ★★.

Let g:N→Ng : \nat \to \nat be recursive and strictly increasing. Show that its range is a recursive set, and that the function h(y)=h(y) = “the least xx such that g(x)≥yg(x) \geq y” is recursive.

Solution

Since gg is strictly increasing, g(x)≥xg(x) \geq x, so y∈im⁡g  ⟺  ∃x≤y g(x)=yy \in \operatorname{im} g \iff \exists x \leq y\ g(x) = y, a bounded quantification over a recursive predicate. The function h(y)=μx [g(x)≥y]h(y) = \mu x\, [g(x) \geq y] is a minimization of a recursive predicate, which is regular since g(y)≥yg(y) \geq y; hence hh is recursive (and even h(y)=μx≤y [g(x)≥y]h(y) = \mu x \leq y\, [g(x) \geq y]).

Exercise 8.10 ★★.

Let f(x)≃μy [g(x,y)=0]f(x) \simeq \mu y\, [g(x, y) = 0] for a partial recursive gg. Is it true that dom⁡f={x:∃y g(x,y)=0}\dom f = \{x : \exists y\ g(x, y) = 0\}? Give a proof or a counterexample.

Solution

It is false in general: we always have dom⁡f⊆{x:∃y g(x,y)=0}\dom f \subseteq \{x : \exists y\ g(x, y) = 0\}, but the converse fails when g(x,z)g(x, z) diverges for some zz smaller than every zero. For example, let g(x,y)≃μz [z+sg‾(y)=0]g(x, y) \simeq \mu z\, [z + \overline{\mathrm{sg}}(y) = 0]. For y≥1y \geq 1, sg‾(y)=0\overline{\mathrm{sg}}(y) = 0 and g(x,y)=0g(x, y) = 0; for y=0y = 0, the search μz [z+1=0]\mu z\, [z + 1 = 0] diverges. Then ∃y g(x,y)=0\exists y\ g(x, y) = 0 holds for all xx, but ff is nowhere defined, since the search for f(x)f(x) is stuck at y=0y = 0.

8.7 Notes and references

The general recursive functions were defined by Gödel in 1934, following a suggestion of Herbrand, through systems of equations. Kleene gave the characterization by minimization and proved the normal form theorem in 1936.

  • S. C. Kleene, General recursive functions of natural numbers, Mathematische Annalen 112 (1936), 727–742.
  • S. C. Kleene, Introduction to Metamathematics, North-Holland, 1952, chapters XI–XII.