Fact-checked by Grok 2 weeks ago

Kleene's recursion theorem

Kleene's recursion theorem, a fundamental result in , states that for any partial \psi(e, \vec{y}) of one or more arguments, there exists an index e such that the e-th partial \phi_e(\vec{y}) satisfies \phi_e(\vec{y}) \simeq \psi(e, \vec{y}) for all \vec{y}, where \simeq denotes equality whenever both sides are defined. This theorem, often referred to as the , enables the construction of self-referential s and programs that can refer to their own indices or descriptions. The theorem has two primary variants: the first recursion theorem, which applies to total recursive functions f(x) and guarantees an index n such that \phi_n(y) \simeq \phi_{f(n)}(y) for all y, and the second recursion theorem, which generalizes this to partial functions with parameters as above. first proved these results in 1938 while developing a system of ordinal notations, with a more accessible presentation appearing in his 1952 monograph Introduction to Metamathematics. The theorems rely on key properties of recursive enumerations, such as the s-m-n theorem (which allows parameterization of indices) and the existence of a universal recursive function that simulates any partial recursive function from its index. Kleene's recursion theorem plays a central role in recursion theory by formalizing , analogous to diagonal arguments in logic, and has profound implications for understanding the . It underpins proofs of , the existence of self-reproducing Turing machines, and the construction of quines—programs that output their own . Applications extend to effective descriptability in , the hierarchy of recursive functions, and modern concepts like viral code propagation and program transformation, demonstrating that no total recursive transformation can avoid fixed points in the space of all partial recursive functions.

Preliminaries

Notation and Definitions

In recursion theory, partial recursive functions form the class of computable partial functions from natural numbers to natural numbers, and they admit an effective enumeration indexed by natural numbers via Gödel numbering. Specifically, they admit an effective enumeration \{\phi_e\}_{e \in \mathbb{N}} indexed by the natural numbers via Gödel numbering (though not bijectively, as multiple indices may define the same function), allowing each partial recursive function to be denoted as \phi_e, the e-th partial recursive function in this enumeration, where e \in \mathbb{N} serves as its Gödel number or index. For any index e and input x \in \mathbb{N}, \phi_e(x) is defined if the computation halts and yields a value; otherwise, it is , corresponding to non-termination or in the underlying or recursive scheme. The domain of \phi_e is the set \{ x \in \mathbb{N} \mid \phi_e(x) \downarrow \}, where \downarrow indicates to a defined value, and the range is \{ \phi_e(x) \mid x \in \dom(\phi_e) \}. The s-m-n theorem provides a mechanism for composing and specializing indices of partial recursive functions. It states that for fixed m, n \geq 0, there exists a total s_m^n : \mathbb{N}^{m+1} \to \mathbb{N} such that for all e \in \mathbb{N}, \vec{x} \in \mathbb{N}^m, and \vec{y} \in \mathbb{N}^n, \phi_{s_m^n(e, \vec{x})}(\vec{y}) = \phi_e(\vec{x}, \vec{y}), enabling the effective construction of new indices by fixing initial arguments. A universal partial recursive function captures the entire enumeration. There exists a binary partial recursive function U(z, x) such that for all e, x \in \mathbb{N}, U(e, x) = \phi_e(x), often formalized via Kleene's normal form theorem as U(\mu y \, T(e, x, y)) = \phi_e(x), where T is the primitive recursive Kleene T-predicate verifying computation steps and \mu denotes the minimization operator. This notation and framework for indexing partial recursive functions were systematized by Stephen Kleene in his 1952 work on metamathematics.

Background on Recursive Functions

