Skip to content

Commit fa17faf

Browse files
committed
feat(ModelTheory/Definablity): add syntax-to-definability bridge lemmas
1 parent a8af750 commit fa17faf

2 files changed

Lines changed: 88 additions & 56 deletions

File tree

Mathlib/ModelTheory/Definability.lean

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,35 +93,88 @@ theorem Definable.mono (hAs : A.Definable L s) (hAB : A ⊆ B) : B.Definable L s
9393
rw [definable_iff_empty_definable_with_params] at *
9494
exact hAs.map_expansion (L.lhomWithConstantsMap (Set.inclusion hAB))
9595

96+
end Set
97+
98+
namespace FirstOrder.Language
99+
100+
open Set
101+
102+
variable {L : Language.{u, v}} {M : Type w} [L.Structure M]
103+
104+
variable {A : Set M} {α : Type u₁}
105+
106+
namespace Formula
107+
108+
/-- A formula with parameters from `A` defines the set of its realizations. -/
109+
theorem definable_withConstants (φ : L[[A]].Formula α) :
110+
A.Definable L {v | φ.Realize v} :=
111+
⟨φ, rfl⟩
112+
113+
theorem definable (φ : L.Formula α) :
114+
A.Definable L {v | φ.Realize v} :=
115+
(empty_definable_iff.mpr ⟨φ, rfl⟩).mono (empty_subset A)
116+
117+
end Formula
118+
119+
namespace BoundedFormula
120+
121+
variable {n : ℕ}
122+
123+
theorem definable_withConstants (φ : L[[A]].BoundedFormula α n) :
124+
A.Definable L {v | φ.Realize (v ∘ Sum.inl) (v ∘ Sum.inr)} := by
125+
simpa using φ.toFormula.definable_withConstants
126+
127+
theorem definable (φ : L.BoundedFormula α n) :
128+
A.Definable L {v | φ.Realize (v ∘ Sum.inl) (v ∘ Sum.inr)} := by
129+
simpa using φ.toFormula.definable
130+
131+
theorem definable_boundedSection_withConstants (φ : L[[A]].BoundedFormula Empty n) :
132+
A.Definable L {xs | φ.Realize default xs} := by
133+
convert (φ.toFormula.relabel (Sum.elim Empty.elim id)).definable_withConstants using 1
134+
ext xs
135+
simp only [Formula.realize_relabel, realize_toFormula]
136+
congr!
137+
138+
theorem definable_boundedSection (φ : L.BoundedFormula Empty n) :
139+
A.Definable L {xs | φ.Realize default xs} := by
140+
convert (φ.toFormula.relabel (Sum.elim Empty.elim id)).definable
141+
ext xs
142+
simp only [Formula.realize_relabel, realize_toFormula]
143+
congr!
144+
145+
end BoundedFormula
146+
147+
end FirstOrder.Language
148+
149+
namespace Set
150+
151+
open FirstOrder FirstOrder.Language
152+
153+
variable {M : Type w} {A : Set M} {L : FirstOrder.Language.{u, v}} [L.Structure M]
154+
155+
variable {α : Type u₁} {β : Type*} {s : Set (α → M)}
156+
96157
@[simp]
97158
theorem definable_empty : A.Definable L (∅ : Set (α → M)) :=
98-
⟨⊥, by
99-
ext
100-
simp⟩
159+
(⊥ : L[[A]].Formula α).definable_withConstants
101160

102161
@[simp]
103-
theorem definable_univ : A.Definable L (univ : Set (α → M)) :=
104-
⟨⊤, by
105-
ext
106-
simp⟩
162+
theorem definable_univ : A.Definable L (univ : Set (α → M)) := by
163+
simpa using (⊤ : L[[A]].Formula α).definable_withConstants
107164

108165
@[simp]
109166
theorem Definable.inter {f g : Set (α → M)} (hf : A.Definable L f) (hg : A.Definable L g) :
110167
A.Definable L (f ∩ g) := by
111168
rcases hf with ⟨φ, rfl⟩
112169
rcases hg with ⟨θ, rfl⟩
113-
refine ⟨φ ⊓ θ, ?_⟩
114-
ext
115-
simp
170+
simpa using (φ ⊓ θ).definable_withConstants
116171

