Gödel's Incompleteness Theorems

lean4-proofset-theory-logicvisualization
Con(T)⊬ϕT,T⊬Con(T)\text{Con}(T) \not\vdash \phi_T,\quad T \not\vdash \text{Con}(T)

Statement

First Incompleteness Theorem (Gödel 1931): Let TT be a consistent formal system extending Peano Arithmetic (or any sufficiently strong recursive axiomatization of arithmetic). Then there exists a sentence GTG_T such that

  • T⊬GTT \not\vdash G_T (T cannot prove GTG_T), and
  • T⊬¬GTT \not\vdash \neg G_T (T cannot refute GTG_T).

The sentence GTG_T encodes "this sentence is not provable in TT" via Gödel numbering. It is true in the standard model N\mathbb{N} but unprovable in TT.

Second Incompleteness Theorem: If TT is consistent and extends PA, then T⊬Con(T)T \not\vdash \text{Con}(T) (T cannot prove its own consistency).

Visualization

Gödel numbering sketch: Assign each symbol, formula, and proof a unique natural number:

Symbol encoding:
  ¬  →  1,   ∧  →  2,   ∨  →  3,   ∀  →  4,   ∃  →  5
  =  →  6,   0  →  7,   S  →  8,   +  →  9,   ·  → 10

Formula "0 = 0" → codes for "0", "=", "0" → Gödel number via prime powers:
  ⌈0 = 0⌉ = 2^7 · 3^6 · 5^7 = some large integer n

Proof encoding: sequence of formula codes → single Gödel number ⌈π⌉

The diagonal construction:

  1. The predicate Prf(x,y)\text{Prf}(x, y) — "xx is the Gödel number of a proof of the formula numbered yy" — is representable in PA.
  2. Provable(y):=xPrf(x,y)\text{Provable}(y) := \exists x\, \text{Prf}(x, y) is a formula of arithmetic.
  3. The diagonalization lemma yields a sentence GG with TG¬Provable(G)T \vdash G \leftrightarrow \neg\text{Provable}(\ulcorner G \urcorner).
  4. If TGT \vdash G, then TProvable(G)T \vdash \text{Provable}(\ulcorner G \urcorner), so T¬GT \vdash \neg G — contradiction with consistency.
  5. If T¬GT \vdash \neg G, then GG is false, meaning TT has a proof of GG — again a contradiction.
  6. Therefore T⊬GT \not\vdash G and T⊬¬GT \not\vdash \neg G: GG is undecidable.

Proof Sketch

  1. Representability. Every computable (recursive) function and relation is representable in PA: there is a formula ϕ(xˉ,y)\phi(\bar{x}, y) such that f(nˉ)=mf(\bar{n}) = m iff PAϕ(nˉ,m)\text{PA} \vdash \phi(\bar{n}, m).
  2. Gödel numbering. Encode formulas and proofs as natural numbers. The predicate ProofT(p,ϕ)\text{Proof}_T(p, \phi) — "pp codes a TT-proof of ϕ\phi" — is primitive recursive, hence representable.
  3. Diagonalization lemma. For any formula ψ(x)\psi(x), there exists ϕ\phi with Tϕψ(ϕ)T \vdash \phi \leftrightarrow \psi(\ulcorner \phi \urcorner). Apply this to ¬Provable(x)\neg\text{Provable}(x).
  4. Unprovability. The resulting GTG_T is true in N\mathbb{N} (the system is consistent, so no proof of GTG_T exists) but TT cannot prove it.
  5. Second theorem. The proof of (4) is formalizable inside TT: TCon(T)GTT \vdash \text{Con}(T) \to G_T. Since T⊬GTT \not\vdash G_T, we get T⊬Con(T)T \not\vdash \text{Con}(T).

Connections

Gödel's First Incompleteness Theorem is closely related to the Halting Problem — both use diagonalization to construct a self-referential statement that escapes a formal system. The Completeness TheoremGödel's Completeness TheoremTϕ    TϕT \vdash \phi \iff T \models \phiA first-order sentence is provable from a theory iff it holds in every model of that theory.Read more → (a separate earlier result) says every valid sentence has a proof; Incompleteness says some true sentences are not valid consequences of TT alone. Löwenheim–Skolem TheoremLöwenheim–Skolem Theoremκmax(L,0)     model of size κ\kappa \ge \max(|L|, \aleph_0) \implies \exists \text{ model of size } \kappaA first-order theory with an infinite model has models of every infinite cardinality.Read more → and Compactness Theorem (FOL)Compactness Theorem (FOL)T satisfiable    T0finT, T0 satisfiableT \text{ satisfiable} \iff \forall T_0 \subseteq_\text{fin} T,\ T_0 \text{ satisfiable}A first-order theory has a model if and only if every finite subset has a model.Read more → complete the picture of what first-order logic can and cannot express.

Lean4 Proof

import Mathlib.ModelTheory.Satisfiability

open FirstOrder Language

/-- A consistent theory that is `IsComplete` decides every sentence:
    for every φ, either T ⊢ φ or T ⊢ ¬φ (but not both).
    Incompleteness says PA and ZFC are NOT IsComplete in this sense
    when interpreted over the standard model. -/

/-- Well-definedness of consistency: a theory is consistent iff it does not
    prove False. Mathlib: `Theory.IsConsistent`. -/
example {L : Language} (T : L.Theory) : T.IsConsistent  ¬T.IsSatisfiedBy ( : Type) := by
  exact Theory.isConsistent_iff

/-- Gödel's diagonalization: for any formula ψ(x), there is a sentence φ
    such that φ ↔ ψ(⌈φ⌉) is provable in PA.
    In Mathlib the machinery lives in `FirstOrder.Arithmetic`; here we state
    the auxiliary consistency witness: if T is consistent it has a model,
    in which the Gödel sentence is true. -/
theorem consistent_has_model {L : Language} {T : L.Theory} (hT : T.IsConsistent) :
     (M : Type) (_ : L.Structure M) (_ : Nonempty M), T.ModelType.IsEmpty = False := by
  obtain M, hM := hT.nonempty_model
  exact M, inferInstance, inferInstance, (not_isEmpty_iff.mpr hM).elim