NV1. The statement is about every prover. Let a prover be anything that has codes of some kind \(\mathrm {Code}\) (sentences, proofs, programs) and a way of running or reading them, \(\mathrm {eval}:\mathrm {Code}\times \mathrm {Code}\to 2\). Nothing else is asked: not a particular logic, not a particular set of rules.
NV2. The minimum is enough. From this alone, by the diagonal of C26 (copy, read, deny):
| statement | in the file |
| no code answers “does \(c\) reject itself?” for every \(c\) | no_self_checker |
| some map \(\mathrm {Code}\to 2\) is the behaviour of no code | not_every_map_coded |
| no sentence says “\(c\) is not true of itself”: no truth predicate inside | no_truth_inside |
If \(d\) answered the first question, then at \(c=d\) its answer would be the denial of itself, which is \(1=0\).
NV3. With provability inside: Löb and Gödel. If the prover can also speak of its own theorems, by a sentence \(\Box a\) (“\(a\) is provable”) obeying the three derivability conditions, and has implication and self-reference, then:
statement | in the file |
if it proves \(\Box b\to b\), it proves \(b\) | loeb |
if consistent, some sentence is not provable | goedel1 |
if consistent, it does not prove its own consistency \(\Box \bot \to \bot \) | goedel2 |
if it proves its own consistency, it proves \(\bot \) | selfVerify_breaks |
|
A model in which all the assumptions hold together, and which is consistent and does not prove its consistency, is given (model, model_no_self_verify).
NV4. More rules do not help. NV2 and NV3 ask only that the prover have at least the listed ingredients. Adding rules removes none of them: the codes are still codes, the diagonal can still be formed, and the same proofs go through. So it is not necessary to write out all the rules of any prover. If a prover with few rules cannot verify itself, a prover with those rules and more cannot either; a stronger prover has a stronger statement of its own consistency, and that statement is again out of its reach. Every proof assistant in use has the minimum of NV1 and NV3.
NV5. Types cannot hold themselves. The same diagonal, said of the types of the checker used here: no type at a level names all the types of that level (lean_types_not_inside_lean, no_code_of_all_types). This is C26 for the kind of kinds.
NV5a. Always one more. The types of level \(u\) are not held by any type of level \(u\) (no_code_of_all_types), and they are held by a type of level \(u+1\). So what holds a level is always one level up, and never the level itself. The same for provers: in a tower \(T_0,T_1,T_2,\dots \) of consistent provers, no \(T_n\) proves its own consistency (tower_never_closes); what verifies \(T_n\) is some other prover, and that one is in the same position. A prover that held its own verifier would prove \(\bot \) (selfVerify_breaks). The tower does not close at any height: this is “one more” of C27, said of provers.
NV6. What this closes. Section 63.10 showed that a chain of apparatus does not end in a bare record (AL5). The same holds for a chain of provers: a prover’s correctness is checked by another prover, or by itself. By NV3 it is not checked by itself; by NV4 a stronger one is in the same position. The checks of Section 323 in Lean are therefore checks relative to Lean, and this statement is itself one of them.
NoSelfVerify.lean
/-
No prover verifies itself.
Core Lean 4, no Mathlib.
Part 1 (conditional). A proof system is given abstractly: sentences,
implication, falsity, a sentence `box a` read as "a is provable", and the
theorems `Pr`. It is assumed to have modus ponens, the axioms K and S, the
three derivability conditions D1-D3 and a diagonal (self-reference). Then:
Loeb: if it proves box b -> b, it proves b;
Goedel I: if consistent, some sentence is not provable;
Goedel II: if consistent, it does not prove its own consistency.
A model shows the assumptions hold together.
Part 2 (no assumptions). Lean's own types: no type at a level names all
the types of that level.
Part 3 (no assumptions). Types themselves: for any type `Code` and any way
of running or reading codes, no code answers the diagonal question, some
map is the behaviour of no code, and there is no truth predicate inside.
Part 4. Always one more: a level is held one level up, and in a tower of
consistent provers none verifies itself.
The assumptions ask only for a minimum. Adding rules removes none of it,
so the statements hold for every stronger system as well.
-/
namespace NoSelfVerify
structure ProvSys where
S : Type
imp : S → S → S
bot : S
box : S → S
Pr : S → Prop
mp : ∀ {a b : S}, Pr (imp a b) → Pr a → Pr b
axK : ∀ a b : S, Pr (imp a (imp b a))
axS : ∀ a b c : S, Pr (imp (imp a (imp b c)) (imp (imp a b) (imp a c)))
d1 : ∀ {a : S}, Pr a → Pr (box a)
d2 : ∀ a b : S, Pr (imp (box (imp a b)) (imp (box a) (box b)))
d3 : ∀ a : S, Pr (imp (box a) (box (box a)))
diag : ∀ b : S, ∃ L : S, Pr (imp L (imp (box L) b)) ∧ Pr (imp (imp (box L) b) L)
variable (T : ProvSys)
/-- chaining two implications, from K and S -/
theorem impTrans {a b c : T.S} (h1 : T.Pr (T.imp a b)) (h2 : T.Pr (T.imp b c)) :
T.Pr (T.imp a c) := by
have h3 : T.Pr (T.imp a (T.imp b c)) := T.mp (T.axK (T.imp b c) a) h2
exact T.mp (T.mp (T.axS a b c) h3) h1
/-- Loeb: proving "if b is provable then b" already proves b -/
theorem loeb (b : T.S) (h : T.Pr (T.imp (T.box b) b)) : T.Pr b := by
obtain ⟨L, hL1, hL2⟩ := T.diag b
have h3 : T.Pr (T.box (T.imp L (T.imp (T.box L) b))) := T.d1 hL1
have h4 : T.Pr (T.imp (T.box L) (T.box (T.imp (T.box L) b))) :=
T.mp (T.d2 L (T.imp (T.box L) b)) h3
have h5 : T.Pr (T.imp (T.box (T.imp (T.box L) b)) (T.imp (T.box (T.box L)) (T.box b))) :=
T.d2 (T.box L) b
have h6 : T.Pr (T.imp (T.box L) (T.imp (T.box (T.box L)) (T.box b))) :=
impTrans T h4 h5
have h7 : T.Pr (T.imp (T.box L) (T.box (T.box L))) := T.d3 L
have h8 : T.Pr (T.imp (T.box L) (T.box b)) :=
T.mp (T.mp (T.axS (T.box L) (T.box (T.box L)) (T.box b)) h6) h7
have h9 : T.Pr (T.imp (T.box L) b) := impTrans T h8 h
have h10 : T.Pr L := T.mp hL2 h9
have h11 : T.Pr (T.box L) := T.d1 h10
exact T.mp h9 h11
/-- Goedel I: a consistent system has an unprovable sentence -/
theorem goedel1 (hc : ¬ T.Pr T.bot) : ∃ G : T.S, ¬ T.Pr G := by
obtain ⟨L, hL1, _⟩ := T.diag T.bot
exact ⟨L, fun hL => hc (T.mp (T.mp hL1 hL) (T.d1 hL))⟩
/-- Goedel II: a consistent system does not prove its own consistency -/
theorem goedel2 (hc : ¬ T.Pr T.bot) : ¬ T.Pr (T.imp (T.box T.bot) T.bot) :=
fun h => hc (loeb T T.bot h)
/-- the same, read the other way: proving its own consistency makes it inconsistent -/
theorem selfVerify_breaks (h : T.Pr (T.imp (T.box T.bot) T.bot)) : T.Pr T.bot :=
loeb T T.bot h
/-! ## A model: all the assumptions hold together -/
def model : ProvSys where
S := Prop
imp := fun a b => a → b
bot := False
box := fun _ => True
Pr := fun p => p
mp := by
intro a b h x
exact h x
axK := by
intro a b x _
exact x
axS := by
intro a b c f g x
exact f x (g x)
d1 := by
intro a _
trivial
d2 := by
intro a b _ _
trivial
d3 := by
intro a _
trivial
diag := by
intro b
refine ⟨b, ?_, ?_⟩
· intro x _
exact x
· intro f
exact f trivial
/-- the model is consistent -/
theorem model_consistent : ¬ model.Pr model.bot := fun h => h
/-- and it does not prove its own consistency -/
theorem model_no_self_verify : ¬ model.Pr (model.imp (model.box model.bot) model.bot) :=
fun h => h trivial
/-- as goedel2 says it cannot -/
example : ¬ model.Pr (model.imp (model.box model.bot) model.bot) :=
goedel2 model model_consistent
/-! ## Lean's own types as a whole
Here nothing is assumed. The statements are about Lean's own universe
`Type u`: it cannot be held inside itself. -/
universe u
/-- the diagonal part for a map `g` from parts of `T` back into `T` -/
abbrev diagSet {T : Type u} (g : (T → Prop) → T) : T → Prop :=
fun t => ∃ s : T → Prop, g s = t ∧ ¬ s t
/-- the parts of `T` cannot be put back into `T` one-to-one (copy, read, deny) -/
theorem cantor_inj {T : Type u} (g : (T → Prop) → T)
(hg : ∀ s t, g s = g t → s = t) : False :=
match Classical.em (diagSet g (g (diagSet g))) with
| .inl h =>
match h with
| ⟨s, hs, hns⟩ =>
have e : s = diagSet g := hg s (diagSet g) hs
hns (by rw [e]; exact h)
| .inr h => h ⟨diagSet g, rfl, h⟩
theorem cast_inj {A B : Type u} (h : A = B) (x y : A) (e : cast h x = cast h y) : x = y := by
cases h
exact e
/-- No type of Lean at level `u` names all the types of level `u`:
whatever `α` and decoder `f` are given, some type is missed. -/
theorem lean_types_not_inside_lean {α : Type u} (f : α → Type u) :
¬ ∀ X : Type u, ∃ a, f a = X := by
intro hf
cases hf (Sigma f → Prop) with
| intro U hU =>
apply cantor_inj (fun s : Sigma f → Prop => (⟨U, cast hU.symm s⟩ : Sigma f))
intro s t h
have h' : (⟨U, cast hU.symm s⟩ : Sigma f) = ⟨U, cast hU.symm t⟩ := h
have h2 : cast hU.symm s = cast hU.symm t := eq_of_heq (Sigma.mk.inj h').2
exact cast_inj hU.symm s t h2
/-- So Lean has no type of codes for all of its own types, at any level. -/
theorem no_code_of_all_types : ¬ ∃ (α : Type u) (f : α → Type u), ∀ X : Type u, ∃ a, f a = X :=
fun ⟨_, f, hf⟩ => lean_types_not_inside_lean f hf
/-! ## Types themselves
Whatever is built from types has codes of some type `Code` and runs or reads
them by a map of types. The three statements below hold for every such
`Code`, with nothing assumed; Lean is built from types, so they hold for it. -/
/-- No total system runs its own diagonal: if `eval d c` is the answer of
program `d` on input `c`, no program answers "does `c` reject itself?". -/
theorem no_self_checker {Code : Type u} (eval : Code → Code → Bool) :
¬ ∃ d : Code, ∀ c, eval d c = !(eval c c) := by
intro ⟨d, h⟩
have h2 : eval d d = !(eval d d) := h d
cases hd : eval d d <;> simp [hd] at h2
/-- So some map of types `Code → Bool` is not the behaviour of any code:
the system cannot run all of itself. -/
theorem not_every_map_coded {Code : Type u} (eval : Code → Code → Bool) :
∃ f : Code → Bool, ∀ d, eval d ≠ f :=
⟨fun c => !(eval c c), fun d h => by
have h2 : eval d d = !(eval d d) := congrFun h d
cases hd : eval d d <;> simp [hd] at h2⟩
/-- The same for statements: if `holds d c` says "sentence `d` is true of `c`",
no sentence says "`c` is not true of itself". There is no truth predicate inside. -/
theorem no_truth_inside {Code : Type u} (holds : Code → Code → Prop) :
¬ ∃ d : Code, ∀ c, holds d c ↔ ¬ holds c c :=
fun ⟨d, h⟩ =>
have hd : holds d d ↔ ¬ holds d d := h d
have hn : ¬ holds d d := fun x => (hd.mp x) x
hn (hd.mpr hn)
/-! ## Always one more -/
/-- the types of level `u` are held one level up -/
example : Type (u + 1) := Type u
/-- A tower of provers, each consistent: at no height does one verify itself.
Whatever verifies prover `n` is not prover `n`. -/
theorem tower_never_closes (T : Nat → ProvSys) (hc : ∀ n, ¬ (T n).Pr (T n).bot) :
∀ n, ¬ (T n).Pr ((T n).imp ((T n).box (T n).bot) (T n).bot) :=
fun n => goedel2 (T n) (hc n)
end NoSelfVerify