GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - typhdotcom/incomplete: Gödel-Kleene, Rosser, and Chaitin incompleteness, second incompleteness theorem, Löb's theorem, and Solovay's theorem (GL is the provability logic), for Lean's type theory. Proved in Lean 4 over lean4lean's formal typing judgment. LLM-assisted, unaudited by experts.

BranchesTags
Open more actions menu

Latest commit

 

History

113 Commits
113 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude
.claude
 
 
Incomplete
Incomplete
 
 
nix
nix
 
 
.copier-answers.yml
.copier-answers.yml
 
 
.envrc
.envrc
 
 
.gitignore
.gitignore
 
 
Incomplete.lean
Incomplete.lean
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
flake.lock
flake.lock
 
 
flake.nix
flake.nix
 
 
lake-manifest.json
lake-manifest.json
 
 
lakefile.toml
lakefile.toml
 
 
lean-toolchain
lean-toolchain
 
 
tasks.nu
tasks.nu
 
 

Repository files navigation

incomplete

Lean 4 proofs of classical incompleteness and provability-logic theorems for Lean 4's formal type theory, specified by the declarative typing judgment of lean4lean (extended with concrete inductive declarations and primitive projections in typhdotcom/lean4lean):

  • Gödel–Kleene, Rosser, and Gödel's second incompleteness theorems, plus a consistent ω-inconsistent context;
  • Löb's theorem, the Hilbert–Bernays–Löb derivability conditions, and Solovay's arithmetical completeness theorem for the provability logic GL (alongside finite Kripke completeness, the de Jongh–Sambin fixed point theorem, and a decision procedure and truth theorem for letterless sentences);
  • Chaitin's incompleteness theorem on program-size complexity, with a universal machine and invariance theorem.

Note

Provability is defined directly against VEnv.HasType / VEnv.IsDefEq in Lean4Lean.Theory.Typing. These results concern that formal specification of Lean's type theory, not Lean's C++ kernel or lean4lean's executable kernel replica.

Scope

The library works in two regimes at once, keeping full and bounded provability strictly distinct:

  1. Full theory (well-formed extensions of Nat): theorems apply to any well-formed environment (env.WF) extending natEnv — arbitrary axioms, definitions, mutual blocks, opaques, quotients, inductive families, and structures with primitive projections. Neither consistency nor halting soundness is proved here for full Provable env; they appear as explicit hypotheses where needed, and second_incompleteness shows that no consistent well-formed extension of natEnv proves its own internal consistency sentence Con T.
  2. Unconditional fragment (zero hypotheses): restricting derivations to sorts Prop and Type (u ≤ 1) without primitive projections (BProvable) keeps all of arithmetic, proof checking, Solovay's walk, and Chaitin's machine intact while admitting a ZF set model (ModelSound.lean). That model proves consistency and Σ₁-soundness outright for both natEnv and clEnv (natEnv plus double-negation elimination dneS).