Primitive recursive functions form a class of total functions on the natural numbers constructed from basic functions—the constant zero function, the successor function, and projection functions—using two operations: composition and primitive recursion. The primitive recursion scheme allows defining a function f(y, 0) = g(y) and f(y, z+1) = h(y, z, f(y, z)) for some previously defined primitive recursive functions g and h, ensuring the function is defined for all inputs and computes in a bounded manner without unbounded searches. These functions capture many intuitive computable operations, such as addition and multiplication, but are limited, as demonstrated by the Ackermann function, which grows faster than any primitive recursive function. To extend this class to capture all effectively computable functions, Stephen Kleene introduced general recursive functions, also known as partial recursive functions, by adding a third operation: unbounded minimization, or the . This operator defines a new \mu y \, \phi(x, y) as the least y such that \phi(x, y) = 0, if such a y exists, allowing the resulting to be (diverge) on some inputs. Partial recursive functions thus include all primitive recursive functions but also permit non-total behavior, enabling the representation of algorithms that may not halt. The Church-Turing thesis posits that the partial recursive functions precisely characterize the set of functions that are effectively computable by any mechanical means, linking the formal definition to intuitive notions of computation. Formulated independently by using \lambda-definability and by via Turing machines in , the thesis asserts equivalence between these models and partial recursion, providing a foundational justification for using recursive functions to study computability. A key result in the theory is the enumeration theorem, which states that the partial recursive functions admit an effective enumeration \phi_e, where for every partial recursive function \psi there exists a e such that \psi = \phi_e, and \phi_e(x) is computed uniformly from e and x via a partial recursive function. This enumeration relies on to encode computations and follows from Kleene's normal form theorem, enabling the indexing of all such functions by . However, a fundamental limitation arises: the set \mathrm{TOT} = \{ e \mid \phi_e \text{ is total} \} is undecidable, as membership requires solving the for all inputs (Turing 1936), and more generally constitutes a non-trivial of the partial recursive functions under (1951), implying no algorithm can determine whether a given corresponds to a total function.

The Second Recursion Theorem

Statement

Kleene's second recursion theorem states that for any partial recursive function \psi(y, x), there exists a natural number e (an index) such that \phi_e(x) \simeq \psi(e, x) for all natural numbers x. Here, \{\phi_i\} denotes a standard effective enumeration of all partial recursive functions, and \simeq means that either both sides are undefined at x or both are defined and equal. This formulation embodies a fixed-point property, where the index e serves as a self-referential : \psi can incorporate computations that depend on e itself, effectively allowing a to describe or apply its own index during execution. If \psi(y, x) is total recursive (defined for all inputs), then the corresponding \phi_e(x) is also total recursive. Kleene proved the theorem in 1952 as part of his foundational contributions to recursion theory in Introduction to Metamathematics.

Proof

The proof of Kleene's second recursion theorem relies on the s-m-n theorem and a argument to construct a fixed point for the given partial \psi(y, x). By the s-m-n theorem (with n=1, m=1), there exists a total recursive function s(i, j) such that \phi_{s(i, j)}(x) \simeq \phi_i(j, x) for all i, j, x. Since \psi(y, x) is partial recursive, there exists an index v such that \phi_v(y, x) \simeq \psi(s(y, y), x). This is possible by : s(y, y) is total recursive, and substituting into \psi yields a partial recursive function. Now define e = s(v, v). Then, \phi_e(x) \simeq \phi_{s(v, v)}(x) \simeq \phi_v(v, x) \simeq \psi(s(v, v), x) = \psi(e, x) for all x, establishing the fixed point. For the general case of \psi(y, \vec{x}) with multiple input arguments \vec{x}, the construction extends analogously by using the appropriate of the s-m-n theorem to specialize the index parameter y. This proof assumes an acceptable Gödel numbering of partial recursive functions, where the s-m-n theorem holds and indices are effectively computable, which is satisfied in the standard model of Turing machines or equivalent computational models. The constructive nature ensures that the fixed-point index e can be explicitly computed from the description of \psi.

Relation to Rogers's Fixed-Point Theorem

Rogers's fixed-point theorem, introduced by Hartley Rogers Jr. in 1967, states that for any recursive functional T mapping from the space of partial recursive functions to itself, there exists an index e such that T(\varphi_e) = \varphi_e, where \varphi_e denotes the partial recursive function with index e under a standard . This formulation establishes the existence of fixed points directly in the , highlighting the self-referential capabilities inherent in recursive functionals. Kleene's second recursion theorem is isomorphic to Rogers's fixed-point theorem, with the equivalence established through the s-m-n theorem, which serves as a form of in . Specifically, Kleene's theorem implies Rogers's by transforming functionals on indices into operators on functions, while Rogers's theorem specializes to Kleene's when restricted to index-based constructions. This mutual implication underscores their shared foundation in enabling within . Historically, Rogers's version extended Kleene's earlier work by generalizing the result to abstract models of , beyond the concrete setting of recursive function enumerations. A key difference in their formulations lies in the level of : Kleene's explicitly employs indices to construct self-referential functions, whereas Rogers's operates at the level of functionals on the entire space of partial functions, providing a more structural perspective on fixed points.

