ExplorationsNumbering formulas, and putting a formula’s number back inside it

A Sentence About Its Own Number

Exhaustively checkedlogicself-referenceencodingadvanced

Assign mathematical formulas whole-number codes that can be decoded again. In this laboratory, the formula 0 = 0 has code 5, so arithmetic with 5 can refer to that expression as data. Substituting codes into formulas builds a route to . The laboratory demonstrates numbering and used in Gödel’s work, not a system or the incompleteness itself.

Current view: Numbering

A formula becoming one integer, one symbol at a time.

Numbering · number 50 = 0
=50000
  1. 000 × 10 + 0 = 0
  2. 000 × 10 + 0 = 0
  3. =0 = 0⟨0, 0⟩ = 0 × 1 / 2 + 0 = 00 × 10 + 5 = 5
Every symbol and its code, as a table
Each node of the formula in the order its code is worked out: the symbol, the digit it is given, what it is applied to, and the arithmetic that produces its code
StepSymbolIts digitReads asPairingCode
1zero00-0 × 10 + 0 = 0
2zero00-0 × 10 + 0 = 0
3equals50 = 0⟨0, 0⟩ = 0 × 1 / 2 + 0 = 00 × 10 + 5 = 5
symbol
one node of the tree: the thing being applied, drawn as its own sign
the code
the number written under a symbol, standing for everything beneath it
the pairing
two children folded into one number before the symbol adds its digit

The tree is the formula: each node is one symbol, its children are what it is applied to, and the number under a node is that subtree’s code. Codes are worked out from the leaves upwards, so every line of arithmetic uses numbers already on the screen. A node with two children pairs their codes first, by Cantor’s rule ⟨a, b⟩ = (a + b)(a + b + 1) / 2 + b, and then multiplies by ten and adds the symbol’s own digit. The strip beneath collects those lines in the order they were worked out.

The formula 0 = 0 is the number 5, worked out from 3 symbols, each one multiplying by ten and adding its own digit.

The number
5
Symbols
3
Free variables
none

The formula

Step by step

Use Step for one change you can inspect, or Run to watch the changes accumulate.

Speed
Advanced parameters
Signature

Addition and multiplication both present, which is what a theory has to interpret before the incompleteness theorem says anything about it at all.

Cases worth seeing

Try this

The formula 0 = 0 is 5 and ¬(0 = 0) is 56. Without running anything, what is the number of ¬¬(0 = 0)? Then type it into the decoding view and see whether the formula comes back.

1/3

What is going on

Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.

Worked by handThe formula ¬(0 = 0) becoming the number 56, one symbol at a time. Every line is a multiplication by ten and an addition, and the pairing rule is used once.
  1. 00 × 10 + 00zero is symbol 0 and takes no argument, so it carries nothing and its code is 0
  2. 0 and 0⟨0, 0⟩ = 0 × 1 / 2 + 00the two sides of the are paired into one number by Cantor’s rule
  3. 0 = 00 × 10 + 55equals is symbol 5, so the whole formula 0 = 0 is the number 5
  4. ¬(0 = 0)5 × 10 + 656negation is symbol 6, and wrapping it round appends one digit and nothing else

The laboratory draws that as a tree rather than a list: each symbol is a , its code is written underneath it, and the codes are worked out from the leaves upwards so that every line of arithmetic uses numbers already on the screen.

Because each successor multiplies a code by ten and adds one, the numeral for a number is a row of ones. The number 296 written in this language is S applied 296 times to 0, and its code is 296 ones in a row. That is what makes the next part readable: a formula can carry another formula's number around inside it, and you can still see which number it is.

01

What you are seeing

A plain description of the process

Begin with a small formula such as 0 = 0. The laboratory's numbering scheme gives this formula code 5. This is an agreed encoding, not a calculation saying that zero equals five: the number 5 represents the written expression.

The language has ten kinds of construction. Five build terms, which name numbers: zero, successor, , addition and multiplication. Five build formulas: equality, negation, conjunction, a universal quantifier and the symbol Prov. That last symbol has no implemented meaning about provability in this laboratory.