The matrix below lists only consistency, halting-soundness, and classical-axiom hypotheses (None means none of those three). All full-judgment rows also take env.WF and natEnv ≤ env (or env.WF' ds with .induct natDecl ∈ ds); statements mentioning Con T, Prov T, or A.real T σ take TablesFor env T (except prov_mp_provable, which holds for any T : Tables, and second_incompleteness and omega_inconsistent_exists, which construct T from hwf.checkable.tables); and statements quantified over object propositions or modal realizations take closed-proposition typing (env.HasType 0 [] · (.sort .zero) in VEnv, BDefEq clEnv [] · · (.sort .zero) in clEnv) and A.Letterless where stated.

Result Full VEnv extra hypotheses {Prop, Type} fragment (BProvable) Entry points
1st incompleteness (Gödel–Kleene) Consistent (+ HaltsSound for irrefutability) Unconditional (natEnv) incomplete_of_wf, incomplete_unconditional
Rosser's theorem (unprovable & irrefutable) Consistent — (bhaltsSound covers natEnv above) incomplete_rosser, rosser_of_pred, rosser_under
2nd incompleteness Consistent Unconditional (clEnv at n = 0: ¬BProvable clEnv (BProv ⊥ → ⊥)) second_incompleteness, con_unprovable, bcon_iterated
Consistent, ω-inconsistent context ([Prov T ⊥]) Consistent — (full-judgment result) omega_inconsistent
Löb, D1–D3, FairBot, iGL soundness None Unconditional for Löb, D1–D3, iGL (IsChecker.bounded) loeb, loeb_formalized, iGL_sound, fairbot
GL arithmetical soundness Provable env dneS Unconditional (clEnv) GL_sound, GL_bsound
Solovay completeness of GL & letterless truth HaltsSound + Provable env dneS Unconditional (clEnv, □ as BProv) GL_iff_provable, tr_iff_lim, GL_iff_bprovable, btr_iff_lim
Fixed points (de Jongh–Sambin) Provable env dneS — Modal.isFixedPoint_fixedPoint, Modal.IsFixedPoint.unique, fixedPoint_arith_exists, fixedPoint_arith, godel_iff_con, Modal.IsSolution.solve, solution_arith
Iterated consistency (□ⁿ⊥, □ⁿ⁺¹⊥ → □ⁿ⊥) HaltsSound (Consistent at n = 0) Unconditional (clEnv) boxBot_succ_imp_unprovable, bcon_iterated
Chaitin's incompleteness theorem Consistent (+ HaltsSound for irrefutability) Unconditional (clEnv, full independence) univM_optimal, K_le_of_outputs, chaitin, chaitin_independent, chaitin_unconditional

Theorems

All declarations displayed in the code blocks below live in Incomplete (including its Incomplete.Modal subnamespace, with Incomplete.Obj opened for Thm, neg, prfT, numT, =ₒ, and ↔ₒ); the dot-notation helper Lean4Lean.VEnv.WF.checkable is defined in Lean4Lean. First, the core vocabulary appearing in the statements (PR.lean, Sentences.lean, Main.lean, Bounded.lean):

-- Primitive recursive codes equipped with one outer unbounded search
def PR.Halts (f : PR) (n : Nat) : Prop := ∃ k, f.eval (val2 k n) = 0
def PR.code  (f : PR) : Nat := encExpr (fn f)

-- Impredicative False, Π₁ non-halting, and negated non-halting (not identified with ∃ in intuitionistic Prop)
def falseS : VExpr := .forallE (.sort .zero) (.bvar 0)
def notHalts (f : PR) (n : Nat) : VExpr :=
  .forallE nat (.forallE (isZero (.app (.app (fn f) (lit n)) (.bvar 0))) falseS)
def halts (f : PR) (n : Nat) : VExpr := .forallE (notHalts f n) falseS

-- Closed proofs in full typing vs. the {Prop, Type} projection-free judgment BDefEq
def Provable  (env : VEnv) (P : VExpr) : Prop := ∃ e, env.HasType 0 [] e P
def BProvable (env : VEnv) (P : VExpr) : Prop := ∃ e, BDefEq env [] e e P

def Consistent (env : VEnv) : Prop := ¬Provable env falseS
def HaltsSound (env : VEnv) : Prop := ∀ f n, Provable env (halts f n) → PR.Halts f n

1. Unconditional fragment and classical provability logic

With consistency and halting soundness discharged by the set model (ModelSound.lean, Unconditional.lean, ClEnv.lean, BProvLogic.lean):

theorem incomplete_unconditional :
    ∃ d : PR, ¬d.Halts d.code ∧ ¬BProvable natEnv (notHalts d d.code) ∧
      ¬BProvable natEnv (halts d d.code)

theorem bconsistent : ¬BProvable natEnv falseS

theorem bhaltsSound {f : PR} {n : Nat} (hp : BProvable natEnv (halts f n)) : f.Halts n

def clEnv : VEnv := withConst natEnv dneName ⟨0, dneS⟩
noncomputable def BProv (P : VExpr) : VExpr := ProvC (bchkT clT) P

theorem GL_iff_bprovable {A : Modal} :
    Modal.GL A ↔ ∀ σ : Nat → VExpr, (∀ n, BDefEq clEnv [] (σ n) (σ n) (.sort .zero)) →
      BProvable clEnv (A.breal σ)

theorem bprovable_iff_lvl {A : Modal} (hA : A.Letterless) (σ : Nat → VExpr) :
    BProvable clEnv (A.breal σ) ↔ ∀ n, Modal.lvl n A = true

theorem btr_iff_lim : ∀ {A : Modal}, A.Letterless → (A.btr ↔ Modal.lim A = true)

theorem bcon_iterated (σ : Nat → VExpr) (n : Nat) :
    ¬BProvable clEnv ((Modal.boxBot n).breal σ) ∧
      (Modal.imp (Modal.boxBot (n + 1)) (Modal.boxBot n)).btr ∧
      ¬BProvable clEnv ((Modal.imp (Modal.boxBot (n + 1)) (Modal.boxBot n)).breal σ)

theorem chaitin_unconditional :
    ∃ c, ∀ L, c ≤ L →
      (∀ n, ¬BProvable clEnv (Complex L n)) ∧
      ∀ n, L < K n → ¬BProvable clEnv (halts cplxM (PR.pair L n))

BProv P internalizes bounded provability via the fragment's own certificate checker, and A.breal σ realizes □ as BProv. On variable-free modal formulas, provability holds iff the formula holds at every natural level n : Nat of the ω-tower (bprovable_iff_lvl); because Modal.lvl n A stabilizes at Modal.lim A from box depth Modal.bd onward (Modal.lvl_eq_lim), Modal.dec decides provability by checking only the finite prefix n ≤ bd A (bprovable_iff_dec). Truth (Modal.btr) coincides with Modal.lim A (btr_iff_lim), and every iterated consistency statement □ⁿ⁺¹⊥ → □ⁿ⊥ is true and unprovable (bcon_iterated, with n = 0 giving ¬BProv ⊥).

2. Full-theory incompleteness, Rosser, and ω-inconsistency

Every well-formed environment admits finite lookup tables (TablesFor) for its constants, definitional-equality rules, and inductive blocks (Lean4Lean.VEnv.WF.checkable). From T : Tables, Con states that no certificate checks as a proof of ⊥, and Prov states ∃ k, chkT T (⌜P⌝, k) = 0 using an impredicative ∃ (Extend.lean, Rosser.lean, Obj/Second.lean, Obj/Omega.lean):

theorem incomplete_rosser (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) (hC : Consistent env) :
    ∃ d : PR, env.HasType 0 [] (notHalts d d.code) (.sort .zero) ∧ ¬d.Halts d.code ∧
      ¬Provable env (notHalts d d.code) ∧ ¬Provable env (halts d d.code)

theorem incomplete_of_wf (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) (hC : Consistent env) :
    ∃ d : PR, ¬d.Halts d.code ∧ ¬Provable env (notHalts d d.code) ∧
      (HaltsSound env → ¬Provable env (halts d d.code))

theorem second_incompleteness (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env)
    (hC : Consistent env) :
    ∃ T, TablesFor env T ∧ env.HasType 0 [] (Con T) (.sort .zero) ∧
      (¬(conM T).Halts 0 ↔ Consistent env) ∧ ¬Provable env (Con T)

theorem con_unprovable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env)
    {T : Tables} (hT : TablesFor env T) (hC : Consistent env) : ¬Provable env (Con T)

