Skip to content

Commit 463c019

Browse files
committed
refactor(ModelTheory): add lemma realize_exClosure_iff' and simplify proofs
Rename `realize_exClosure` to `realize_exClosure_iff` and add the new lemma `realize_exClosure_iff'` which gives an equivalent condition using a full variable assignment instead of only free variables. Use the new lemma to simplify: - `realize_exClosure_of_realize_equivSentence` - `exists_realize_equivSentence_iff_realize_exClosure` - `partialType_completeTheory_iff_finitelyRealizable` (first direction) - `partialTypeOver_iff_realizedIn_elementaryExtension`
1 parent 9947007 commit 463c019

2 files changed

Lines changed: 36 additions & 53 deletions

File tree

Mathlib/ModelTheory/PartialTypes.lean

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,14 @@ theorem partialType_completeTheory_iff_finitelyRealizable
230230
have hψN : ψ.Realize v := by
231231
simp only [Formula.realize_iInf, Subtype.forall, ψ]
232232
aesop
233-
have hψexN : ψ.exClosure.Realize N := by
234-
letI : (constantsOn α).Structure N := constantsOn.structure v
235-
exact Formula.realize_exClosure_of_realize_equivSentence
236-
((Formula.realize_equivSentence N ψ).2 hψN)
233+
have hψexN : ψ.exClosure.Realize N :=
234+
(Formula.realize_exClosure_iff'.2 ⟨v, hψN⟩)
237235
have hψexM : ψ.exClosure.Realize M :=
238236
((L.realize_iff_of_model_completeTheory M N ψ.exClosure).1 hψexN)
239-
obtain ⟨vM, hvM⟩ :=
240-
(Formula.exists_realize_equivSentence_iff_realize_exClosure.mpr hψexM)
241-
have hψM : ψ.Realize vM := by
242-
simpa [Equiv.symm_apply_apply] using
243-
(Formula.realize_equivSentence_symm M (Formula.equivSentence ψ) vM).mpr hvM
244-
exists vM
245-
aesop
237+
obtain ⟨vM, hψM⟩ := Formula.realize_exClosure_iff'.1 hψexM
238+
refine ⟨vM, fun φ hφ => ?_⟩
239+
simp only [Formula.realize_iInf, Subtype.forall, ψ] at hψM
240+
exact hψM φ hφ
246241
· intro h
247242
rw [partialType_iff_finitelyRealizable S]
248243
intro s hs
@@ -366,15 +361,14 @@ theorem partialTypeOver_iff_realizedIn_elementaryExtension
366361
∀ φ ∈ S,
367362
((L.lhomWithConstantsMap ((↑) : A → M)).onFormula φ).Realize v := by
368363
classical
364+
haveI : (LHom.constantsOnMap ((↑) : A → M)).IsExpansionOn M :=
365+
constantsOnMap_isExpansionOn rfl
366+
haveI : (L.lhomWithConstantsMap ((↑) : A → M)).IsExpansionOn M :=
367+
LHom.sumMap_isExpansionOn _ _ _
369368
constructor
370369
· intro hS
371370
let S' : Set (L[[M]].Formula α) := mapSet ((↑) : A → M) S
372-
haveI : (LHom.constantsOnMap ((↑) : A → M)).IsExpansionOn M :=
373-
constantsOnMap_isExpansionOn rfl
374-
haveI : (L.lhomWithConstantsMap ((↑) : A → M)).IsExpansionOn M :=
375-
LHom.sumMap_isExpansionOn _ _ _
376371
have hS' : ((L.elementaryDiagram M).IsConsistentWith S') := by
377-
change ((L[[M]].completeTheory M).IsConsistentWith S')
378372
simpa [S'] using
379373
(partialType_completeTheory_map ((↑) : A → M) hS)
380374
let p : (L.elementaryDiagram M).PartialType α := ofSet S' hS'
@@ -396,30 +390,17 @@ theorem partialTypeOver_iff_realizedIn_elementaryExtension
396390
have : ψ'.Realize v := by
397391
simp only [LHom.realize_onFormula, Formula.realize_iInf, Subtype.forall, ψ', ψ]
398392
intro φ hφ
399-
specialize h φ (mem_of_subset_of_mem hs hφ)
400-
simpa [ψ', ψ] using h
393+
simpa [ψ', ψ] using h φ (mem_of_subset_of_mem hs hφ)
401394
let ψ'' : L[[M]].Sentence := ψ'.exClosure
402395
have hψ'' : ψ''.Realize N := by
403-
simp only [Formula.realize_exClosure, ψ'']
404-
exists v ∘ (↑)
405-
exact (BoundedFormula.realize_restrictFreeVar'
406-
(s := (ψ'.freeVarFinset : Set α)) Set.Subset.rfl (v := v)).2 this
396+
rw [Formula.realize_exClosure_iff']
397+
exists v
407398
haveI : (L.lhomWithConstants M).IsExpansionOn ↑N :=
408399
LHom.isExpansionOn_reduct (L.lhomWithConstants M) N
409-
rw [realize_iff_of_model_completeTheory M N] at hψ''
410-
rw [Formula.realize_exClosure] at hψ''
400+
rw [realize_iff_of_model_completeTheory M N, Formula.realize_exClosure_iff'] at hψ''
411401
obtain ⟨w, hw⟩ := hψ''
412-
let vM : α → M := fun a =>
413-
if hmem : a ∈ ψ'.freeVarFinset then w ⟨a, hmem⟩ else Classical.choice inferInstance
414-
have hwEq : vM ∘ (↑) = w := by aesop
415-
haveI : (LHom.constantsOnMap ((↑) : A → M)).IsExpansionOn M :=
416-
constantsOnMap_isExpansionOn rfl
417-
haveI : (L.lhomWithConstantsMap ((↑) : A → M)).IsExpansionOn M :=
418-
LHom.sumMap_isExpansionOn _ _ _
419-
exists vM
420-
suffices hψ' : ψ'.Realize vM by
421-
simpa [ψ', ψ] using hψ'
422-
exact (BoundedFormula.realize_restrictFreeVar vM (congrFun (id (Eq.symm hwEq)))).mp hw
402+
exists w
403+
simpa [ψ', ψ] using hw
423404

424405
end PartialType
425406

Mathlib/ModelTheory/Semantics.lean

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -936,15 +936,28 @@ end BoundedFormula
936936
namespace Formula
937937

938938
@[simp]
939-
theorem realize_exClosure [DecidableEq α] (φ : L.Formula α) :
939+
theorem realize_exClosure_iff [DecidableEq α] {φ : L.Formula α} :
940940
φ.exClosure.Realize M ↔
941941
∃ v : φ.freeVarFinset → M, Formula.Realize (φ.restrictFreeVar id) v := by
942942
simp [Sentence.Realize, Formula.exClosure, Formula.realize_iExs]
943943

944+
theorem realize_exClosure_iff' [DecidableEq α] [Nonempty M] {φ : L.Formula α} :
945+
(φ.exClosure.Realize M) ↔ ∃ v : α → M, φ.Realize v := by
946+
rw [realize_exClosure_iff]
947+
constructor
948+
· rintro ⟨v, hv⟩
949+
let v' := fun a => if hmem : a ∈ φ.freeVarFinset
950+
then v ⟨a, hmem⟩ else Classical.choice inferInstance
951+
exists v'
952+
simpa [Formula.Realize, BoundedFormula.realize_restrictFreeVar v', v'] using hv
953+
· rintro ⟨v, hv⟩
954+
refine ⟨fun a => v a, ?_⟩
955+
simpa [Formula.Realize, BoundedFormula.realize_restrictFreeVar] using hv
956+
944957
theorem realize_exClosure_of_realize_equivSentence [DecidableEq α] [L[[α]].Structure M]
945958
[(L.lhomWithConstants α).IsExpansionOn M] {φ : L.Formula α}
946959
(h : (Formula.equivSentence φ).Realize M) : φ.exClosure.Realize M := by
947-
rw [Formula.realize_exClosure]
960+
rw [realize_exClosure_iff]
948961
exists fun a => (L.con (a : α) : M)
949962
simpa [Formula.Realize, BoundedFormula.realize_restrictFreeVar] using h
950963

@@ -953,22 +966,11 @@ theorem exists_realize_equivSentence_iff_realize_exClosure
953966
(∃ v : α → M,
954967
letI := (constantsOn.structure v);
955968
(Formula.equivSentence φ).Realize M) ↔ (φ.exClosure.Realize M) := by
956-
constructor
957-
· rintro ⟨v, hv⟩
958-
exact (Formula.realize_exClosure φ).mpr ⟨fun a => v a,
959-
(BoundedFormula.realize_restrictFreeVar (φ := φ) (f := id) (v := fun a => v a) (v' := v)
960-
(fun _ => rfl)).2
961-
(by simpa [Formula.Realize]
962-
using (realize_equivSentence_symm M (Formula.equivSentence φ) v).2 hv)⟩
963-
· intro h
964-
classical
965-
obtain ⟨v, hv⟩ := (Formula.realize_exClosure φ).1 h
966-
let v' := fun a => if hmem : a ∈ φ.freeVarFinset
967-
then v ⟨a, hmem⟩ else Classical.choice inferInstance
968-
exists v'
969-
refine (Formula.realize_equivSentence_symm M (Formula.equivSentence φ) v').mp ?_
970-
simpa [Equiv.symm_apply_apply, Formula.Realize] using
971-
(BoundedFormula.realize_restrictFreeVar v' (by grind)).1 hv
969+
have h (v : α → M) : (letI := (constantsOn.structure v); (Formula.equivSentence φ).Realize M) ↔
970+
φ.Realize v := by
971+
simpa [Equiv.symm_apply_apply] using
972+
(Formula.realize_equivSentence_symm M (Formula.equivSentence φ) v).symm
973+
simpa [h] using Formula.realize_exClosure_iff'.symm
972974

973975
end Formula
974976

0 commit comments

Comments
 (0)