Skip to content

Commit 71b57f2

Browse files
SnO2WMaNclaude
andauthored
add(Incompleteness): First incompleteness theorem from the halting problem (#836)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2040d2f commit 71b57f2

1 file changed

Lines changed: 54 additions & 14 deletions

File tree

Foundation/FirstOrder/Incompleteness/Halting.lean

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,64 @@ lemma incomplete_of_REPred_not_ComputablePred_Nat
5656
use φ/[⌜a⌝];
5757
constructor <;> assumption;
5858

59-
/-
60-
lemma _root_.REPred.iff_decoded_pred {A : α → Prop} [Primcodable α] : REPred A ↔ REPred λ n : ℕ ↦ match Encodable.decode n with | some a => A a | none => False := by
61-
sorry;
62-
63-
lemma _root_.ComputablePred.iff_decoded_pred {A : α → Prop} [h : Primcodable α] : ComputablePred A ↔ ComputablePred λ n : ℕ ↦ match Encodable.decode n with | some a => A a | none => False := by
64-
sorry;
59+
/--
60+
Recursive enumerability of a predicate on a `Primcodable` type is equivalent to
61+
the recursive enumerability of the corresponding predicate on `ℕ` obtained by decoding.
62+
-/
63+
lemma _root_.REPred.iff_decoded_pred {α : Type*} [Primcodable α] {A : α → Prop} :
64+
REPred A ↔ REPred fun n : ℕ ↦ (Encodable.decode (α := α) n).elim False A := by
65+
constructor
66+
· intro hA
67+
have hbind : Partrec fun n : ℕ =>
68+
(Encodable.decode (α := α) n : Part α).bind
69+
fun a => Part.assert (A a) fun _ => Part.some () :=
70+
(Computable.ofOption Computable.decode).bind (hA.comp Computable.snd).to₂
71+
refine (Partrec.dom_re hbind).of_eq fun n => ?_
72+
rcases h : Encodable.decode (α := α) n with _ | a <;> simp [Part.assert]
73+
· intro hg
74+
refine REPred.of_eq (p := fun a => (Encodable.decode (α := α) (Encodable.encode a)).elim False A)
75+
(hg.comp Computable.encode) fun a => ?_
76+
simp [Encodable.encodek]
6577

66-
lemma incomplete_of_REPred_not_ComputablePred₂ {P : α → Prop} [h : Primcodable α] (hRE : REPred P) (hC : ¬ComputablePred P) : ¬Entailment.Complete (T : Axiom ℒₒᵣ) := by
67-
apply incomplete_of_REPred_not_ComputablePred (P := λ n : ℕ ↦ match h.decode n with | some a => P a | none => False);
68-
. exact REPred.iff_decoded_pred.mp hRE;
69-
. exact ComputablePred.iff_decoded_pred.not.mp hC;
78+
/--
79+
Computability of a predicate on a `Primcodable` type is equivalent to
80+
the computability of the corresponding predicate on `ℕ` obtained by decoding.
81+
-/
82+
lemma _root_.ComputablePred.iff_decoded_pred {α : Type*} [Primcodable α] {A : α → Prop} :
83+
ComputablePred A ↔ ComputablePred fun n : ℕ ↦ (Encodable.decode (α := α) n).elim False A := by
84+
constructor
85+
· intro hA
86+
refine computablePred_iff_computable_decide.mpr ?_
87+
have hcomp := Computable.option_casesOn (o := fun n : ℕ => Encodable.decode (α := α) n)
88+
(f := fun _ => false) (g := fun _ a => decide (A a))
89+
Computable.decode (Computable.const false) (hA.decide.comp Computable.snd)
90+
refine hcomp.of_eq fun n => ?_
91+
rcases h : Encodable.decode (α := α) n with _ | a <;> simp
92+
· intro hg
93+
have hdec : Computable fun a : α =>
94+
decide ((Encodable.decode (α := α) (Encodable.encode a)).elim False A) :=
95+
hg.decide.comp Computable.encode
96+
refine ComputablePred.of_eq
97+
(p := fun a => (Encodable.decode (α := α) (Encodable.encode a)).elim False A)
98+
(computablePred_iff_computable_decide.mpr hdec) fun a => ?_
99+
simp [Encodable.encodek]
70100

71101
/--
72-
Halting problem is r.e. but not recursive, so Gödel's first incompleteness theorem follows.
102+
If an r.e. but not recursive predicate `P` on a `Primcodable` type exists, then incompleteness follows.
73103
-/
74-
theorem incomplete_of_halting_problem : ¬Entailment.Complete (T : Axiom ℒₒᵣ) := incomplete_of_REPred_not_ComputablePred₂
75-
(ComputablePred.halting_problem_re 0)
76-
(ComputablePred.halting_problem _)
104+
lemma incomplete_of_REPred_not_ComputablePred {α : Type*} [Primcodable α] {P : α → Prop}
105+
(hRE : REPred P) (hC : ¬ComputablePred P) : Entailment.Incomplete T := by
106+
apply incomplete_of_REPred_not_ComputablePred_Nat T
107+
(P := fun n : ℕ ↦ (Encodable.decode (α := α) n).elim False P)
108+
· exact REPred.iff_decoded_pred.mp hRE
109+
· exact ComputablePred.iff_decoded_pred.not.mp hC
110+
111+
/--
112+
The halting problem is r.e. but not recursive, so Gödel's first incompleteness theorem follows.
77113
-/
114+
theorem incomplete_of_halting_problem : Entailment.Incomplete T :=
115+
incomplete_of_REPred_not_ComputablePred T
116+
(ComputablePred.halting_problem_re 0)
117+
(ComputablePred.halting_problem 0)
78118

79119
end LO.FirstOrder.Arithmetic

0 commit comments

Comments
 (0)