theorem omega_inconsistent (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hC : Consistent env) :
    ¬Thm env [Prov T falseS] falseS ∧
    Thm env [Prov T falseS] (Prov T falseS) ∧
    ∀ k : Nat, Thm env [Prov T falseS] (neg (prfT T (numT (encExpr falseS)) (lit k) =ₒ zero))

The second theorem rests on proving Con T → G0 T inside the object theory (con_imp_G0_provable). In omega_inconsistent, [Prov T ⊥] is a hypothesis context over env itself (consistent by Löb at P := ⊥), proving that some certificate checks as a proof of ⊥ while refuting each numeral k (omega_inconsistent_exists existentially supplies T from env.WF). Declaration-list variants (incomplete_rosser', incomplete_of_wf', second_incompleteness') replace (hwf : env.WF) (hext : natEnv ≤ env) with (H : env.WF' ds) (hm : .induct natDecl ∈ ds).

Rosser's argument uses provability only through three facts, so it holds for any predicate that has them (rosser_of_pred): it holds of every theorem, its certificates are checked by a code, and it never holds of both halts f n and notHalts f n. At the predicate "A → Q is provable" this is Rosser's theorem under a hypothesis (rosser_under): a closed proposition A consistent with the theory leaves some notHalts d ⌜d⌝ undecided, neither it nor its negation following from A.

The Rosser machine also races any two sentences (race), by the explicit machines raceC (race_spec): for P and Q there are machines a and b, ignoring their inputs, with a halting when a proof of P comes before every proof of Q and b the reverse. So a halts only if P is provable and does if P is and Q is not, and when either halts the theory proves that the other never does.

3. Löb's theorem, derivability conditions, and Solovay completeness

