This repository was archived by the owner on Jul 2, 2026. It is now read-only.
forked from gotrevor/Foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompleteness.lean
More file actions
304 lines (263 loc) · 9.34 KB
/
Copy pathCompleteness.lean
File metadata and controls
304 lines (263 loc) · 9.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
module
public import Foundation.Modal.Tableau
public import Foundation.Modal.Kripke.Basic
@[expose] public section
namespace LO.Modal
open Entailment
open Formula
open Kripke
open MaximalConsistentTableau
variable {S} [Entailment S (Formula ℕ)]
variable {𝓢 : S} [Entailment.Consistent 𝓢] [Entailment.K 𝓢]
namespace Kripke
section
abbrev canonicalFrame (𝓢 : S) [Entailment.Consistent 𝓢] [Entailment.K 𝓢] : Kripke.Frame where
World := MaximalConsistentTableau 𝓢
Rel t₁ t₂ := □⁻¹'t₁.1.1 ⊆ t₂.1.1
abbrev canonicalModel (𝓢 : S) [Entailment.Consistent 𝓢] [Entailment.K 𝓢] : Model where
toFrame := canonicalFrame 𝓢
Val a t := (atom a) ∈ t.1.1
@[reducible]
instance : Semantics (canonicalModel 𝓢) (Formula ℕ) := Formula.Kripke.Satisfies.semantics (M := canonicalModel 𝓢)
end
section lemmata
variable {φ ψ : Formula ℕ}
variable {t : (canonicalModel 𝓢).World}
lemma truthlemma : ((φ ∈ t.1.1) ↔ t ⊧ φ) ∧ ((φ ∈ t.1.2) ↔ ¬t ⊧ φ) := by
induction φ generalizing t with
| hatom =>
simp_all only [Semantics.Models, Satisfies, true_and];
exact iff_not_mem₁_mem₂.symm;
| hfalsum => simp [Semantics.Models, Satisfies];
| himp φ ψ ihφ ihψ =>
constructor;
. constructor;
. intro hφψ hφ;
rcases iff_mem₁_imp.mp hφψ with (hφ | hψ);
. have := ihφ.2.1 hφ; contradiction;
. exact ihψ.1.1 hψ;
. intro hφψ;
rcases Satisfies.imp_def₂.mp hφψ with (hφ | hψ);
. apply iff_mem₁_imp.mpr;
left;
exact ihφ.2.2 hφ;
. apply iff_mem₁_imp.mpr;
right;
exact ihψ.1.2 hψ;
. constructor;
. intro hφψ;
rcases iff_mem₂_imp.mp hφψ with ⟨hφ, hψ⟩;
apply Satisfies.imp_def₂.not.mpr;
push Not;
constructor;
. exact ihφ.1.mp hφ;
. exact ihψ.2.mp hψ;
. intro hφψ;
apply iff_mem₂_imp.mpr;
replace hφψ := Satisfies.imp_def₂.not.mp hφψ;
push Not at hφψ;
rcases hφψ with ⟨hφ, hψ⟩;
constructor;
. exact ihφ.1.mpr hφ;
. exact ihψ.2.mpr hψ;
| hbox φ ihφ =>
constructor;
. constructor;
. intro h t' Rtt';
apply ihφ.1.1;
exact iff_mem₁_box.mp h Rtt';
. intro h;
apply iff_mem₁_box.mpr;
intro t' Rtt';
apply ihφ.1.2;
exact h t' Rtt';
. constructor;
. intro h;
apply Satisfies.box_def.not.mpr;
push Not;
obtain ⟨t', Rtt', ht'⟩ := iff_mem₂_box.mp h;
use t';
constructor;
. exact Rtt';
. exact ihφ.2.mp ht';
. intro h;
apply iff_mem₂_box.mpr;
replace h := Satisfies.box_def.not.mp h;
push Not at h;
obtain ⟨t', Rtt', ht'⟩ := h;
use t';
constructor;
. exact Rtt';
. exact ihφ.2.mpr ht';
lemma truthlemma₁ : (φ ∈ t.1.1) ↔ t ⊧ φ := truthlemma.1
lemma truthlemma₂ : (φ ∈ t.1.2) ↔ ¬t ⊧ φ := truthlemma.2
lemma iff_valid_on_canonicalModel_deducible : (canonicalModel 𝓢) ⊧ φ ↔ 𝓢 ⊢ φ := by
constructor;
. contrapose;
intro h;
have : Tableau.Consistent 𝓢 (∅, {φ}) := by
apply Tableau.iff_consistent_empty_singleton₂ (𝓢 := 𝓢) (φ := φ) |>.mpr;
exact h;
obtain ⟨t, ht⟩ := lindenbaum this;
apply ValidOnModel.not_of_exists_world;
use t;
apply truthlemma₂.mp;
apply ht.2;
tauto_set;
. intro h t;
exact truthlemma₁.mp $ MaximalConsistentTableau.iff_provable_mem₁.mp h t;
end lemmata
class Canonical (𝓢 : S) [Entailment.Consistent 𝓢] [Entailment.K 𝓢] (C : FrameClass) : Prop where
canonical : (Kripke.canonicalFrame 𝓢) ∈ C
instance [Canonical 𝓢 C] : Complete 𝓢 C := ⟨by
intro φ;
contrapose!;
intro h;
apply not_validOnFrameClass_of_exists_model;
use (canonicalModel 𝓢);
constructor;
. exact Canonical.canonical;
. exact iff_valid_on_canonicalModel_deducible.not.mpr h;
⟩
namespace canonicalModel
open Formula.Kripke.Satisfies
variable {x y : (canonicalModel 𝓢).World}
lemma def_rel_box_mem₁ : x ≺ y ↔ □⁻¹'x.1.1 ⊆ y.1.1 := by simp [Frame.Rel'];
lemma def_rel_box_satisfies : x ≺ y ↔ ∀ {φ}, x ⊧ □φ → y ⊧ φ := by
constructor;
. intro h φ hφ;
exact truthlemma₁.mp $ def_rel_box_mem₁.mp h (truthlemma₁.mpr hφ);
. intro h;
apply def_rel_box_mem₁.mpr;
intro φ hφ;
exact truthlemma₁.mpr $ h $ truthlemma₁.mp hφ
lemma def_multirel_boxItr_satisfies : x ≺^[n] y ↔ (∀ {φ}, x ⊧ □^[n]φ → y ⊧ φ) := by
constructor;
. intro h φ hφ;
exact Satisfies.boxItr_def.mp hφ h;
. induction n generalizing x y with
| zero =>
suffices (∀ {φ : Formula ℕ}, x ⊧ φ → y ⊧ φ) → x = y by simpa;
intro h;
apply intro_equality;
. intro φ hφ; exact truthlemma₁.mpr $ h $ truthlemma₁.mp hφ;
. intro φ hφ; exact truthlemma₂.mpr $ h $ Satisfies.not_def.mpr $ truthlemma₂.mp hφ;
| succ n ih =>
intro h;
obtain ⟨t, ht⟩ := lindenbaum (𝓢 := 𝓢) (t₀ := ⟨{ φ | x ⊧ □φ }, □^[n]'{ φ | ¬y ⊧ φ }⟩) $ by
intro Γ Δ hΓ hΔ;
by_contra! hC;
have : 𝓢 ⊢ □Γ.conj 🡒 □Δ.disj := imply_box_distribute'! hC;
have : □Δ.disj ∈ x.1.1 := mdp_mem₁_provable this $ by
apply truthlemma₁.mpr;
intro y Rxy;
apply Satisfies.fconj_def.mpr;
intro φ hφ;
apply hΓ hφ y Rxy;
have : x ⊧ □Δ.disj := truthlemma₁.mp this;
have : x ⊧ □^[(n + 1)](□⁻¹^[n]'Δ).disj := by
suffices x ⊧ □□^[n](□⁻¹^[n]'Δ).disj by simpa;
intro y Rxy;
apply boxItr_def.mpr;
intro z Ryz;
apply Satisfies.fdisj_def.mpr;
obtain ⟨ψ, hψ₁, hψ₂⟩ := Satisfies.fdisj_def.mp $ this y Rxy;
obtain ⟨ξ, hξ, rfl⟩ := hΔ hψ₁;
use ξ;
constructor;
. simpa [Finset.LO.preboxItr];
. exact Satisfies.boxItr_def.mp hψ₂ Ryz;
have : y ⊧ (□⁻¹^[n]'Δ).disj := h this;
obtain ⟨ψ, hψ₁, hψ₂⟩ := fdisj_def.mp this;
have : y ⊭ ψ := Set.LO.mem_of_mem_boxItr $ @hΔ (□^[n]ψ) $ by
show □^[n]ψ ∈ ↑Δ;
grind;
contradiction;
use t;
constructor;
. intro φ hφ;
apply ht.1;
exact truthlemma₁.mp hφ;
. apply ih;
intro φ hφ;
have := Set.compl_subset_compl.mpr ht.2 $ iff_not_mem₂_mem₁.mpr $ truthlemma₁.mpr hφ;
grind;
lemma def_multirel_boxItr_mem₁ : x ≺^[n] y ↔ ((□⁻¹^[n]'x.1.1) ⊆ y.1.1) := ⟨
fun h _ hφ => truthlemma₁.mpr $ def_multirel_boxItr_satisfies.mp h $ truthlemma₁.mp hφ,
fun h => def_multirel_boxItr_satisfies.mpr fun hφ => truthlemma₁.mp (h $ truthlemma₁.mpr hφ)
⟩
lemma def_multirel_boxItr_mem₂ : x ≺^[n] y ↔ (y.1.2 ⊆ (□⁻¹^[n]'x.1.2)) := by
apply Iff.trans def_multirel_boxItr_mem₁;
constructor;
. intro h φ;
contrapose!;
intro hφ;
apply iff_not_mem₂_mem₁.mpr;
apply h;
apply iff_not_mem₂_mem₁.mp;
assumption;
. intro h φ;
contrapose!;
intro hφ;
apply iff_not_mem₁_mem₂.mpr;
apply h;
apply iff_not_mem₁_mem₂.mp;
assumption;
lemma def_rel_box_mem₂ : x ≺ y ↔ (y.1.2 ⊆ (□⁻¹' x.1.2)) := by
simpa using def_multirel_boxItr_mem₂ (n := 1);
lemma def_multirel_diaItr_satisfies : x ≺^[n] y ↔ (∀ {φ}, y ⊧ φ → x ⊧ ◇^[n]φ) := by
constructor;
. intro h φ hφ;
apply Formula.Kripke.Satisfies.diaItr_def.mpr;
use y;
. intro h;
apply def_multirel_boxItr_satisfies.mpr;
intro φ;
contrapose;
intro hφ;
apply Satisfies.not_def.mp;
have : x ⊧ ∼□^[n](∼∼φ) := diaItr_dual.mp $ h (φ := ∼φ) (Satisfies.not_def.mp hφ);
revert this;
apply intro_neg_semiequiv;
apply intro_boxItr_semiequiv;
intro _ _;
apply negneg_def.mpr;
lemma def_multirel_diaItr_mem₁ : x ≺^[n] y ↔ (y.1.1 ⊆ (◇⁻¹^[n]'x.1.1)) := by
constructor;
. intro h φ hφ;
apply truthlemma₁.mpr;
apply def_multirel_diaItr_satisfies.mp h;
exact truthlemma₁.mp hφ;
. intro h;
apply def_multirel_diaItr_satisfies.mpr;
intro _ hφ;
exact truthlemma₁.mp $ h $ truthlemma₁.mpr hφ;
/-
by
sorry,
-- fun h _ hφ => truthlemma₁.mpr $ def_multirel_diaItr_satisfies.mp h (truthlemma₁.mp hφ),
fun h => def_multirel_diaItr_satisfies.mpr fun hφ => truthlemma₁.mp $ h (truthlemma₁.mpr hφ)
⟩
-/
lemma def_rel_dia_mem₁ : x ≺ y ↔ (y.1.1 ⊆ (◇'⁻¹ x.1.1)) := by
simpa using def_multirel_diaItr_mem₁ (n := 1);
lemma def_multirel_diaItr_mem₂ : x ≺^[n] y ↔ ((◇⁻¹^[n]'x.1.2) ⊆ y.1.2) := by
constructor;
. intro Rxy φ;
contrapose;
intro hφ;
apply iff_not_mem₂_mem₁.mpr;
apply def_multirel_diaItr_mem₁.mp Rxy;
exact iff_not_mem₂_mem₁.mp hφ;
. intro H;
apply def_multirel_diaItr_mem₁.mpr;
intro φ;
contrapose;
intro hφ;
exact iff_not_mem₁_mem₂.mpr $ @H φ (iff_not_mem₁_mem₂.mp hφ);
lemma def_rel_dia_mem₂ : x ≺ y ↔ ((◇'⁻¹x.1.2) ⊆ y.1.2) := by
simpa using def_multirel_diaItr_mem₂ (n := 1);
end canonicalModel
end Kripke
end LO.Modal
end