Each kind has a tag from 0 to 9. A construction receives a code by multiplying its argument code by ten and adding its tag. Where it needs two arguments, their codes are first combined by a reversible pairing operation.

Decoding reverses these steps. Dividing 5 by ten leaves 5, the equality tag, and quotient 0, which unpairs into the two zero terms. More complicated codes are decoded recursively; some numbers are rejected because they encode no well-formed expression.

The view then replaces a formula's free with a numeral built from a code. This is a concrete ingredient of , not an implementation of a predicate or a proof of the incompleteness .

02

Why it starts to make sense

Intuition, before any algebra

A formula is a piece of writing about numbers. It cannot be about a formula, because formulas are not numbers, and there is no symbol in the language that means "formula".

Numbering removes that obstacle in the most literal way available. Once every formula has a number, and the numbering can be undone, a statement about a number is a statement about a formula. Nothing mystical happens: what changes is that a language whose only subject matter was arithmetic now has arithmetic that stands for its own syntax.

The second step is smaller than it looks. A formula with one free is a slot waiting for a number. It has a code, and its code is a number. So there is nothing to stop you putting a formula's own code into its own slot, and once you have done it, the resulting sentence is about the formula you started from.

This is why the smallest example matters more than the famous one. The formula is the number 5. Wrap a negation round it and it is 56. The formula is 296. Substituting 296 into it gives a sentence which, read out, says that the formula numbered 296 is not provable, and 296 is the formula that sentence came from.

03

The key idea

Two , stacked

The scheme is built from two reversible steps, and reversible is the load-bearing word.

The symbol code. For a with symbol digit and payload ,

Division with recovers and uniquely, which is why one number can be read back as a symbol and its argument.

The pairing. A symbol with two arguments has two codes to store in one payload, and Cantor's pairing does it:

This walks the of the quarter plane, hitting every exactly once, so it can be undone as well.

Gödel used products of powers instead, which is a perfectly good and produces codes of dozens of digits for the shortest formula there is. The pairing is chosen here for one reason: has code 5, and a reader can check the arithmetic without a computer.

Corner quotes. Writing for the numeral of 's code lets a sentence be printed as rather than as 296 successors. It is shorthand for how the page prints, not an extra symbol in the language.

04

Formal statement

Four statements, and which of them this page settles

Let be the language above and the code of .

  1. is and effectively invertible: there is an algorithm which, given , returns the unique with or reports that there is none. Proved below, and checked exhaustively over every formula of depth at most 4 over three .
  2. . For a theory interpreting enough arithmetic and any with one free , there is a sentence with . Proved in the literature, and not here. What this laboratory carries out is the construction: , in which 's code appears inside the sentence produced.
  3. . If is consistent, effectively axiomatised and interprets enough arithmetic, then is incomplete. Cited, and not reproduced anywhere on this page.
  4. Presburger. First-order arithmetic with addition and without multiplication is complete and decidable. Proved in the literature, and the reason statement 3 has the conditions it has.

The distance between 2 and what the laboratory does is worth stating exactly. The lemma delivers a sentence equivalent to a statement about its own code; the construction here produces a sentence containing the code of the formula it was made from. Closing that gap requires a represented inside , and there is no here.

05

Proof

The numbering is and invertible

Claim. The map from formulas of to is , and there is an algorithm recovering from .

Cantor's pairing is a . For put . Then , and since , the value lies in . Those intervals for are disjoint and cover the , so every determines uniquely, then , then . ∎

One is recoverable. A node's code is with . Division by ten with gives and uniquely, so the symbol and its payload are both determined. ∎

on height. A leaf is or a : its code determines which, and for a variable the payload is the index. For a of height , the code gives its symbol and payload; the symbol says whether the payload is one child's code or a pair, and in the pair case the pairing is undone into two codes. Each child has height at most , so by induction each is determined by its code. Hence the whole tree is determined. ∎

Effectiveness. The recovery is a finite computation: one division per , one per pairing. It is what decode performs, and it either returns a formula or reports that the number codes none, since a payload may name a term where a formula is required. ∎

