@@ -5,10 +5,22 @@ import Mathlib.Computability.Reduce
5
5
# Church's Undecidability of First-Order Logic Theorem
6
6
-/
7
7
8
+ section
9
+
10
+ lemma Iff.of_not_not {p q : Prop } (hp : ¬p) (hq : ¬q) : p ↔ q := by {
11
+ exact (iff_false_right hq).mpr hp
12
+ }
13
+
14
+ end
8
15
9
16
section
10
17
11
- variable {α β} [Primcodable α] [Primcodable β]
18
+ lemma Part.cases (p : Part α) : p = Part.none ∨ ∃ a, a ∈ p := by
19
+ by_cases h : p.Dom
20
+ · right; exact Part.dom_iff_mem.mp h
21
+ · left; exact Part.eq_none_iff'.mpr h
22
+
23
+ variable {α β γ σ} [Primcodable α] [Primcodable β] [Primcodable γ] [Primcodable σ]
12
24
13
25
lemma ComputablePred.range_subset {f : α → β} (hf : Computable f) {A} (hA : ComputablePred A) : ComputablePred { x | A (f x) } := by
14
26
apply computable_iff.mpr;
@@ -18,8 +30,88 @@ lemma ComputablePred.range_subset {f : α → β} (hf : Computable f) {A} (hA :
18
30
. apply Computable.comp <;> assumption;
19
31
. rfl;
20
32
21
- end
33
+ open Computable
34
+
35
+ lemma Computable.of₁ {f : α → γ} (hf : Computable f) : Computable₂ fun (a : α) (_ : β) ↦ f a := Computable.to₂ (hf.comp fst)
36
+
37
+ lemma Computable.of₂ {f : β → γ} (hf : Computable f) : Computable₂ fun (_ : α) (b : β) ↦ f b := Computable.to₂ (hf.comp snd)
38
+
39
+ lemma Partrec.of₁ {f : α →. γ} (hf : Partrec f) : Partrec₂ fun (a : α) (_ : β) ↦ f a := Partrec.to₂ (hf.comp Computable.fst)
40
+
41
+ lemma Partrec.of₂ {f : β →. γ} (hf : Partrec f) : Partrec₂ fun (_ : α) (b : β) ↦ f b := Partrec.to₂ (hf.comp Computable.snd)
42
+
43
+ theorem Partrec.optionCasesOn {o : α → Option β} {f : α →. σ} {g : α → β →. σ} (ho : Computable o)
44
+ (hf : Partrec f) (hg : Partrec₂ g) :
45
+ Partrec fun a ↦ Option.casesOn (o a) (f a) (g a) := by
46
+ let optToSum : Option β → Unit ⊕ β := fun o ↦ Option.casesOn o (Sum.inl ()) Sum.inr
47
+ have hOptToSum : Computable optToSum :=
48
+ Computable.option_casesOn Computable.id (Computable.const (Sum.inl ())) (Computable.of₂ Computable.sumInr)
49
+ exact (Partrec.sumCasesOn (hOptToSum.comp ho) (Partrec.of₁ hf) hg).of_eq <| by
50
+ intro a
51
+ rcases o a <;> simp [optToSum]
52
+
53
+ theorem Partrec.rfindOpt_unique {α} {f : ℕ → Option α}
54
+ (H : ∀ {a n}, a ∈ f n → ∀ {b m}, b ∈ f m → a = b) {a} :
55
+ a ∈ Nat.rfindOpt f ↔ ∃ n, a ∈ f n := by
56
+ constructor
57
+ · exact Nat.rfindOpt_spec
58
+ · rintro ⟨n, h⟩
59
+ have h' := Nat.rfindOpt_dom.2 ⟨_, _, h⟩
60
+ obtain ⟨k, hk⟩ := Nat.rfindOpt_spec ⟨h', rfl⟩
61
+ rcases H h hk
62
+ exact Part.get_mem h'
63
+
64
+ lemma ComputablePred.eq {f g : α → β}
65
+ (hf : Computable f) (hg : Computable g) : ComputablePred fun a : α ↦ f a = g a := by
66
+ have : DecidableEq β := Encodable.decidableEqOfEncodable β
67
+ apply ComputablePred.computable_iff.mpr ⟨fun a ↦ f a = g a, ?_, ?_⟩
68
+ · exact (Primrec.eq (α := β)).to_comp.comp hf hg
69
+ · ext a; simp
70
+
71
+ lemma ComputablePred.ne {f g : α → β}
72
+ (hf : Computable f) (hg : Computable g) : ComputablePred fun a : α ↦ f a ≠ g a :=
73
+ (ComputablePred.eq hf hg).not
74
+
75
+ private lemma REPred.toComputable_func {f : α → β} (h : REPred fun p : α × β ↦ f p.1 = p.2 ) :
76
+ ComputablePred fun p : α × β ↦ f p.1 = p.2 := by
77
+ apply ComputablePred.computable_iff_re_compl_re'.mpr ⟨h, ?_⟩
78
+ have : REPred fun p : (α × β) × β ↦ f p.1 .1 = p.2 ∧ p.2 ≠ p.1 .2 :=
79
+ REPred.and
80
+ (h.comp (α := (α × β) × β) ((fst.comp fst).pair snd))
81
+ (ComputablePred.ne snd (snd.comp fst)).to_re
82
+ exact this.projection.of_eq <| by
83
+ rintro ⟨a, b⟩
84
+ simp
85
+
86
+ lemma REPred.toComputable {f : α → β} (h : REPred fun p : α × β ↦ f p.1 = p.2 ) : Computable f := by
87
+ have h : ComputablePred fun p : α × β ↦ f p.1 = p.2 := REPred.toComputable_func h
88
+ rcases ComputablePred.computable_iff.mp h with ⟨c, hc, ec⟩
89
+ replace ec : ∀ p : α × β, c p = true ↔ f p.1 = p.2 := fun p ↦ by symm; simpa using congr_fun ec p
90
+ let g : α → ℕ → Option β := fun a n ↦ (Encodable.decode n : Option β).bind fun b ↦ bif c ⟨a, b⟩ then .some b else .none
91
+ have hg : Computable₂ g := by
92
+ have : Computable₂ fun (p : α × ℕ) (b : β) ↦ bif c ⟨p.1 , b⟩ then some b else none :=
93
+ (cond (hc.comp (pair (fst.comp fst) snd))
94
+ (option_some.comp snd) (const none)).to₂ (α := α × ℕ) (β := β)
95
+ exact (Computable.option_bind (Computable.comp Computable.decode Computable.snd) this).to₂
96
+ have := Partrec.rfindOpt hg
97
+ exact this.of_eq <| by
98
+ intro a
99
+ refine Part.eq_some_iff.mpr ?_
100
+ refine (Partrec.rfindOpt_unique ?_).mpr ?_
101
+ · unfold g
102
+ intro b₁ n₁
103
+ rcases (Encodable.decode n₁ : Option β) with (_ | v₁)
104
+ · simp
105
+ intro h₁ b₂ n₂
106
+ rcases (Encodable.decode n₂ : Option β) with (_ | v₂)
107
+ · simp
108
+ revert h₁
109
+ suffices f a = v₁ → v₁ = b₁ → f a = v₂ → v₂ = b₂ → b₁ = b₂ by simpa [Bool.cond_eq_if, ec]
110
+ grind
111
+ · use Encodable.encode (f a)
112
+ simp [g, ec, Bool.cond_eq_if]
22
113
114
+ end
23
115
24
116
namespace LO.ISigma1
25
117
@@ -103,6 +195,20 @@ theorem firstorder_undecidability : ¬ComputablePred (fun n : ℕ ↦ ∃ σ : S
103
195
apply @not_computable_theorems (T := 𝐏𝐀⁻) (by sorry ) inferInstance inferInstance;
104
196
sorry ;
105
197
198
+ /-
199
+ open LO.Entailment FirstOrder Arithmetic R0 PeanoMinus IOpen ISigma0 ISigma1 Metamath InternalArithmetic
200
+
201
+ private lemma theory_provability_undecidable : ¬ComputablePred fun n : ℕ ↦ ∃ σ : Sentence ℒₒᵣ, n = ⌜σ⌝ ∧ T ⊢!. σ := by {
202
+ intro hC
203
+ let U : ℕ → Prop := fun n : ℕ ↦ ∀ σ : Sentence ℒₒᵣ, n = ⌜σ⌝ → T ⊬. σ
204
+ have U_re : REPred U := by simpa using hC.not.to_re
205
+ let υ : Semisentence ℒₒᵣ 1 := codeOfREPred U
206
+ have hυ : ∀ n : ℕ, U n ↔ T ⊢!. υ/[ ↑n ] := fun n ↦ by
207
+ simpa [Semiformula.coe_substs_eq_substs_coe₁, Axiom.provable_iff] using re_complete U_re
208
+ let δ : Semisentence ℒₒᵣ 1 := “σ. ∃ τ, !ssnum τ σ σ ∧ ”
209
+ }
210
+ -/
211
+
106
212
end Arithmetic
107
213
108
214
end LO.FirstOrder
0 commit comments