This page demonstrates a classic Gödel numbering: each symbol in a logical formula is mapped to an integer
code, shifted by +1 to ensure positivity, and used as the exponent of successive primes
2, 3, 5, 7, …. The product is the Gödel number ⟦ϕ⟧. Thanks to unique prime
factorization, we can recover the exact formula from the number by reading those exponents back.
Reserved logic symbols have small codes; any other character uses a generic rule so everything remains encodable.
| Symbol | Code c(·) |
|---|
For any character χ not listed at left, use:
c(χ) = 1000 + codePoint(χ)
This guarantees a total, injective code over all Unicode symbols we might type.
E(χ) = c(χ) + 1
Adding 1 ensures exponents are ≥ 1 (we never use zero exponents).
Let p₁, p₂, … be the increasing sequence of primes.
Tokenize ϕ into σ₁…σₙ (normalize ASCII: !→¬, &→∧, |→∨, ->→→, <->→↔; ignore spaces).
Define the Gödel number: ⟦σ₁…σₙ⟧ = ∏i=1..n pᵢ ^ E(σᵢ).
Decoding: factor the number; the exponents are E(σᵢ)=c(σᵢ)+1. Subtract 1 and invert c.
! → ¬, & → ∧, | → ∨, -> → →, <-> → ↔. Spaces are ignored.Let ϕ have token sequence σ₁…σₙ. Define ⟦ϕ⟧ := ∏i=1..n pᵢE(σᵢ), where E(σ)=c(σ)+1 and c(·) is injective. By the Fundamental Theorem of Arithmetic, every natural number has a unique prime factorization. Hence the exponent vector (E(σ₁), …, E(σₙ)) is uniquely determined by ⟦ϕ⟧. Subtracting 1 yields (c(σ₁), …, c(σₙ)), and because c is injective we recover the exact σ₁…σₙ. Therefore ϕ ↦ ⟦ϕ⟧ is injective and decoding is well-defined.
Compositionality. If τ is appended to ϕ, then ⟦ϕ·τ⟧ = ⟦ϕ⟧ · pn+1E(τ). This follows from multiplying by the next prime raised to the new symbol’s exponent.
After you click Compute ⟦ϕ⟧, the table below lists, for each position i, the i-th prime pᵢ, the corresponding exponent eᵢ, the recovered symbol, and its base code c(·) = eᵢ−1. Reading the symbols in order reconstructs the formula. If you change one symbol, only one exponent changes, so the product changes in exactly one prime component.
| # | Prime pᵢ | Exponent eᵢ | Recovered symbol | c(·) |
|---|