What this does not touch. It says nothing about provability, and the words "consistent", "" and "" do not appear in it. It is a statement about a numbering scheme. The incompleteness theorem is not established anywhere on this page, and could not be: this laboratory has no theory, no axioms and no notion of derivation. is a symbol with a suggestive name and no meaning attached to it at all.

06

Limits and frontier

What the laboratory is and is not

What this laboratory implements. The numbering and the construction, which are two ingredients of Gödel's . It does not implement provability. There is no proof predicate, no set, no derivations and no search: is an uninterpreted symbol. It does not prove the , and no setting on this page brings it closer to doing so. The theorem is cited in the ledger above and reproduced nowhere.

What is actually checked here. Every formula of depth at most 4 over three goes through the encoder and back and returns unchanged, and every below a million either decodes to a formula that encodes back to itself or is refused. That is a finite check of a scheme whose general correctness is settled by the in layer 5, not by the check.

Where the stops applying. The failure preset drops multiplication. Every part of the machinery on this page carries on working in that fragment: formulas have codes, codes come apart, the construction produces its sentence. What is gone is the conclusion, because Presburger arithmetic is complete and decidable, so there is no undecidable sentence in it to construct. That is the sharpest thing this page can say about the theorem's conditions: they are not decoration, and removing one symbol removes the theorem.

The gap that stays open on this page. The construction here produces a sentence carrying the code of the formula it was built from. The produces a sentence provably equivalent to a statement about its own code. Getting from the first to the second needs a theory that can represent as an arithmetic relation, which is the technical heart of Gödel's paper and is the part a browser cannot usefully show you.

Read this next to The Sequence That Reads Itself Aloud. There a rule reads its own output and writes down what it saw, and the self-description is at the level of digits. Here it is at the level of statements, and the extra machinery needed to move between the two levels is what took until 1931 to find.

What is actually established

Every statement on this page, with its status, its exact scope, and the date that status was last checked.

Proved

Every formula of this toy language has a unique code, and the encoding is injective and effectively invertible.

Scope
Every formula of the ten-symbol language defined on this page, with any variable indices and any depth.
Why
The argument is short enough to give in full, and layer 5 gives it. A node’s code is its payload times ten plus its symbol’s digit, and division by ten with remainder recovers both halves uniquely. A node with two children forms its payload by Cantor’s pairing, which is a bijection from pairs of natural numbers onto the natural numbers. A composition of bijections is a bijection, and induction on the height of the tree carries that up from the leaves. Injectivity and invertibility are the same fact stated twice.
Status checked
Exhaustively checked

Every formula of depth at most 4 over three variables is returned unchanged by encoding and decoding, and no two of them share a code.

Scope
All 15,264,560 formulas of depth at most 4 over the variables x, y and z, together with every integer below 1,000,000 taken the other way.
Why
The proof above is general and this is not: it is the finite check that the code implements the argument. Every formula in the range is encoded, decoded, and compared to the original structurally rather than by its code, which is exactly what injectivity over that set means. In the other direction every integer below a million either decodes to a formula that encodes back to itself, which 46,225 of them do, or is refused outright, which 953,775 of them are. Nothing here covers depth 5, and nothing here is what makes the general claim above true.
Computation (exact)
Exact integer arithmetic on arbitrary-precision integers throughout, run in the test suite rather than in your browser. 15,264,560 formulas enumerated by depth over three variables, each encoded and decoded and compared structurally; every integer from 0 to 999,999 decoded and re-encoded. Cross-checked against a second, independent encoding by prime powers over the Polish-notation symbol sequence, which agrees about which formulas are distinct. Algorithm godel-numbering-1.
Status checked
Proved

Diagonalisation produces, for any formula F(x) with one free variable, a sentence G equivalent to F(code of G).

Scope
Any theory interpreting enough arithmetic to represent the substitution function, for any formula F with one free variable.
Why
This is the Diagonal Lemma, and it is a theorem of the literature rather than of this page. What the laboratory carries out is the construction the lemma is named after: it takes F, works out F’s own code, and substitutes the numeral for that code back into F, so the code appears inside the sentence produced. Going from there to the lemma’s statement needs a substitution function represented inside the theory, and this laboratory has no theory and represents nothing. The construction is shown; the lemma is cited.
Status checked
Proved

