Skip to content

Commit cb6040d

Browse files
committed
feat(ModelTheory/Satisfiability): Fix universe on ModelsBoundedFormula, derive consequences for models in all universes (#16676)
Redefines `ModelsBoundedFormula` to require a formula to be true in all models of a higher universe Derives that `ModelsBoundedFormula` implies a formula is true in models in all universes from properties of satisfiability (ultimately derived from Löwenheim-Skolem)
1 parent 00efa9f commit cb6040d

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

Mathlib/ModelTheory/Satisfiability.lean

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ variable (T)
281281
/-- A theory models a (bounded) formula when any of its nonempty models realizes that formula on all
282282
inputs. -/
283283
def ModelsBoundedFormula (φ : L.BoundedFormula α n) : Prop :=
284-
∀ (M : ModelType.{u, v, max u v} T) (v : α → M) (xs : Fin n → M), φ.Realize v xs
284+
∀ (M : ModelType.{u, v, max u v w} T) (v : α → M) (xs : Fin n → M), φ.Realize v xs
285285

286286
-- Porting note: In Lean3 it was `⊨` but ambiguous.
287287
@[inherit_doc FirstOrder.Language.Theory.ModelsBoundedFormula]
@@ -290,7 +290,7 @@ infixl:51 " ⊨ᵇ " => ModelsBoundedFormula -- input using \|= or \vDash, but n
290290
variable {T}
291291

292292
theorem models_formula_iff {φ : L.Formula α} :
293-
T ⊨ᵇ φ ↔ ∀ (M : ModelType.{u, v, max u v} T) (v : α → M), φ.Realize v :=
293+
T ⊨ᵇ φ ↔ ∀ (M : ModelType.{u, v, max u v w} T) (v : α → M), φ.Realize v :=
294294
forall_congr' fun _ => forall_congr' fun _ => Unique.forall_iff
295295

296296
theorem models_sentence_iff {φ : L.Sentence} : T ⊨ᵇ φ ↔ ∀ M : ModelType.{u, v, max u v} T, M ⊨ φ :=
@@ -327,12 +327,47 @@ theorem ModelsBoundedFormula.realize_sentence {φ : L.Sentence} (h : T ⊨ᵇ φ
327327
exact ⟨h, inferInstance⟩
328328
exact Model.isSatisfiable M
329329

330+
theorem models_formula_iff_onTheory_models_equivSentence {φ : L.Formula α} :
331+
T ⊨ᵇ φ ↔ (L.lhomWithConstants α).onTheory T ⊨ᵇ Formula.equivSentence φ := by
332+
refine ⟨fun h => models_sentence_iff.2 (fun M => ?_),
333+
fun h => models_formula_iff.2 (fun M v => ?_)⟩
334+
· letI := (L.lhomWithConstants α).reduct M
335+
have : (L.lhomWithConstants α).IsExpansionOn M := LHom.isExpansionOn_reduct _ _
336+
-- why doesn't that instance just work?
337+
rw [Formula.realize_equivSentence]
338+
have : M ⊨ T := (LHom.onTheory_model _ _).1 M.is_model -- why isn't M.is_model inferInstance?
339+
let M' := Theory.ModelType.of T M
340+
exact h M' (fun a => (L.con a : M)) _
341+
· letI : (constantsOn α).Structure M := constantsOn.structure v
342+
have : M ⊨ (L.lhomWithConstants α).onTheory T := (LHom.onTheory_model _ _).2 inferInstance
343+
exact (Formula.realize_equivSentence _ _).1 (h.realize_sentence M)
344+
345+
theorem ModelsBoundedFormula.realize_formula {φ : L.Formula α} (h : T ⊨ᵇ φ) (M : Type*)
346+
[L.Structure M] [M ⊨ T] [Nonempty M] {v : α → M} : φ.Realize v := by
347+
rw [models_formula_iff_onTheory_models_equivSentence] at h
348+
letI : (constantsOn α).Structure M := constantsOn.structure v
349+
have : M ⊨ (L.lhomWithConstants α).onTheory T := (LHom.onTheory_model _ _).2 inferInstance
350+
exact (Formula.realize_equivSentence _ _).1 (h.realize_sentence M)
351+
352+
theorem models_toFormula_iff {φ : L.BoundedFormula α n} : T ⊨ᵇ φ.toFormula ↔ T ⊨ᵇ φ := by
353+
refine ⟨fun h M v xs => ?_, ?_⟩
354+
· have h' : φ.toFormula.Realize (Sum.elim v xs) := h.realize_formula M
355+
simp only [BoundedFormula.realize_toFormula, Sum.elim_comp_inl, Sum.elim_comp_inr] at h'
356+
exact h'
357+
· simp only [models_formula_iff, BoundedFormula.realize_toFormula]
358+
exact fun h M v => h M _ _
359+
360+
theorem ModelsBoundedFormula.realize_boundedFormula
361+
{φ : L.BoundedFormula α n} (h : T ⊨ᵇ φ) (M : Type*)
362+
[L.Structure M] [M ⊨ T] [Nonempty M] {v : α → M} {xs : Fin n → M} : φ.Realize v xs := by
363+
have h' : φ.toFormula.Realize (Sum.elim v xs) := (models_toFormula_iff.2 h).realize_formula M
364+
simp only [BoundedFormula.realize_toFormula, Sum.elim_comp_inl, Sum.elim_comp_inr] at h'
365+
exact h'
366+
330367
theorem models_of_models_theory {T' : L.Theory}
331368
(h : ∀ φ : L.Sentence, φ ∈ T' → T ⊨ᵇ φ)
332-
{φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := by
333-
simp only [models_sentence_iff] at h
334-
intro M
335-
have hM : M ⊨ T' := T'.model_iff.2 (fun ψ hψ => h ψ hψ M)
369+
{φ : L.Formula α} (hφ : T' ⊨ᵇ φ) : T ⊨ᵇ φ := fun M => by
370+
have hM : M ⊨ T' := T'.model_iff.2 (fun ψ hψ => (h ψ hψ).realize_sentence M)
336371
let M' : ModelType T' := ⟨M⟩
337372
exact hφ M'
338373

@@ -429,16 +464,21 @@ theorem SemanticallyEquivalent.trans {φ ψ θ : L.BoundedFormula α n}
429464
rw [BoundedFormula.realize_iff] at *
430465
exact ⟨h2'.1 ∘ h1'.1, h1'.2 ∘ h2'.2
431466

432-
theorem SemanticallyEquivalent.realize_bd_iff {φ ψ : L.BoundedFormula α n} {M : Type max u v}
433-
[Nonempty M] [L.Structure M] [T.Model M] (h : T.SemanticallyEquivalent φ ψ)
467+
theorem SemanticallyEquivalent.realize_bd_iff {φ ψ : L.BoundedFormula α n} {M : Type*}
468+
[Nonempty M] [L.Structure M] [M ⊨ T] (h : T.SemanticallyEquivalent φ ψ)
434469
{v : α → M} {xs : Fin n → M} : φ.Realize v xs ↔ ψ.Realize v xs :=
435-
BoundedFormula.realize_iff.1 (h (ModelType.of T M) v xs)
470+
BoundedFormula.realize_iff.1 (h.realize_boundedFormula M)
436471

437-
theorem SemanticallyEquivalent.realize_iff {φ ψ : L.Formula α} {M : Type max u v} [Nonempty M]
438-
[L.Structure M] (_hM : T.Model M) (h : T.SemanticallyEquivalent φ ψ) {v : α → M} :
472+
theorem SemanticallyEquivalent.realize_iff {φ ψ : L.Formula α} {M : Type*} [Nonempty M]
473+
[L.Structure M] [M ⊨ T] (h : T.SemanticallyEquivalent φ ψ) {v : α → M} :
439474
φ.Realize v ↔ ψ.Realize v :=
440475
h.realize_bd_iff
441476

477+
theorem SemanticallyEquivalent.models_sentence_iff {φ ψ : L.Sentence} {M : Type*} [Nonempty M]
478+
[L.Structure M] [M ⊨ T] (h : T.SemanticallyEquivalent φ ψ) :
479+
M ⊨ φ ↔ M ⊨ ψ :=
480+
h.realize_iff
481+
442482
/-- Semantic equivalence forms an equivalence relation on formulas. -/
443483
def semanticallyEquivalentSetoid (T : L.Theory) : Setoid (L.BoundedFormula α n) where
444484
r := SemanticallyEquivalent T

0 commit comments

Comments
 (0)