ExplorationsNumbering formulas, and putting a formula’s number back inside it
A Sentence About Its Own Number
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 self-referenceDefinition: Self-reference occurs when a statement, program or object refers to itself.. The laboratory demonstrates numbering and substitutionDefinition: Substitution replaces specified symbols or expressions according to a stated rule. used in Gödel’s work, not a proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. system or the incompleteness theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. itself.
Current view: Numbering
A formula becoming one integer, one symbol at a time.
- 000 × 10 + 0 = 0
- 000 × 10 + 0 = 0
- =0 = 0⟨0, 0⟩ = 0 × 1 / 2 + 0 = 00 × 10 + 5 = 5
Every symbol and its code, as a table
| Step | Symbol | Its digit | Reads as | Pairing | Code |
|---|---|---|---|---|---|
| 1 | zero | 0 | 0 | - | 0 × 10 + 0 = 0 |
| 2 | zero | 0 | 0 | - | 0 × 10 + 0 = 0 |
| 3 | equals | 5 | 0 = 0 | ⟨0, 0⟩ = 0 × 1 / 2 + 0 = 0 | 0 × 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.
Advanced parameters
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.
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.
- 00 × 10 + 00zero is symbol 0 and takes no argument, so it carries nothing and its code is 0
- 0 and 0⟨0, 0⟩ = 0 × 1 / 2 + 00the two sides of the equationDefinition: An equation states that two expressions have equal values. are paired into one number by Cantor’s rule
- 0 = 00 × 10 + 55equals is symbol 5, so the whole formula 0 = 0 is the number 5
- ¬(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 nodeDefinition: A node is one object or state represented as a point in a graph., 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.
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, variablesDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified., 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 remainderDefinition: The remainder is what is left after making as many complete groups of a chosen positive integer size as possible. 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 substitutionDefinition: Substitution replaces specified symbols or expressions according to a stated rule. view then replaces a formula's free variableDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified. with a numeral built from a code. This is a concrete ingredient of self-referenceDefinition: Self-reference occurs when a statement, program or object refers to itself., not an implementation of a proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. predicate or a proof of the incompleteness theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results..
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 variableDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified. 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.
The key idea
Two bijectionsDefinition: A bijection is a correspondence in which every item on each side matches exactly one item on the other., stacked
The scheme is built from two reversible steps, and reversible is the load-bearing word.
The symbol code. For a nodeDefinition: A node is one object or state represented as a point in a graph. with symbol digit and payload ,
Division with remainderDefinition: The remainder is what is left after making as many complete groups of a chosen positive integer size as possible. 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 diagonalsDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. of the quarter plane, hitting every natural numberDefinition: Natural numbers are the counting numbers; conventions differ on whether zero is included. exactly once, so it can be undone as well.
Gödel used products of primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. powers instead, which is a perfectly good bijectionDefinition: A bijection is a correspondence in which every item on each side matches exactly one item on the other. 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.
Formal statement
Four statements, and which of them this page settles
Let be the language above and the code of .
- is injectiveDefinition: A function is injective when different inputs always produce different outputs. 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 variablesDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified..
- Diagonal LemmaDefinition: The diagonal lemma builds a sentence equivalent to a specified property of its own code, inside a formal system with enough arithmetic.. For a theory interpreting enough arithmetic and any with one free variableDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified., 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.
- First incompleteness theoremDefinition: Gödel’s first incompleteness theorem says that a consistent, effectively axiomatized system rich enough for arithmetic has undecidable statements.. If is consistent, effectively axiomatised and interprets enough arithmetic, then is incomplete. Cited, and not reproduced anywhere on this page.
- 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 substitutionDefinition: Substitution replaces specified symbols or expressions according to a stated rule. functionDefinition: A function assigns exactly one output to each allowed input. represented inside , and there is no here.
Proof
The numbering is injectiveDefinition: A function is injective when different inputs always produce different outputs. and invertible
Claim. The map from formulas of to natural numbersDefinition: Natural numbers are the counting numbers; conventions differ on whether zero is included. is injectiveDefinition: A function is injective when different inputs always produce different outputs., and there is an algorithm recovering from .
Cantor's pairing is a bijectionDefinition: A bijection is a correspondence in which every item on each side matches exactly one item on the other.. For put . Then , and since , the value lies in . Those intervals for are disjoint and cover the natural numbersDefinition: Natural numbers are the counting numbers; conventions differ on whether zero is included., so every determines uniquely, then , then . ∎
One nodeDefinition: A node is one object or state represented as a point in a graph. is recoverable. A node's code is with . Division by ten with remainderDefinition: The remainder is what is left after making as many complete groups of a chosen positive integer size as possible. gives and uniquely, so the symbol and its payload are both determined. ∎
InductionDefinition: Mathematical induction proves a claim for all successive integers by proving a starting case and a step from each case to the next. on height. A leaf is or a variableDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified.: its code determines which, and for a variable the payload is the index. For a nodeDefinition: A node is one object or state represented as a point in a graph. 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 nodeDefinition: A node is one object or state represented as a point in a graph., one integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. square
rootDefinition: A square root of a number is a value that gives that number when multiplied by itself. 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 proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. does not touch. It says nothing about provability, and the words "consistent", "axiomDefinition: An axiom is a starting statement accepted within a mathematical system, from which other statements can be proved." and "theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results." 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.
Limits and frontier
What the laboratory is and is not
What this laboratory implements. The numbering and the diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. construction, which are two ingredients of Gödel's proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions.. It does not implement provability. There is no proof predicate, no axiomDefinition: An axiom is a starting statement accepted within a mathematical system, from which other statements can be proved. set, no derivations and no search: is an uninterpreted symbol. It does not prove the theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results., 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 variablesDefinition: A variable is a symbol representing a quantity whose value can vary or has not yet been specified. goes through the encoder and back and returns unchanged, and every integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. 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 proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. in layer 5, not by the check.
Where the theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. 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 diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. 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 Diagonal LemmaDefinition: The diagonal lemma builds a sentence equivalent to a specified property of its own code, inside a formal system with enough arithmetic. 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 substitutionDefinition: Substitution replaces specified symbols or expressions according to a stated rule. 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.
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
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
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
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
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.
- 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.
- 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.
- 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.
- 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.
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.
Related by mechanism
Connected by how they work, not by sharing a topic label.