# Diagonal lemma

In mathematical logic, the diagonal lemma (also known as diagonalization lemma, self-reference lemma or fixed point theorem) establishes the existence of self-referential sentences in certain formal theories.
A particular instance of the diagonal lemma was used by Kurt Gödel in 1931 to construct his proof of the incompleteness theorems as well as in 1933 by Tarski to prove his undefinability theorem. In 1934, Carnap was the first to publish the diagonal lemma at some level of generality. The diagonal lemma is named in reference to Cantor's diagonal argument in set and number theory.
The diagonal lemma applies to any sufficiently strong theories capable of representing the diagonal function. Such theories include first-order Peano arithmetic ${\mathsf {PA}}$, the weaker Robinson arithmetic ${\mathsf {Q}}$ as well as any theory containing ${\mathsf {Q}}$ (i.e. which interprets it). A common statement of the lemma (as given below) makes the stronger assumption that the theory can represent all recursive functions, but all the theories mentioned have that capacity, as well.

## Background
###### Gödel Numbering

The diagonal lemma also requires a Gödel numbering $\alpha$. We write $\alpha (\varphi )$ for the code assigned to $\varphi$ by the numbering. For ${\overline {n}}$, the standard numeral of $n$ (i.e. ${\overline {0}}=_{df}{\mathsf {0}}$ and ${\overline {n+1}}=_{df}{\mathsf {S}}({\overline {n}})$), let $\ulcorner \varphi \urcorner$ be the standard numeral of the code of $\varphi$ (i.e. $\ulcorner \varphi \urcorner$ is ${\overline {\alpha (\varphi )}}$). We assume a standard Gödel numbering

###### Representation Theorem

Let $\mathbb {N}$ be the set of natural numbers. A first-order theory $T$ in the language of arithmetic containing ${\mathsf {Q}}$ represents the $k$-ary recursive function $f:\mathbb {N} ^{k}\rightarrow \mathbb {N}$ if there is a formula $\varphi _{f}(x_{1},\dots ,x_{k},y)$ in the language of $T$ s.t. for all $m_{1},\dots ,m_{k}\in \mathbb {N}$, if $f(m_{1},\dots ,m_{k})=n$ then $T\vdash \forall y(\varphi _{f}({\overline {m_{1}}},\dots ,{\overline {m_{k}}},y)\leftrightarrow y={\overline {n}})$.
The representation theorem is provable, i.e. every recursive function is representable in $T$.

## The Diagonal Lemma and its proof

   Diagonal Lemma: Let $T$ a first-order theory containing ${\mathsf {Q}}$ (Robinson arithmetic) and let $\psi (x)$ be any formula in the language of $T$ with only $x$ as free variable. Then there is a sentence $\varphi$ in the language of $T$ s.t. $T\vdash \varphi \leftrightarrow \psi (\ulcorner \varphi \urcorner )$.
Intuitively, $\varphi$ is a self-referential sentence which "says of itself that it has the property $\psi$."
Proof: Let $diag_{T}:\mathbb {N} \to \mathbb {N}$ be the recursive function which associates the code of each formula $\varphi (x)$ with only one free variable $x$ in the language of $T$ with the code of the closed formula $\varphi (\ulcorner \varphi \urcorner )$ (i.e. the substitution of $\ulcorner \varphi \urcorner$ into $\varphi$ for $x$) and $0$ for other arguments. (The fact that $diag_{T}$ is recursive depends on the choice of the Gödel numbering, here the standard one.)
By the representation theorem, $T$ represents every recursive function. Thus, there is a formula $\delta (x,y)$ be the formula representing $diag_{T}$, in particular, for each $\varphi (x)$, $T\vdash \delta (\ulcorner \varphi \urcorner ,y)\leftrightarrow y=\ulcorner \varphi (\ulcorner \varphi \urcorner )\urcorner$.
Let $\psi (x)$ be an arbitrary formula with only $x$ as free variable. We now define $\chi (x)$ as $\exists y(\delta (x,y)\land \psi (x))$, and let $\varphi$ be $\chi (\ulcorner \chi \urcorner )$. Then the following equivalences are provable in $T$:
$\varphi \leftrightarrow \chi (\ulcorner \chi \urcorner )\leftrightarrow \exists y(\delta (\ulcorner \chi \urcorner ,y)\land \psi (y))\leftrightarrow \exists y(y=\ulcorner \chi (\ulcorner \chi \urcorner )\urcorner \land \psi (y))\leftrightarrow \exists y(y=\ulcorner \varphi \urcorner \land \psi (y))\leftrightarrow \psi (\ulcorner \varphi \urcorner )$.