Applications of the Second Theorem

Quines and Self-Reference

A quine is a whose output is exactly its own . This form of self-replication demonstrates constructive , where a program can access and reproduce its own description without external input. Kleene's second recursion theorem enables the construction of quines by guaranteeing the existence of fixed points for computable functions, allowing a program to refer to its own index. Specifically, consider a partial computable function \psi(e, x) defined such that if x = 0, it outputs the source code of the program with index e, and otherwise computes \phi_e(x-1), where \phi_e is the function computed by index e. By the theorem, there exists an index e such that \phi_e(y) = \psi(e, y) for all y; thus, \phi_e(0) outputs the source code of \phi_e, yielding a quine. An example in illustrates this construction, assuming a mechanism to quote and concatenate code:
def quine():
    own_index = <self-reference to index e>  # Fixed point ensures this resolves to e
    code_template = "def quine():\n    own_index = {0}\n    code_template = {1}\n    print(code_template.format(own_index, repr(code_template)))\nquine()"
    print(code_template.format(own_index, repr(code_template)))
quine()
Here, the fixed-point property substitutes the program's own index, causing execution to print the entire source. This application highlights constructive self-reference in Turing-complete programming languages such as and , where quines can be explicitly written using similar quoting and evaluation mechanisms. Quines exist in any Turing-complete language as a direct consequence of Kleene's second , which ensures the of self-referential descriptions.

Elimination of

The second allows for the elimination of explicit in definitions of partial s by constructing self-referential fixed points that incorporate recursive calls implicitly. To illustrate, suppose one wishes to define a f satisfying f(x) = g(f(h(x))), where g and h are given partial s. Construct a partial \psi(e, x) = g(\phi_e(h(x))), where \phi_e is the e-th partial in a standard enumeration. By the second , there exists an index e such that \phi_e(x) = \psi(e, x) for all x, yielding \phi_e(x) = g(\phi_e(h(x))). Thus, f = \phi_e is obtained without any explicit recursive structure, as the self-reference via the fixed index e replaces the recursive invocation. This step-by-step construction parameterizes the definition over the e of the target , effectively "baking in" the recursive call through the fixed-point property of the of partial recursive functions. The begins by expressing the recursive step in terms of an application of the universal partial recursive function to the parameterized index, ensuring the resulting fixed point satisfies the original specification uniformly. Kleene originally applied this technique to simplify proofs involving ordinal notations, particularly in constructing effective systems that enumerate all constructive ordinals below the Church-Kleene ordinal. A primary advantage of this elimination is that it provides explicit indices for functions defined by recursive processes, facilitating rigorous proofs by reducing them to properties of the fixed-point indices within the standard enumeration. As a concrete example, consider the Ackermann function A(m, n), a total recursive function that grows faster than any primitive recursive function and is classically defined by the recursive equations: \begin{align*} A(0, n) &= n + 1, \\ A(m + 1, 0) &= A(m, 1), \\ A(m + 1, n + 1) &= A(m, A(m + 1, n)). \end{align*} To define it non-recursively via the fixed point, introduce primitive recursive functions c(z) = 0 if z = 0 and $1 otherwise, and \overline{c}(z) = 1 - c(z). Construct a binary partial recursive \psi(e, m, n) that computes the case analysis: \begin{align*} &\psi(e, m, n) \simeq (n + 1) \cdot \overline{c}(m) + \phi_e(m - 1, 1) \cdot c(m) \cdot \overline{c}(n) \\ &+ \phi_e(m - 1, \phi_e(m, n - 1)) \cdot c(m) \cdot c(n). \end{align*} The second recursion theorem yields an index e such that \phi_e(m, n) = \psi(e, m, n), and on m verifies that \phi_e(m, n) = A(m, n) for all m, n.

Reflexive Programming Languages