117172
@[simp]
118173
theorem Definable.union {f g : Set (α → M)} (hf : A.Definable L f) (hg : A.Definable L g) :
119174
A.Definable L (f ∪ g) := by
120-
rcases hf with ⟨φ, hφ⟩
121-
rcases hg with ⟨θ, hθ⟩
122-
refine ⟨φ ⊔ θ, ?_⟩
123-
ext
124-
rw [hφ, hθ, mem_setOf_eq, Formula.realize_sup, mem_union, mem_setOf_eq, mem_setOf_eq]
175+
rcases hf with ⟨φ, rfl⟩
176+
rcases hg with ⟨θ, rfl⟩
177+
simpa using (φ ⊔ θ).definable_withConstants
125178

126179
theorem definable_finset_inf {ι : Type*} {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i))
127180
(s : Finset ι) : A.Definable L (s.inf f) := by
@@ -161,10 +214,8 @@ theorem definable_iUnion_of_finite {ι : Type*} [Finite ι] {f : ι → Set (α
161214

162215
@[simp]
163216
theorem Definable.compl {s : Set (α → M)} (hf : A.Definable L s) : A.Definable L sᶜ := by
164-
rcases hf with ⟨φ, hφ⟩
165-
refine ⟨φ.not, ?_⟩
166-
ext v
167-
rw [hφ, compl_setOf, mem_setOf, mem_setOf, Formula.realize_not]
217+
rcases hf with ⟨φ, rfl⟩
218+
simpa using (φ.not).definable_withConstants
168219

169220
@[simp]
170221
theorem Definable.sdiff {s t : Set (α → M)} (hs : A.Definable L s) (ht : A.Definable L t) :
@@ -177,9 +228,7 @@ theorem Definable.sdiff {s t : Set (α → M)} (hs : A.Definable L s) (ht : A.De
177228
theorem Definable.preimage_comp (f : α → β) {s : Set (α → M)} (h : A.Definable L s) :
178229
A.Definable L ((fun g : β → M => g ∘ f) ⁻¹' s) := by
179230
obtain ⟨φ, rfl⟩ := h
180-
refine ⟨φ.relabel f, ?_⟩
181-
ext
182-
simp only [Set.preimage_setOf_eq, mem_setOf_eq, Formula.realize_relabel]
231+
simpa using (φ.relabel f).definable_withConstants
183232

184233
theorem Definable.image_comp_equiv {s : Set (β → M)} (h : A.Definable L s) (f : α ≃ β) :
185234
A.Definable L ((fun g : β → M => g ∘ f) '' s) := by
@@ -278,19 +327,15 @@ theorem Definable.image_comp {s : Set (β → M)} (h : A.Definable L s) (f : α
278327
lemma Definable.exists_of_finite [Finite β] {S : Set ((α ⊕ β) → M)}
279328
(hS : A.Definable L S) :
280329
A.Definable L { v : α → M | ∃ u : β → M, Sum.elim v u ∈ S } := by
281-
obtain ⟨φ, hφ⟩ := hS
282-
exists φ.iExs β
283-
ext v
284-
simp [hφ]
330+
obtain ⟨φ, rfl⟩ := hS
331+
simpa using (φ.iExs β).definable_withConstants
285332

286333
/-- Finite universal quantifiers preserve definablity. -/
287334
lemma Definable.forall_of_finite [Finite β] {S : Set ((α ⊕ β) → M)}
288335
(hS : A.Definable L S) :
289336
A.Definable L { v : α → M | ∀ u : β → M, Sum.elim v u ∈ S } := by
290-
obtain ⟨φ, hφ⟩ := hS
291-
exists φ.iAlls β
292-
ext v
293-
simp [hφ]
337+
obtain ⟨φ, rfl⟩ := hS
338+
simpa using (φ.iAlls β).definable_withConstants
294339

295340
variable (L A)
296341

@@ -478,10 +523,7 @@ theorem definableFun_iff_empty_definableFun_with_params :
478523
@[fun_prop]
479524
theorem _root_.FirstOrder.Language.Term.definableFun_realize (t : L.Term α) :
480525
(∅ : Set M).DefinableFun L (t.realize) := by
481-
rw [empty_definableFun_iff]
482-
refine ⟨(t.relabel some).equal (Term.var none), ?_⟩
483-
ext v
484-
simp [tupleGraph]
526+
simpa using ((t.relabel some).equal (Term.var none)).definable
485527

486528
/-- A function symbol is a definable function. -/
487529
@[fun_prop]
@@ -591,9 +633,7 @@ def TermDefinable (f : (α → M) → M) : Prop :=
591633
theorem TermDefinable.definable_tupleGraph {f : (α → M) → M} (h : A.TermDefinable L f) :
592634
A.Definable L f.tupleGraph := by
593635
obtain ⟨φ, rfl⟩ := h
594-
use (φ.relabel some).equal (Term.var none)
595-
ext
596-
simp [Function.tupleGraph]
636+
simpa using ((φ.relabel some).equal (Term.var none)).definable_withConstants
597637

598638
variable {L} {A B} {f : (α → M) → M}
599639

Mathlib/ModelTheory/ElementarySubstructures.lean

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,9 @@ theorem closure_eq_self (hA : L.MeetsDefinable A) :
159159
closure L A = A := by
160160
refine Subset.antisymm ?_ subset_closure
161161
rw [coe_closure_eq_range_term_realize]
162-
intro x hx
163-
have : A.Definable₁ L {x} := by
164-
obtain ⟨t, rfl⟩ := hx
165-
use (Term.var 0).equal (t.relabel Sum.inl).varsToConstants
166-
simp [Set.ext_iff]
167-
exact singleton_inter_nonempty.mp <| hA _ (singleton_nonempty x) this
162+
rintro x ⟨t, rfl⟩
163+
exact singleton_inter_nonempty.mp <| hA _ (singleton_nonempty _) <|
164+
by simpa using ((Term.var 0).equal (t.relabel Sum.inl).varsToConstants).definable_withConstants
168165

169166
/-- The closure of a set meeting definable sets is an elementary substructure. -/
170167
theorem isElementary_closure (hA : L.MeetsDefinable A) :
@@ -174,20 +171,15 @@ theorem isElementary_closure (hA : L.MeetsDefinable A) :
174171
let D : Set M := {y : M | φ.Realize default (Fin.snoc (Subtype.val ∘ x) y)}
175172
have hD_ne : D.Nonempty := ⟨a,hφ⟩
176173
have hD : A.Definable₁ L D := by
177-
simp only [Definable₁, Definable, Fin.isValue]
178-
refine ⟨((L.lhomWithConstants A).onBoundedFormula φ).toFormula.relabel
179-
(Sum.elim Empty.elim id) |>.subst fun i => Fin.lastCases (Term.var 0)
180-
(fun j => (L.con ⟨x j, by
174+
apply (φ.definable_boundedSection).preimage_map
175+
simp only [DefinableMap]
176+
refine Fin.lastCases ?_ ?_
177+
· simp only [Fin.snoc_last]; fun_prop
178+
· intro i; simp only [Fin.snoc_castSucc];
179+
have : ↑(x i) ∈ A := by
181180
nth_rw 1 [← hA.closure_eq_self]
182-
simp only [Subtype.coe_prop]
183-
⟩).term) i, ?_⟩
184-
ext v
185-
simp only [Fin.isValue, mem_setOf_eq, Formula.relabel, Formula.Realize,
186-
BoundedFormula.realize_subst, BoundedFormula.realize_relabel, Nat.add_zero, Fin.castAdd_zero,
187-
Fin.cast_refl, Function.comp_id, Fin.natAdd_zero, D]
188-
rw [← Formula.Realize, BoundedFormula.realize_toFormula, LHom.realize_onBoundedFormula]
189-
congr! 1
190-
ext i; cases i using Fin.lastCases <;> simp
181+
simp
182+
fun_prop (disch := assumption)
191183
obtain ⟨b, hbD, hbA⟩ := hA D hD_ne hD
192184
exact ⟨⟨b, by rwa [← hA.closure_eq_self] at hbA⟩, hbD⟩
193185

0 commit comments

Comments
 (0)