{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nFix a standard [[Gödel numbering|MFJXPAF0R0]] of programs, and let $\\varphi_e$ be the partial [[computable function|KZSB5E471K]] of one argument computed by program $e$.\nLet $f \\colon \\N \\to \\N$ be a total computable function.\nThen there is $e \\in \\N$ such that $\\varphi_e = \\varphi_{f(e)}$ as partial functions.\n\n## Remarks\n\nBy the [[smn theorem|YWX4FCFPAP]], there is a total computable $h$ such that $\\varphi_{h(u)} = \\varphi_{\\varphi_u(u)}$ whenever $\\varphi_u(u)$ is defined.\nThe composite $f \\circ h$ is total computable, so it equals $\\varphi_v$ for some $v$.\nPut $e = h(v)$.\nThen $\\varphi_e = \\varphi_{\\varphi_v(v)} = \\varphi_{f(h(v))} = \\varphi_{f(e)}$.\n\nAn equivalent form: for every partial computable $\\psi(e, x)$ there is $e$ with $\\varphi_e(x) \\simeq \\psi(e, x)$ for all $x$.\nHere $\\simeq$ means that both sides are undefined, or both are defined and equal.\nExample: with $\\psi(e, x) = e$ one gets a program $e$ that outputs its own number on every input, a \"quine\".\n\nThe function $f$ need not have a fixed point $e = f(e)$; the theorem only gives a fixed point of the programs' behaviour.\nFor instance $f(e) = e + 1$ has no fixed point in $\\N$, but some $e$ and $e + 1$ compute the same function.\n\n## Explanations\n\n### L1 human\n\nThe theorem says that a program may refer to its own code.\nAny mechanical transformation of programs leaves the behaviour of at least one program unchanged.\nA classic consequence is that there are programs that print their own source code.\n\n### L2 human\n\nThe recursion theorem justifies definitions in which a program calls itself by index, which is how general recursion is handled inside computability theory.\nIts proof is a diagonal argument and is closely related to the diagonal lemma used in [[Gödel's incompleteness theorems|X9WYNYE29C]].\nIt gives a short proof of [[Rice's theorem|AKDR5YBBE2]] and of the undecidability of the [[halting problem|Z7TN2B35B0]].\n",
  "commit": "547b6eddb8f2feb8d579f2d633d22a27b7e132fc",
  "front": {
    "about": [
      "KZSB5E471K"
    ],
    "kind": "statement",
    "msc": [
      "03D20"
    ],
    "name": "Kleene's recursion theorem",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q1933521",
      "wikipedia": "Kleene's recursion theorem"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Kleene's_recursion_theorem"
      }
    ],
    "tag": "F3Z30M606H",
    "uses": [
      "KZSB5E471K",
      "MFJXPAF0R0"
    ]
  },
  "kind": "statement",
  "link": "https://math2.tamnd.com/node/F3Z30M606H/",
  "links": [
    {
      "field": "about",
      "target": "KZSB5E471K"
    },
    {
      "field": "uses",
      "target": "KZSB5E471K"
    },
    {
      "field": "uses",
      "target": "MFJXPAF0R0"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/F3Z30M606H.md",
  "msc": [
    "03D20"
  ],
  "name": "Kleene's recursion theorem",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/F3Z/F3Z30M606H.md",
  "status": null,
  "tag": "F3Z30M606H",
  "uri": "m2://F3Z30M606H",
  "url": "https://math2.tamnd.com/wiki/kleenes-recursion-theorem/",
  "writing": {
    "tag": "F3Z30M606H",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