Reflexive programming languages are those that incorporate mechanisms for and self-modification, allowing a to access, examine, or alter its own or representation during execution. This reflexivity enables meta-programming techniques where code can treat itself as data, facilitating dynamic behaviors such as runtime or optimization. Kleene's second recursion theorem underpins the theoretical foundation for such languages by guaranteeing the existence of fixed points in computable functions, ensuring that self-referential programs can be constructed without circular definitions. A classic example is , which supports reflexivity through its quote form for treating code as data and the eval function for executing quoted expressions, enabling the creation of self-interpreters. In , a self-interpreter can be defined as a function that takes a quoted program and evaluates it within the same language environment, effectively interpreting its own definition; the recursion theorem ensures such a fixed-point interpreter exists by allowing the interpreter's index to be passed as an argument to itself. This construction leverages the theorem's fixed-point property to avoid explicit recursion schemes, producing an interpreter that applies uniformly to all programs, including itself. In modern contexts, reflexive features persist in languages like and , where eval enables metacompilation—compiling code at runtime based on self-analysis—for applications such as just-in-time optimization or dynamic scripting. The theorem's role extends to guaranteeing the computability of these self-applicable compilers without requiring special primitives beyond standard . However, reflexivity introduces undecidability challenges, as self-modifying systems inherit limitations like the ; for instance, determining whether a reflective will terminate when applied to its own is undecidable, mirroring Rice's theorem corollaries in . These implications highlight the theorem's influence on designing safe reflective systems while underscoring inherent computational boundaries.

The First Recursion Theorem

Statement and Example

Kleene's first recursion theorem asserts that for any total f(x), there exists an index n such that \phi_n(y) \simeq \phi_{f(n)}(y) for all y. This formulation guarantees a fixed point under a total recursive transformation of indices, without explicit parameters, enabling constructions where a is invariant under its own index transformation. In contrast to the second recursion theorem, which provides a parameterized fixed point for partial s, the first theorem yields an existential fixed point for functions, facilitating self-referential definitions in a non-parametric setting. A concrete example illustrates the theorem's utility. Suppose we wish to construct a that simulates another specified by an e, but transformed by a fixed recursive f. By the first recursion theorem, there exists n such that \phi_n = \phi_{f(n)}, meaning the n-th function is a fixed point of the f. For instance, if f(k) = k + 1, the theorem guarantees an n where \phi_n = \phi_{n+1}, demonstrating the existence of equivalent programs under shifts. This illustrates how the theorem supports structured definitions of s invariant under mappings, eliminating the need for explicit recursion schemes in such cases.

Proof Sketch

The proof of the first recursion theorem reduces to the second recursion theorem using the s-m-n theorem. Since f is total recursive, define the partial recursive function \psi(e, y) = \phi_{f(e)}(y). By the universal property, \psi is partial recursive. Applying the second recursion theorem to \psi, there exists an index n such that \phi_n(y) \simeq \psi(n, y) = \phi_{f(n)}(y) for all y. Since f is total and the numbering is acceptable, the fixed point preserves the relevant properties. The construction is effective, producing n computably from the index of f.

Comparison to the Second Theorem

The First Recursion Theorem (FRT) and the Second Recursion Theorem (SRT), both due to Stephen Kleene, differ in scope and formulation. The FRT applies to total recursive functions without parameters, guaranteeing an index n such that \phi_n(y) \simeq \phi_{f(n)}(y) for a total f, supporting fixed points under total transformations. In contrast, the SRT applies to partial recursive functions with parameters, guaranteeing a total recursive e(\vec{y}) such that \phi_{e(\vec{y})}(\vec{z}) \simeq \psi(e(\vec{y}), \vec{y}, \vec{z}), facilitating parameterized self-reference. The FRT's strength lies in its focus on total computability without parameters, suitable for constructions under mappings. The SRT excels in generality for partial functions with explicit parameters, essential for dynamic . Note that naming conventions for "first" and "second" vary in the literature; some sources (e.g., Moschovakis 2016) reverse the designations, with FRT as higher-order least fixed points and SRT as . The theorems are interrelated: the FRT can be derived from the SRT by specializing to cases without parameters, while the SRT extends the FRT via for partiality and parameters. A generalized recursion theorem encompasses both. In practice, the FRT suits non-parametric computations like fixed-point transformations, while the SRT underpins parameterized applications such as quines or undecidability proofs. Both were proved by Kleene in 1938 during his work on ordinal notations, with accessible presentations in his 1952 monograph Introduction to Metamathematics.