Because the object logic is intuitionistic, Löb's theorem, the Hilbert–Bernays–Löb conditions D1–D3 (prov_of_provable, prov_mp_provable, prov_prov_provable), formalized Löb, and intuitionistic iGL soundness require neither consistency nor dneS. Classical GL soundness adds Provable env dneS, and Solovay's arithmetical completeness adds HaltsSound env (Obj/Loeb.lean, Obj/Derivability.lean, Obj/GL.lean, Obj/Solovay.lean):

theorem loeb (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) {P : VExpr} (hP : env.HasType 0 [] P (.sort .zero))
    (h : Provable env (.forallE (Prov T P) P)) : Provable env P

theorem prov_mp_provable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    {P Q : VExpr} (hQ : env.HasType 0 [] Q (.sort .zero)) :
    Provable env (.forallE (Prov T (.forallE P Q)) (.forallE (Prov T P) (Prov T Q)))

theorem prov_prov_provable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (P : VExpr) :
    Provable env (.forallE (Prov T P) (Prov T (Prov T P)))

theorem loeb_formalized (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) {P : VExpr} (hP : env.HasType 0 [] P (.sort .zero)) :
    Provable env (.forallE (Prov T (.forallE (Prov T P) P)) (Prov T P))

theorem GL_iff_provable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hdne : Provable env dneS) (hS : HaltsSound env) {A : Modal} :
    Modal.GL A ↔ ∀ σ : Nat → VExpr, (∀ n, env.HasType 0 [] (σ n) (.sort .zero)) →
      Provable env (A.real T σ)
Companion modal, Kripke, FairBot, and letterless signatures (Modal/, Obj/GL.lean, Obj/Letterless.lean)
-- Arithmetical soundness of GL and iGL, mutual Löb ("FairBot"), and Solovay counter-realization
theorem GL_sound (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hdne : Provable env dneS) {σ : Nat → VExpr}
    (hσ : ∀ n, env.HasType 0 [] (σ n) (.sort .zero)) {A : Modal} (h : Modal.GL A) :
    Provable env (A.real T σ)

theorem iGL_sound (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) {σ : Nat → VExpr} (hσ : ∀ n, env.HasType 0 [] (σ n) (.sort .zero))
    {A : Modal} (h : Modal.iGL A) : Provable env (A.real T σ)

theorem fairbot (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) {A B : VExpr} (hA : env.HasType 0 [] A (.sort .zero))
    (hB : env.HasType 0 [] B (.sort .zero)) (hAB : Provable env (A ↔ₒ Prov T B))
    (hBA : Provable env (B ↔ₒ Prov T A)) : Provable env A ∧ Provable env B

theorem GL_arith_complete (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hdne : Provable env dneS) (hS : HaltsSound env) {A : Modal}
    (h : ¬Modal.GL A) :
    ∃ σ : Nat → VExpr, (∀ n, env.HasType 0 [] (σ n) (.sort .zero)) ∧
      ¬Provable env (A.real T σ)

-- Standalone Kripke completeness of GL on finite transitive irreflexive frames
structure Modal.FinModel (n : Nat) where
  R : Fin n → Fin n → Bool
  V : Fin n → Nat → Bool
  trans : ∀ {a b c}, R a b = true → R b c = true → R a c = true
  irrefl : ∀ a, R a a = false

theorem Modal.FinModel.GL_sound {n : Nat} (M : FinModel n) {A : Modal} (h : GL A) (w : Fin n) :
    M.Forces w A

theorem Modal.GL_complete {A : Modal} (h : ¬GL A) :
    ∃ (n : Nat) (M : FinModel (n + 1)), M.Rooted ∧ (∀ i k, M.V i k = true → var k ∈ sub A) ∧
      ¬M.Forces 0 A

theorem Modal.GL_iff {A : Modal} :
    GL A ↔ ∀ (n : Nat) (M : FinModel n) (w : Fin n), M.Forces w A

-- Letterless ω-level tower, finite-prefix Boolean decider (n ≤ bd A), limit truth, and □ⁿ⊥
def Modal.lvl (n : Nat) : Modal → Bool
  | var _ => false
  | bot => false
  | imp A B => !lvl n A || lvl n B
  | box A => decide (∀ m, m < n → lvl m A = true)

theorem Modal.FinModel.forces_iff_lvl {n : Nat} (M : FinModel n) {A : Modal}
    (hA : Letterless A) (w : Fin n) : M.Forces w A ↔ lvl (M.height w) A = true

