-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathElementaryMaps.lean
More file actions
362 lines (291 loc) · 13.7 KB
/
Copy pathElementaryMaps.lean
File metadata and controls
362 lines (291 loc) · 13.7 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/-
Copyright (c) 2022 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
module
public import Mathlib.Data.Fintype.Basic
public import Mathlib.ModelTheory.Substructures
/-!
# Elementary Maps Between First-Order Structures
## Main Definitions
- A `FirstOrder.Language.ElementaryEmbedding` is an embedding that commutes with the
realizations of formulas.
- The `FirstOrder.Language.elementaryDiagram` of a structure is the set of all sentences with
parameters that the structure satisfies.
- `FirstOrder.Language.ElementaryEmbedding.ofModelsElementaryDiagram` is the canonical
elementary embedding of any structure into a model of its elementary diagram.
## Main Results
- `FirstOrder.Language.ElementaryEmbedding.mk_realizations_le` shows that definable-set
cardinality cannot decrease under an elementary embedding.
- `FirstOrder.Language.ElementaryEmbedding.encard_realizations_eq_coe_iff` shows that elementary
embeddings preserve exact finite definable-set cardinality.
- `FirstOrder.Language.ElementaryEmbedding.infinite_realizations_iff` shows that elementary
embeddings preserve and reflect infinitude of definable sets.
- The Tarski-Vaught Test for embeddings: `FirstOrder.Language.Embedding.isElementary_of_exists`
gives a simple criterion for an embedding to be elementary.
-/
@[expose] public section
open FirstOrder
open scoped Cardinal
namespace FirstOrder
namespace Language
open Structure
variable (L : Language) (M : Type*) (N : Type*) {P : Type*} {Q : Type*}
variable [L.Structure M] [L.Structure N] [L.Structure P] [L.Structure Q]
/-- An elementary embedding of first-order structures is an embedding that commutes with the
realizations of formulas. -/
structure ElementaryEmbedding where
/-- The underlying embedding -/
toFun : M → N
-- Porting note:
-- The autoparam here used to be `obviously`.
-- We have replaced it with `aesop` but that isn't currently sufficient.
-- See https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Aesop.20and.20cases
-- If that can be improved, we should remove the proofs below.
map_formula' :
∀ ⦃n⦄ (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (toFun ∘ x) ↔ φ.Realize x := by
aesop
@[inherit_doc FirstOrder.Language.ElementaryEmbedding]
scoped[FirstOrder] notation:25 A " ↪ₑ[" L "] " B => FirstOrder.Language.ElementaryEmbedding L A B
variable {L} {M} {N}
namespace ElementaryEmbedding
attribute [coe] toFun
instance instFunLike : FunLike (M ↪ₑ[L] N) M N where
coe f := f.toFun
coe_injective f g h := by
cases f
cases g
simpa only [ElementaryEmbedding.mk.injEq]
@[simp]
theorem map_boundedFormula (f : M ↪ₑ[L] N) {α : Type*} {n : ℕ} (φ : L.BoundedFormula α n)
(v : α → M) (xs : Fin n → M) : φ.Realize (f ∘ v) (f ∘ xs) ↔ φ.Realize v xs := by
classical
rw [← BoundedFormula.realize_restrictFreeVar' Set.Subset.rfl, Set.inclusion_eq_id]
have h :=
f.map_formula' ((φ.restrictFreeVar id).toFormula.relabel (Fintype.equivFin _))
(Sum.elim (v ∘ (↑)) xs ∘ (Fintype.equivFin _).symm)
simp only [Formula.realize_relabel, BoundedFormula.realize_toFormula] at h
rw [← Function.comp_assoc _ _ (Fintype.equivFin _).symm,
Function.comp_assoc _ (Fintype.equivFin _).symm (Fintype.equivFin _),
_root_.Equiv.symm_comp_self, Function.comp_id, Function.comp_assoc, Sum.elim_comp_inl,
Function.comp_assoc _ _ Sum.inr, Sum.elim_comp_inr, ← Function.comp_assoc] at h
refine h.trans ?_
rw [Function.comp_assoc _ _ (Fintype.equivFin _), _root_.Equiv.symm_comp_self,
Function.comp_id, Sum.elim_comp_inl, Sum.elim_comp_inr (v ∘ Subtype.val) xs,
BoundedFormula.realize_restrictFreeVar v (by simp)]
@[simp]
theorem map_formula (f : M ↪ₑ[L] N) {α : Type*} (φ : L.Formula α) (x : α → M) :
φ.Realize (f ∘ x) ↔ φ.Realize x := by
rw [Formula.Realize, Formula.Realize, ← f.map_boundedFormula, Unique.eq_default (f ∘ default)]
theorem map_sentence (f : M ↪ₑ[L] N) (φ : L.Sentence) : M ⊨ φ ↔ N ⊨ φ := by
rw [Sentence.Realize, Sentence.Realize, ← f.map_formula, Unique.eq_default (f ∘ default)]
theorem theory_model_iff (f : M ↪ₑ[L] N) (T : L.Theory) : M ⊨ T ↔ N ⊨ T := by
simp only [Theory.model_iff, f.map_sentence]
theorem elementarilyEquivalent (f : M ↪ₑ[L] N) : M ≅[L] N :=
elementarilyEquivalent_iff.2 f.map_sentence
@[simp]
theorem injective (φ : M ↪ₑ[L] N) : Function.Injective φ := by
intro x y
exact (φ.map_formula ((var 0).equal (var 1)) fun i => if i = 0 then x else y).1
instance embeddingLike : EmbeddingLike (M ↪ₑ[L] N) M N :=
{ show FunLike (M ↪ₑ[L] N) M N from inferInstance with injective' := injective }
section
universe u u' v v'
variable {M : Type u} {N : Type u'} {α : Type v} {β : Type v'}
variable [L.Structure M] [L.Structure N]
/-- The embedding of realization subtypes induced by an elementary embedding. -/
def realizationsEmbedding (e : M ↪ₑ[L] N) (φ : L.Formula (β ⊕ α)) (b : β → M) :
{x : α → M | φ.Realize (Sum.elim b x)} ↪
{x : α → N | φ.Realize (Sum.elim (e ∘ b) x)} where
toFun x := ⟨e ∘ x, show φ.Realize _ by
simpa only [← Sum.comp_elim] using (e.map_formula φ (Sum.elim b x)).mpr x.2⟩
inj' x y h := Subtype.ext <| e.injective.comp_left <| congrArg Subtype.val h
/-- Cardinality of a definable set cannot decrease under an elementary embedding. -/
theorem mk_realizations_le (e : M ↪ₑ[L] N) (φ : L.Formula (β ⊕ α)) (b : β → M) :
Cardinal.lift.{max u' v} (#({x : α → M | φ.Realize (Sum.elim b x)})) ≤
Cardinal.lift.{max u v} (#({x : α → N | φ.Realize (Sum.elim (e ∘ b) x)})) :=
Cardinal.lift_mk_le_lift_mk_of_injective (realizationsEmbedding e φ b).injective
/-- An elementary embedding preserves and reflects exact finite cardinality of a definable set. -/
theorem encard_realizations_eq_coe_iff [Finite α] (e : M ↪ₑ[L] N)
(φ : L.Formula (β ⊕ α)) (b : β → M) (n : ℕ) :
{x : α → N | φ.Realize (Sum.elim (e ∘ b) x)}.encard = n ↔
{x : α → M | φ.Realize (Sum.elim b x)}.encard = n := by
simp only [← Formula.realize_iExsExactly, map_formula]
/-- The infinitude of a definable set is preserved under an elementary embedding. -/
theorem infinite_realizations_iff [Finite α] (e : M ↪ₑ[L] N)
(φ : L.Formula (β ⊕ α)) (b : β → M) :
Set.Infinite {x : α → N | φ.Realize (Sum.elim (e ∘ b) x)} ↔
Set.Infinite {x : α → M | φ.Realize (Sum.elim b x)} := by
simp [Set.encard_eq_top_iff.symm.trans ENat.eq_top_iff_forall_ge,
← Formula.realize_iExsAtLeast]
end
@[simp]
theorem map_fun (φ : M ↪ₑ[L] N) {n : ℕ} (f : L.Functions n) (x : Fin n → M) :
φ (funMap f x) = funMap f (φ ∘ x) := by
have h := φ.map_formula (Formula.graph f) (Fin.cons (funMap f x) x)
rw [Formula.realize_graph, Fin.comp_cons, Formula.realize_graph] at h
rw [eq_comm, h]
@[simp]
theorem map_rel (φ : M ↪ₑ[L] N) {n : ℕ} (r : L.Relations n) (x : Fin n → M) :
RelMap r (φ ∘ x) ↔ RelMap r x :=
haveI h := φ.map_formula (r.formula var) x
h
instance strongHomClass : StrongHomClass L (M ↪ₑ[L] N) M N where
map_fun := map_fun
map_rel := map_rel
@[simp]
theorem map_constants (φ : M ↪ₑ[L] N) (c : L.Constants) : φ c = c :=
HomClass.map_constants φ c
/-- An elementary embedding is also a first-order embedding. -/
def toEmbedding (f : M ↪ₑ[L] N) : M ↪[L] N where
toFun := f
inj' := f.injective
map_fun' {_} f x := by simp
map_rel' {_} R x := by simp
/-- An elementary embedding is also a first-order homomorphism. -/
def toHom (f : M ↪ₑ[L] N) : M →[L] N where
toFun := f
map_fun' {_} f x := by simp
map_rel' {_} R x := by simp
@[simp]
theorem toEmbedding_toHom (f : M ↪ₑ[L] N) : f.toEmbedding.toHom = f.toHom :=
rfl
@[simp]
theorem coe_toHom {f : M ↪ₑ[L] N} : (f.toHom : M → N) = (f : M → N) :=
rfl
@[simp]
theorem coe_toEmbedding (f : M ↪ₑ[L] N) : (f.toEmbedding : M → N) = (f : M → N) :=
rfl
theorem coe_injective : @Function.Injective (M ↪ₑ[L] N) (M → N) (↑) :=
DFunLike.coe_injective
@[ext]
theorem ext ⦃f g : M ↪ₑ[L] N⦄ (h : ∀ x, f x = g x) : f = g :=
DFunLike.ext f g h
variable (L) (M)
/-- The identity elementary embedding from a structure to itself -/
@[refl]
def refl : M ↪ₑ[L] M where toFun := id
variable {L} {M}
instance : Inhabited (M ↪ₑ[L] M) :=
⟨refl L M⟩
@[simp]
theorem refl_apply (x : M) : refl L M x = x :=
rfl
/-- Composition of elementary embeddings -/
@[trans]
def comp (hnp : N ↪ₑ[L] P) (hmn : M ↪ₑ[L] N) : M ↪ₑ[L] P where
toFun := hnp ∘ hmn
map_formula' n φ x := by simp [Function.comp_assoc]
@[simp]
theorem comp_apply (g : N ↪ₑ[L] P) (f : M ↪ₑ[L] N) (x : M) : g.comp f x = g (f x) :=
rfl
/-- Composition of elementary embeddings is associative. -/
theorem comp_assoc (f : M ↪ₑ[L] N) (g : N ↪ₑ[L] P) (h : P ↪ₑ[L] Q) :
(h.comp g).comp f = h.comp (g.comp f) :=
rfl
/-- Lifts an elementary embedding to the expanded language with constants -/
def liftWithConstants (f : M ↪ₑ[L] N) (A : Set M) :
M ↪ₑ[L[[A]]] (f.toEmbedding.withConstants A) := by
refine ⟨f, ?_⟩
intro n φ x
have h :
(Sum.elim (fun a ↦ ↑(L.con a)) (⇑f ∘ x) :
↑A ⊕ Fin n → f.toEmbedding.withConstants A) =
f ∘ Sum.elim (fun a ↦ ↑(L.con a)) x :=
(Sum.comp_elim _ _ _).symm
simpa only [Formula.Realize, ← BoundedFormula.realize_constantsVarsEquiv, h] using!
f.map_formula
(BoundedFormula.constantsVarsEquiv φ)
(Sum.elim (fun a ↦ ↑(L.con a)) x)
end ElementaryEmbedding
variable (L) (M)
/-- The elementary diagram of an `L`-structure is the set of all sentences with parameters it
satisfies. -/
abbrev elementaryDiagram : L[[M]].Theory :=
L[[M]].completeTheory M
set_option backward.isDefEq.respectTransparency false in
/-- The canonical elementary embedding of an `L`-structure into any model of its elementary diagram
-/
@[simps]
def ElementaryEmbedding.ofModelsElementaryDiagram (N : Type*) [L.Structure N] [L[[M]].Structure N]
[(lhomWithConstants L M).IsExpansionOn N] [N ⊨ L.elementaryDiagram M] : M ↪ₑ[L] N :=
⟨((↑) : L[[M]].Constants → N) ∘ Sum.inr, fun n φ x => by
refine
_root_.trans ?_
((realize_iff_of_model_completeTheory M N
(((L.lhomWithConstants M).onBoundedFormula φ).subst
(Constants.term ∘ Sum.inr ∘ x)).alls).trans
?_)
· simp_rw [Sentence.Realize, BoundedFormula.realize_alls, BoundedFormula.realize_subst,
LHom.realize_onBoundedFormula, Formula.Realize, Unique.forall_iff, Function.comp_def,
Term.realize_constants]
· simp_rw [Sentence.Realize, BoundedFormula.realize_alls, BoundedFormula.realize_subst,
LHom.realize_onBoundedFormula, Formula.Realize, Unique.forall_iff]
rfl⟩
variable {L M}
namespace Embedding
/-- The **Tarski-Vaught test** for elementarity of an embedding. -/
theorem isElementary_of_exists (f : M ↪[L] N)
(htv :
∀ (n : ℕ) (φ : L.BoundedFormula Empty (n + 1)) (x : Fin n → M) (a : N),
φ.Realize default (Fin.snoc (f ∘ x) a : _ → N) →
∃ b : M, φ.Realize default (Fin.snoc (f ∘ x) (f b) : _ → N)) :
∀ {n} (φ : L.Formula (Fin n)) (x : Fin n → M), φ.Realize (f ∘ x) ↔ φ.Realize x := by
suffices h : ∀ (n : ℕ) (φ : L.BoundedFormula Empty n) (xs : Fin n → M),
φ.Realize (f ∘ default) (f ∘ xs) ↔ φ.Realize default xs by
intro n φ x
exact φ.realize_relabel_sumInr.symm.trans (_root_.trans (h n _ _) φ.realize_relabel_sumInr)
refine fun n φ => φ.recOn ?_ ?_ ?_ ?_ ?_
· exact fun {_} _ => Iff.rfl
· intros
simp [BoundedFormula.Realize, ← Sum.comp_elim, HomClass.realize_term]
· intro _ _ R ts xs
simp only [BoundedFormula.Realize, ← Sum.comp_elim, HomClass.realize_term]
simp_rw [← Function.comp_apply (f := (f : M → N)),
← Function.comp_apply (f := Term.realize (Sum.elim default xs)),
← Function.comp_apply (f := (f : M → N) ∘ Term.realize (Sum.elim default xs))]
rw [Function.comp_assoc, map_rel f]
· intro _ _ _ ih1 ih2 _
simp [ih1, ih2]
· intro n φ ih xs
simp only [BoundedFormula.realize_all]
refine ⟨fun h a => ?_, ?_⟩
· rw [← ih, Fin.comp_snoc]
exact h (f a)
· contrapose!
rintro ⟨a, ha⟩
obtain ⟨b, hb⟩ := htv n φ.not xs a (by
rw [BoundedFormula.realize_not, ← Unique.eq_default (f ∘ default)]
exact ha)
refine ⟨b, fun h => hb (Eq.mp ?_ ((ih _).2 h))⟩
rw [Unique.eq_default (f ∘ default), Fin.comp_snoc]
/-- Bundles an embedding satisfying the Tarski-Vaught test as an elementary embedding. -/
@[simps]
def toElementaryEmbedding (f : M ↪[L] N)
(htv :
∀ (n : ℕ) (φ : L.BoundedFormula Empty (n + 1)) (x : Fin n → M) (a : N),
φ.Realize default (Fin.snoc (f ∘ x) a : _ → N) →
∃ b : M, φ.Realize default (Fin.snoc (f ∘ x) (f b) : _ → N)) :
M ↪ₑ[L] N :=
⟨f, fun _ => f.isElementary_of_exists htv⟩
end Embedding
namespace Equiv
/-- A first-order equivalence is also an elementary embedding. -/
def toElementaryEmbedding (f : M ≃[L] N) : M ↪ₑ[L] N where
toFun := f
@[simp]
theorem toElementaryEmbedding_toEmbedding (f : M ≃[L] N) :
f.toElementaryEmbedding.toEmbedding = f.toEmbedding :=
rfl
@[simp]
theorem coe_toElementaryEmbedding (f : M ≃[L] N) :
(f.toElementaryEmbedding : M → N) = (f : M → N) :=
rfl
end Equiv
@[simp]
theorem realize_term_substructure {α : Type*} {S : L.Substructure M} (v : α → S) (t : L.Term α) :
t.realize ((↑) ∘ v) = (↑(t.realize v) : M) :=
HomClass.realize_term S.subtype
end Language
end FirstOrder