Extensions and Variations

Generalized Recursion Theorem

The generalized recursion theorem extends Kleene's original results to computations relative to an oracle O, ensuring the existence of fixed points in relativized settings. Specifically, for any oracle O and any partial recursive functional \psi^O relative to O, there exists an index e such that \phi_e^O(x) \simeq \psi^O(e, x) for all x, where \phi_e^O denotes the e-th partial function computable relative to O. This relativization follows directly from the standard proof of Kleene's second recursion theorem, as the underlying s-m-n theorem and universal Turing machine construction hold relative to any oracle. Extensions to higher-type recursion involve type-2 functionals, which operate on functions from naturals to naturals, as developed in Kleene's framework for the hyperarithmetical hierarchy. In this setting, the theorem generalizes to ensure self-referential definitions for functionals in the hyperarithmetical sets, computable via transfinite iterations up to the Church-Kleene ordinal \omega_1^{CK}. These extensions unify computability over higher-order objects, preserving fixed-point constructions within the analytical hierarchy. Abstract versions of the theorem apply in any Gödel-complete effective numbering system equipped with an s-m-n analog, guaranteeing the existence of fixed points for applicable partial functions. Such generalizations, pioneered by Platek in the through his work on admissible sets, extend to infinitary models where is defined over admissible ordinals and structures. These frameworks demonstrate that fixed points exist in a wide class of relative degrees, thereby unifying principles across diverse effective systems.

Fixed-Point-Free Functions

In computability theory, a total function f: \omega \to \omega is called fixed-point-free (FPF) if \varphi_{f(e)} \neq \varphi_e for every index e \in \omega, where \varphi_e denotes the e-th partial recursive function in some acceptable numbering of the partial recursive functions. Equivalently, f is FPF if W_{f(n)} \neq W_n for all n \in \omega, where W_n = \dom(\varphi_n) is the n-th recursively enumerable (r.e.) set. This notion arises naturally as a diagonalization concept contrasting with the self-referential fixed points guaranteed by Kleene's recursion theorem. Kleene's recursion theorem directly implies that no total recursive function is fixed-point-free. Specifically, for any total recursive f, there exists an index e such that \varphi_e = \varphi_{f(e)}, yielding a fixed point. This follows immediately from the theorem's statement that every total recursive function admits fixed points in the numbering of partial recursive functions. Thus, any FPF function, if it exists, must be non-recursive. Indeed, such functions do exist but require oracles of sufficient Turing degree; for example, the halting problem \emptyset' computes an FPF function via a simple diagonalization over the r.e. sets. The Turing degrees capable of computing FPF functions have been characterized in relation to low degrees and diagonalization strength. A set A computes an FPF A computes a total h such that \varphi_{h(e)} \neq \varphi_e for all e. Degrees computing such functions coincide with those that are diagonally non-computable (), meaning they compute a total g with g(e) \neq \varphi_e(e) whenever the latter is defined. No low c.e. degree (i.e., one with A' \leq_T \emptyset') computes an FPF , as confirmed by the low basis theorem, but there exist low degrees that do. A key variation and extension of Kleene's theorem in this context is Arslanov's completeness criterion for r.e. sets. A c.e. set A <_T \emptyset' computes no FPF function, as every A-computable total has a fixed point e with W_{f(e)} = W_e. Conversely, a c.e. set is Turing-complete (i.e., A \equiv_T \emptyset') it computes an FPF function. This criterion generalizes the non-existence result of Kleene's theorem to relative , highlighting the role of the jump operator in enabling strong enough to avoid fixed points entirely. It has implications for the structure of the c.e. Turing degrees, linking to the ability to perform effective anti-diagonalizations over all r.e. sets.