theorem Modal.GL_iff_lvl {A : Modal} (hA : Letterless A) : GL A ↔ ∀ n, lvl n A = true

theorem Modal.GL_iff_dec {A : Modal} (hA : Letterless A) : GL A ↔ dec A = true

theorem provable_iff_lvl (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hdne : Provable env dneS) (hS : HaltsSound env) {A : Modal}
    (hA : A.Letterless) (σ : Nat → VExpr) :
    Provable env (A.real T σ) ↔ ∀ n, Modal.lvl n A = true

theorem tr_iff_lim (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hdne : Provable env dneS) (hS : HaltsSound env) :
    ∀ {A : Modal}, A.Letterless → (A.tr env T ↔ Modal.lim A = true)

theorem boxBot_unprovable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hS : HaltsSound env) (σ : Nat → VExpr) :
    ∀ n, ¬Provable env ((Modal.boxBot n).real T σ)

theorem boxBot_succ_imp_unprovable (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env)
    {T : Tables} (hT : TablesFor env T) (hS : HaltsSound env) (σ : Nat → VExpr) (n : Nat) :
    ¬Provable env ((Modal.imp (Modal.boxBot (n + 1)) (Modal.boxBot n)).real T σ)

provable_iff_dec equates Provable env (A.real T σ) with the finite-prefix check Modal.dec A = true (n ≤ bd A). On letterless formulas GL is strictly stronger than iGL: Modal.not_iGL_dne_box proves GL (¬¬□⊥ → □⊥) and ¬iGL (¬¬□⊥ → □⊥) via a three-element Heyting modal algebra.

A variable p is modalized in A when it occurs only under □. Then Modal.fixedPoint builds a formula H without p with GL ⊢ H ↔ A[H/p] (Modal.isFixedPoint_fixedPoint), and any such H is the only solution: GL ⊢ □(C ↔ A[C/p]) → (C ↔ A[C/p]) → (C ↔ H) (Modal.IsFixedPoint.unique, Modal.GL_solution_unique). Both are proved in Kripke models, where a solution is determined by recursion along the relation (Modal.Kripke.setV_unique). Arithmetically, the realization S of H has S ↔ A[S/p] provable (fixedPoint_arith_exists), and conversely a closed proposition S with S ↔ A[S/p] provable has S ↔ H provable (fixedPoint_arith), so every sentence provably equivalent to its own unprovability is provably equivalent to ¬Prov ⊥ (godel_iff_con). A system of equations n ↔ sys n over variables ps, each modalized in every equation, is solved one variable at a time (Modal.solve, Modal.IsSolution.solve); the solution is unique (Modal.IsSolution.unique_var), its realizations solve the system in the theory (solution_arith_exists), and closed propositions that provably solve it are provably equivalent to them (solution_arith).

The Solovay sentences behind arithmetical completeness are available for any finite model (solovay_atlas): for a finite transitive irreflexive model M there are closed propositions S 0, …, S (n + 1), one per world and one for a root below them, and a realization σ, such that the theory refutes any two of them together and proves whatever all of them imply; S (w + 1) implies the realization of B when w forces B and its negation otherwise; S a implies that ¬S b is unprovable when a sees b; and, in a halts-sound theory, none is refuted.

4. Chaitin's incompleteness theorem

Binary programs List Bool correspond constructively and bijectively to Nat via bits and ofBits (ofBits_bits, bits_ofBits), with (bits p).length = bitLen p := Nat.log2 (p + 1) (bits_length). A program p packs a machine index e and input x bijectively as prog e x := 2 ^ e * (2 * x + 1) - 1—a unary prefix of e false bits followed by the delimited input bits (bits_prog)—and describes n when its decoded machine f (encPR f = e) outputs n on x via its least halting witness; K n is the shortest binary program length describing n. Inside PR, a universal machine univM backed by a primitive recursive trace verifier realizes Describes exactly (TracePR.lean, UnivPR.lean, Chaitin.lean):

def PR.Outputs (f : PR) (x n : Nat) : Prop :=
  ∃ k, f.eval (val2 k x) = 0 ∧ (∀ j < k, f.eval (val2 j x) ≠ 0) ∧ unpair1 k = n

def prog (e x : Nat) : Nat := 2 ^ e * (2 * x + 1) - 1
def bitLen (p : Nat) : Nat := Nat.log2 (p + 1)
theorem bits_length (p : Nat) : (bits p).length = bitLen p