Any consistent, effectively axiomatised theory interpreting enough arithmetic is incomplete: there is a sentence in its language that it neither proves nor refutes.

Scope
Every theory meeting all three conditions: consistent, with an effectively given set of axioms, and interpreting enough arithmetic to represent the syntactic relations.
Why
Cited and not reproduced. This laboratory implements the numbering and the diagonal construction, which are two ingredients of the proof. It does not implement provability: Prov is a bare symbol with a suggestive name, there is no proof predicate, no axioms, no derivations and no search. It does not prove the theorem, and no configuration of this page brings it any closer to proving it. The three conditions in the scope are the part most often dropped when the theorem is repeated, and the next claim is what they are there to exclude.
Status checked
Proved

Presburger arithmetic, which has addition but no multiplication, is complete and decidable.

Scope
First-order arithmetic over the natural numbers with 0, the successor and addition, and without multiplication.
Why
The warrant for the failure preset, and the reason it is a failure of the conclusion rather than of the machinery. Drop multiplication and the numbering still works, the codes are the same codes, and the diagonal construction still produces a sentence with its source formula’s number inside it. What is gone is the theorem: a complete and decidable theory has no undecidable sentence to find. Decidable does not mean easy, either, which is why Fischer and Rabin are cited beside Presburger.
Status checked

Sources

Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.

  1. Kurt Gödel, Über formal unentscheidbare Sätze der Principia Mathematica und verwandter Systeme I, Monatshefte für Mathematik und Physik 38, pp. 173–198, 1931. Link

    The original paper: the arithmetisation of syntax, the diagonal construction, and the first incompleteness theorem. Gödel numbers formulas with products of prime powers, which is why the code of a three-symbol formula there runs to several digits and the code of a three-symbol formula here is 5. Nothing on this page reproduces the proof.

    Bibliographic record checked. This is not an independent verification of the proof.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: publisher record.

    Publisher confirms author, title, 1931 and volume 38, pages 173–198.

  2. George S. Boolos, John P. Burgess, Richard C. Jeffrey, Computability and Logic, Cambridge University Press, fifth edition, 2007. Link

    A reference for computability and the diagonal lemma. Representing substitution inside a formal theory requires more than the external string manipulation implemented by this laboratory.

    Bibliographic record checked. This is not an independent verification of the proof.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: publisher record.

    Publisher's front matter confirms authors, fifth edition and 2007 publication.

  3. Mojżesz Presburger, Über die Vollständigkeit eines gewissen Systems der Arithmetik ganzer Zahlen, in welchem die Addition als einzige Operation hervortritt, Comptes Rendus du I congrès de Mathématiciens des Pays Slaves, 1929. Link

    The classical reference for decidability of arithmetic with addition. The laboratory can encode strings from this fragment externally, but that is not an internal diagonal lemma or an incompleteness proof for Presburger arithmetic.

    Bibliographic record checked. This is not an independent verification of the proof.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: library record.

    National academic catalogue confirms the 1929 proceedings citation; original proof was not inspected.

  4. Michael J. Fischer, Michael O. Rabin, Super-exponential complexity of Presburger arithmetic, Complexity of Computation, SIAM-AMS Proceedings, 1974. Link

    Decidable is not the same as tractable: the decision procedure for Presburger arithmetic needs at least doubly exponential time. Cited beside Presburger so that the failure preset does not leave a reader thinking the complete fragment is the easy one.

    Bibliographic record checked. This is not an independent verification of the proof.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: author record.

    University research record confirms authors, title and 1974 proceedings publication.

  5. Raymond M. Smullyan, Gödel’s Incompleteness Theorems, Oxford University Press, 1992. Link

    A short book-length treatment of what the theorem requires of a theory: consistency, an effectively given axiom set, and enough arithmetic to represent the syntactic relations. Cited for the conditions in the ledger, which are the part most often dropped when the theorem is repeated informally.

    Bibliographic record checked. This is not an independent verification of the proof.

    Bibliographic review:

    AI-assisted bibliographic audit. Evidence type: publisher record.

    Publisher confirms Smullyan, title and October 1992 publication.

Connected by how they work, not by sharing a topic label.