## Some Generalizations

There are various generalizations of the Diagonal Lemma. We present only three of them; in particular, combinations of the below generalizations yield new generalizations. Let $T$ be a first-order theory containing ${\mathsf {Q}}$ (Robinson arithmetic).

###### Diagonal Lemma with Parameters

Let $\psi (x,y_{1},\dots ,y_{n})$ be any formula with free variables $x,y_{1},\dots ,y_{n}$.
Then there is a formula $\varphi (y_{1},\dots y_{n})$ with free variables $y_{1},\dots ,y_{n}$ s.t. for all $m_{1},\dots ,m_{n}\in \mathbb {N}$, $T\vdash \varphi (y_{1},\dots ,y_{n})\leftrightarrow \psi (\ulcorner \varphi (y_{1},\dots ,y_{n})\urcorner ,y_{1},\dots ,y_{n})$.

###### Uniform Diagonal Lemma

Let $\psi (x,y_{1},\dots ,y_{n})$ be any formula with free variables $x,y_{1},\dots ,y_{n}$.
Then there is a formula $\varphi (y_{1},\dots y_{n})$ with free variables $y_{1},\dots ,y_{n}$ s.t. for all $m_{1},\dots ,m_{n}\in \mathbb {N}$, $T\vdash \varphi ({\overline {m_{1}}},\dots ,{\overline {m_{n}}})\leftrightarrow \psi (\ulcorner \varphi ({\overline {m_{1}}},\dots ,{\overline {m_{n}}})\urcorner ,{\overline {m_{1}}},\dots ,{\overline {m_{n}}})$.

###### Simultaneous Diagonal Lemma

Let $\psi _{1}(x_{1},x_{2})$ and $\psi _{2}(x_{1},x_{2})$ be formulae with free variable $x_{1}$ and $x_{2}$.
Then there are sentence $\varphi _{1}$ and $\varphi _{2}$ s.t. $T\vdash \varphi _{1}\leftrightarrow \psi _{1}(\ulcorner \varphi _{1}\urcorner ,\ulcorner \varphi _{2}\urcorner )$ and $T\vdash \varphi _{2}\leftrightarrow \psi _{2}(\ulcorner \varphi _{1}\urcorner ,\ulcorner \varphi _{2}\urcorner )$.
The case with $n$ many formulae is similar.

## History

The lemma is called "diagonal" because it bears some resemblance to Cantor's diagonal argument. The terms "diagonal lemma" or "fixed point" do not appear in Kurt Gödel's 1931 article or in Alfred Tarski's 1936 article.
In 1934, Rudolf Carnap was the first to publish the diagonal lemma in some level of generality, which says that for any formula $\psi (x)$ with $x$ as free variable (in a sufficiently expressive language), then there exists a sentence $\varphi$ such that $\varphi \leftrightarrow \psi (\ulcorner \varphi \urcorner )$ is true (in some standard model). Carnap's work was phrased in terms of truth rather than provability (i.e. semantically rather than syntactically). Remark also that the concept of recursive functions was not yet developed in 1934.
The diagonal lemma is closely related to Kleene's recursion theorem in computability theory, and their respective proofs are similar. In 1952, Léon Henkin asked whether sentences that state their own provability are provable. His question led to more general analyses of the diagonal lemma, especially with Löb's theorem and provability logic.