References

  1. [1]
    Recursive Functions - Stanford Encyclopedia of Philosophy
    Apr 23, 2020 · 3.4 The Recursion Theorem. The result which is now most often referred to as Kleene's Recursion Theorem can be used to unify a number of ...
  2. [2]
    Kleene's Recursion Theorem -- from Wolfram MathWorld
    The strongest form of the recursion theorem. This form states that for each k, there exists a recursive function f of k+2 variables such that f is a injection.
  3. [3]
    Introduction To Metamathematics : Stephen Cole Kleene
    Jun 20, 2023 · Introduction To Metamathematics. by: Stephen Cole Kleene. Publication date: 1952-01-01. Publisher: D. Van Nostrand Company Inc. Collection ...
  4. [4]
    [PDF] The Kleene Recursion Theorem - andrew.cmu.ed
    Apply s-m-n to this variable position and then apply Kleene's fixed point theorem. ... The Kleene recursion theorem has far wider significance than these examples.
  5. [5]
    [PDF] Kleene's amazing second recursion theorem. - UCLA Mathematics
    Kleene uses the theorem in the very next page to prove that there is a largest initial segment of the countable ordinals which can be given “constructive.
  6. [6]
    Theory of recursive functions and effective computability
    Nov 2, 2011 · Theory of recursive functions and effective computability. by: Rogers, H. (Hartley), 1926-. Publication date: 1967. Topics: Recursive functions ...
  7. [7]
    General recursive functions of natural numbers. - EuDML
    Kleene, S.C.. "General recursive functions of natural numbers.." Mathematische Annalen 112 (1936): 727-742. <http://eudml.org/doc/159849>.
  8. [8]
    [PDF] ON COMPUTABLE NUMBERS, WITH AN APPLICATION TO THE ...
    The "computable" numbers may be described briefly as the real numbers whose expressions as a decimal are calculable by finite means.
  9. [9]
    [PDF] Kleene Second Recursion Theorem: A Functional Pearl - okmij.org
    5 KLEENE ORIGINAL THEOREM. We now demonstrate that the Kleene original theorem is a special case of our staged lambda-calculus approach. Kleene has ...Missing: source 1952
  10. [10]
    [PDF] Fixed Point Theorems in Computability Theory - Mathematics
    The proof of the recursion theorem is very short, and it has an air of mystery. In Kleene's original paper [18], which is about ordinal notations, it is ...<|control11|><|separator|>
  11. [11]
    [PDF] CSCE 551 — Notes on Self-Reference in Computation
    Mar 29, 2024 · The Recursion Theorem also follows easily from the Fixed Point Theorem. The two theorems are so similar that some authors confuse the two and ...
  12. [12]
    Kleene's amazing Second Recursion Theorem - Project Euclid
    June 2010 Kleene's amazing Second Recursion Theorem. Yiannis N. Moschovakis · DOWNLOAD PDF + SAVE TO MY LIBRARY. Bull. Symbolic Logic 16(2): 189-239 (June ...Missing: original | Show results with:original
  13. [13]
    [PDF] Logic and Computation I - Chapter 1 Introduction to theory of ...
    Sep 26, 2024 · Kleene normal form theorem: every partial recursive function can be obtained from two fixed primitive recursive functions by applying µ-operator ...
  14. [14]
    [PDF] Kleene's Second Recursion Theorem and Self-Referencing Programs
    Oct 21, 2024 · Proof of Kleene's Second Recursion Theorem. The idea behind the proof is to divide the construction of the desired program Pe = ABC into three.
  15. [15]
  16. [16]
    [PDF] A theory of reflexive computation based on soft intuitionistic logic
    Nov 9, 2016 · Self-modifying programs are inherent to computability. This notion goes back to the second recursion. Theorem of Kleene [8,15]. The article [12] ...<|control11|><|separator|>
  17. [17]
    None
    Below is a merged summary of Kleene's Recursion Theorems based on the provided segments from Martin Davis (1958 and 1995). To retain all information in a dense and organized manner, I will use a combination of narrative text and a table in CSV format for key details. The narrative will provide an overview and relationships, while the table will capture specific statements, proofs, notations, and references across the sources.
  18. [18]
    Admissible Sets and Structures
    1974a Admissible Sets over Models of Set Theory, Generalized Recursion Theory, pp. ... Platek, R. 1966 Foundations of recursion theory, Doctoral ...
  19. [19]
    Degrees of Functions with no Fixed Points - ScienceDirect.com
    ... the Foundations of Mathematics. Degrees of Functions with no Fixed Points. Author links open overlay panel. Carl G. Jockusch Jr. Show more. Add to Mendeley.