def Describes (p n : Nat) : Prop := ∃ f x, prog (encPR f) x = p ∧ f.Outputs x n
def IsComplex (L n : Nat) : Prop := ∀ p, bitLen p ≤ L → ¬Describes p n
noncomputable def K (n : Nat) : Nat

theorem isComplex_iff_lt_K (L n : Nat) : IsComplex L n ↔ L < K n
theorem univM_outputs_iff (p n : Nat) : univM.Outputs p n ↔ Describes p n
theorem univM_optimal (f : PR) :
    ∃ c, ∀ x n, f.Outputs x n → ∃ p, bitLen p ≤ bitLen x + c ∧ univM.Outputs p n
theorem K_le_of_outputs (f : PR) : ∃ c, ∀ x n, f.Outputs x n → K n ≤ bitLen x + c
theorem K_le_bitLen : ∃ c, ∀ n, K n ≤ bitLen n + c

def Complex (L n : Nat) : VExpr := notHalts cplxM (PR.pair L n)

theorem complex_refute (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {L n : Nat}
    (h : K n ≤ L) : Provable env (halts cplxM (PR.pair L n))

theorem complex_sound (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) (hC : Consistent env)
    {L n : Nat} (h : Provable env (Complex L n)) : L < K n

theorem complex_irrefutable (env : VEnv) (hS : HaltsSound env) {L n : Nat} (h : L < K n) :
    ¬Provable env (halts cplxM (PR.pair L n))

theorem chaitin (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hC : Consistent env) :
    ∃ c, ∀ L, c ≤ L → ∀ n, ¬Provable env (Complex L n)

theorem chaitin_independent (env : VEnv) (hwf : env.WF) (hext : natEnv ≤ env) {T : Tables}
    (hT : TablesFor env T) (hS : HaltsSound env) :
    ∃ c, ∀ L, c ≤ L → ∀ n, L < K n →
      ¬Provable env (Complex L n) ∧ ¬Provable env (halts cplxM (PR.pair L n))

univM_optimal and K_le_of_outputs establish additive invariance up to a constant bit-length overhead over the class of least-zero PR machines, with the linear bound K n ≤ bitLen n + c (K_le_bitLen). Because prog and encPR are injective and PR evaluation is deterministic, each program describes at most one number (describes_unique), leaving fewer than 2 ^ (L + 1) numbers with K n ≤ L (K_le_length_lt) and making L < K n cofinitely true for every L (K_eventually).

Complex L n is a computable closed Π₁ sentence expressing K(n) > L (complex_true_iff), whose negation Complex L n → ⊥ is definitionally halts cplxM (PR.pair L n), backed by the bridge theorem uChk_spec. Typing (complex_ty, bcomplex_ty), counting, cofinite truth, and adequacy (complex_refute, complex_sound, complex_irrefutable, and the bounded counterparts bcomplex_refute, bcomplex_sound, bcomplex_irrefutable) all hold for every L and n. Above the threshold c, K(n) > L is unprovable for every L ≥ c and every n (chaitin), and under HaltsSound—or unconditionally in chaitin_unconditional in Section 1—exact independence holds even intuitionistically for every L ≥ c and every n with K(n) > L (chaitin_independent).

References and related work. The theorem is due to G. J. Chaitin ("Information-theoretic limitations of formal systems", Journal of the ACM 21(3):403–424, 1974). Universality of univM over all partial computable functions rests on Kleene's normal form theorem (identifying partial computable functions with least-zero PR searches), which is not proved here. In Lean 4, A. Milovanov's kolmogorov-complexity-lean formalizes Kolmogorov complexity on Mathlib over all Partrec decompressors, with Chaitin and Kritchman–Raz incompleteness stated over abstract formal-system interfaces; the development here instead fixes one concrete formal theory (VEnv / clEnv), an explicit Π₁ complexity sentence, consistency as the only hypothesis for unprovability, and a fixed PR-search machine class.

Design

Four architectural choices keep the development compact despite targeting a dependent type theory rather than first-order arithmetic:

  • Nat is the only inductive type required. Propositional connectives, quantifiers, and Leibniz equality are impredicatively encoded in Prop, and 0 ≠ succ n uses large elimination of Nat into Prop. Base arithmetic (natEnv_wf) is therefore a single inductive declaration added to the empty environment.
  • Kleene normal form separates recursion from search. Machines are total primitive recursive terms (PR) paired with one outer ∃ k search. Every partial recursive function has this shape, while the object theory only ever evaluates total primitive recursive functions on numerals by β- and ι-conversion (PR.adequate).
  • Gödel numbering is a bijection. Names, universe levels, expressions, judgments, and 16-rule derivation trees (Cert) map bijectively to Nat (decCert_enc, encCert_dec). Every natural number is a valid syntactic object, so neither external nor internal proof checkers need well-formedness guards against junk codes.
  • One internal development serves both regimes. Object-level proof theory in Incomplete/Obj/ (equipped with a custom natural-deduction tactic mode for nameless de Bruijn terms) is parameterized over an abstract typing interface (ObjEnv) and checker interface (IsChecker), instantiated once for full VEnv typing and once for BDefEq to prove internal Σ₁-completeness (ok_exists) and everything downstream.

Layout

Every module in Incomplete/ opens with a docstring summarizing its definitions and proof idea.

  • External arithmetic, proof checking, and 1st incompleteness: PR.lean, Adequacy.lean, Sentences.lean, Decide.lean, Cert.lean, Encode.lean, CheckPR.lean, Kleene.lean, Main.lean, Final.lean, Rosser.lean.
  • Well-formed environments and extensions: NatEnv.lean, NatDeclWF.lean, Extend.lean, plus concrete extensions with Eq and And (EqEnv.lean, AndEnv.lean).
  • Bounded fragment and ZF set model: Bounded.lean, ZF.lean, ZFUniv.lean, Model.lean, ModelSound.lean, ClEnv.lean, Unconditional.lean, BProvLogic.lean.
  • Standalone modal logic: Incomplete/Modal/ — Hilbert systems GL and iGL (Basic.lean), Kripke frames (Kripke.lean), finite rooted completeness (Complete.lean), the letterless height tower (Letterless.lean), and fixed points of modalized formulas (FixedPoint.lean).
  • Internalized proof theory: Incomplete/Obj/ — typing and tactics (Typing.lean, Core.lean, Tactic.lean), symbolic arithmetic and certificate checking (Checker.lean, BChecker.lean), internal Σ₁-completeness (Sigma.lean), second theorem (Second.lean), Löb and D1–D3 (Loeb.lean, Omega.lean, Derivability.lean, GL.lean), and Solovay's walk (Solovay.lean, Letterless.lean).
  • Universal machine and Chaitin's incompleteness: TracePR.lean, UnivPR.lean, Chaitin.lean.

Dependency

lakefile.toml pins typhdotcom/lean4lean (a fork of digama0/lean4lean) at 19acdf081dc3. Core typing and definitional equality come from upstream; this repository uses three theory-level additions from the fork:

  • Concrete inductive declarations (Theory/VEnv.lean, Theory/Inductive.lean, Theory/Typing/Env.lean): VInductDecl.WF, recursor and iota-rule generation, VEnv.addInduct, and the GeneratedWF obligation that generated recursors and iota rules are well typed (discharged for Nat in NatDeclWF.lean).
  • Primitive projections and structure η (Theory/Typing/Basic.lean): VExpr.proj, VEnv.inducts, and the IsDefEq rules projDF, projIota, and projEta with their ProjAllowed side conditions (included in the full-theory checker in Cert.lean and ProjRules.lean, and omitted from BDefEq).
  • Environment and telescope lemmas (Theory/Typing/{EnvLemmas,Projection,Telescope}.lean): VEnv.WF.ordered, VDecl.WF.le, IsDefEq.appN_substT, and IsDefEq.lams_beta.

The proofs do not depend on the fork's kernel verification, runtime-model axioms, or open injectivity assumptions; direct imports are limited to Lean4Lean.Theory.Typing.{Basic,Env,EnvLemmas,Meta,Projection,Telescope}. The toolchain is Lean v4.34.1 (lean-toolchain) with batteries v4.34.0; lean4lean itself pins v4.33.0-rc2 for its kernel replica and regression tests.

Build and audit

nix develop -c lake build
nu tasks.nu fmt
nu tasks.nu check

Every theorem depends only on propext, Classical.choice, and Quot.sound. The certificate checker Cert.check and its soundness and completeness depend on no Classical.choice; incomplete_of_wf and incomplete_rosser reach it only through lean4lean's keptFieldsBy and keptLiftBy and through core's Char and String lemmas under the numbering of names. The codebase contains no sorry, native_decide, or custom axiom.

Markdown links to Lean declarations are managed automatically (nix/lean-anchors.py): write single-line [`symbol`](Incomplete/File.lean) or [label](Incomplete/File.lean "lean:symbol") (titles without the lean: prefix remain ordinary tooltips on file links). After editing Lean or Markdown sources, run nu tasks.nu fmt (nix fmt) to refresh #L signature spans and table alignment, then nu tasks.nu check (nix flake check) to verify formatting, symbol spans (checks.lean-anchors), and relative file and heading links (checks.links). Any other rendered .lean#... line link (unmanaged, reference-style, multiline, HTML, or with a query) is rejected; escaped and code-span examples are left as written.

Full #print axioms audit script (run with nix develop -c lake env lean --trust=0 <file>)
import Incomplete
open Incomplete
#print axioms incomplete_unconditional
#print axioms incomplete_rosser
#print axioms rosser_of_pred
#print axioms rosser_under
#print axioms race
#print axioms solovay_atlas
#print axioms incomplete_rosser'
#print axioms incomplete_of_wf
#print axioms incomplete_of_wf'
#print axioms second_incompleteness
#print axioms second_incompleteness'
#print axioms con_unprovable
#print axioms loeb
#print axioms loeb_halts
#print axioms con_unprovable_of_loeb
#print axioms omega_inconsistent
#print axioms omega_inconsistent_exists
#print axioms prov_mp_provable
#print axioms prov_prov_provable
#print axioms loeb_formalized
#print axioms GL_sound
#print axioms iGL_sound
#print axioms fairbot
#print axioms Modal.Kripke.GL_sound
#print axioms Modal.FinModel.GL_sound
#print axioms Modal.GL_complete
#print axioms Modal.GL_iff
#print axioms GL_arith_complete
#print axioms GL_iff_provable
#print axioms Modal.FinModel.forces_iff_lvl
#print axioms Modal.GL_iff_lvl
#print axioms Modal.GL_iff_dec
#print axioms Modal.not_iGL_dne_box
#print axioms Modal.isFixedPoint_fixedPoint
#print axioms Modal.IsFixedPoint.unique
#print axioms Modal.GL_solution_unique
#print axioms fixedPoint_arith_exists
#print axioms fixedPoint_arith
#print axioms godel_iff_con
#print axioms Modal.IsSolution.solve
#print axioms Modal.IsSolution.unique_var
#print axioms solution_arith_exists
#print axioms solution_arith
#print axioms provable_iff_lvl
#print axioms provable_iff_dec
#print axioms tr_iff_lim
#print axioms boxBot_unprovable
#print axioms boxBot_succ_imp_unprovable
#print axioms tr_boxBot_succ_imp
#print axioms con_unprovable_letterless
#print axioms bconsistent
#print axioms bhaltsSound
#print axioms clEnv_wf
#print axioms clEnv_bconsistent
#print axioms clEnv_bhaltsSound
#print axioms GL_iff_bprovable
#print axioms bprovable_iff_lvl
#print axioms bprovable_iff_dec
#print axioms btr_iff_lim
#print axioms bcon_iterated
#print axioms ofBits_bits
#print axioms bits_ofBits
#print axioms bits_length
#print axioms bitLen_ofBits
#print axioms bits_prog
#print axioms describes_unique
#print axioms K_spec
#print axioms isComplex_iff_lt_K
#print axioms K_le_of_outputs
#print axioms K_le_bitLen
#print axioms K_le_length_lt
#print axioms K_eventually
#print axioms not_complex_length_lt
#print axioms isComplex_eventually
#print axioms uChk_spec
#print axioms univM_outputs_iff
#print axioms univM_optimal
#print axioms complex_refute
#print axioms complex_sound
#print axioms complex_irrefutable
#print axioms bcomplex_refute
#print axioms bcomplex_sound
#print axioms bcomplex_irrefutable
#print axioms chaitin
#print axioms chaitin_independent
#print axioms chaitin_unconditional

License

Apache 2.0 (LICENSE), matching lean4lean.

About

Gödel-Kleene, Rosser, and Chaitin incompleteness, second incompleteness theorem, Löb's theorem, and Solovay's theorem (GL is the provability logic), for Lean's type theory. Proved in Lean 4 over lean4lean's formal typing judgment. LLM-assisted, unaudited by experts.

Topics

computability-theoryformal-verificationgodel-incompletenessincompletenesskleene-recursion-theoremlean4lean4leanmathematical-logicmetamathematicsmodal-logicproof-assistantprovability-logictheorem-provingtype-theory

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.