Skip to content

Commit 1ded3d6

Browse files
NoneMoreReemMelamed
authored andcommitted
feat(ModelTheory): add exClosure definition for first-order formulas (leanprover-community#36667)
Prepare for moving realizations between elementarily equivalent structures. Co-authored-by: NoneMore <hellgoingup@outlook.com>
1 parent 482e6c8 commit 1ded3d6

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

Mathlib/ModelTheory/Semantics.lean

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,45 @@ theorem realize_iExsUnique [Finite γ] {φ : L.Formula (α ⊕ γ)} {v : α →
933933

934934
end BoundedFormula
935935

936+
namespace Formula
937+
938+
@[simp]
939+
theorem realize_exClosure [DecidableEq α] (φ : L.Formula α) :
940+
φ.exClosure.Realize M ↔
941+
∃ v : φ.freeVarFinset → M, Formula.Realize (φ.restrictFreeVar id) v := by
942+
simp [Sentence.Realize, Formula.exClosure, Formula.realize_iExs]
943+
944+
theorem realize_exClosure_of_realize_equivSentence [DecidableEq α] [L[[α]].Structure M]
945+
[(L.lhomWithConstants α).IsExpansionOn M] {φ : L.Formula α}
946+
(h : (Formula.equivSentence φ).Realize M) : φ.exClosure.Realize M := by
947+
rw [Formula.realize_exClosure]
948+
exists fun a => (L.con (a : α) : M)
949+
simpa [Formula.Realize, BoundedFormula.realize_restrictFreeVar] using h
950+
951+
theorem exists_realize_equivSentence_iff_realize_exClosure
952+
[DecidableEq α] [Nonempty M] {φ : L.Formula α} :
953+
(∃ v : α → M,
954+
letI := (constantsOn.structure v);
955+
(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
972+
973+
end Formula
974+
936975
namespace StrongHomClass
937976

938977
variable {F : Type*} [EquivLike F M N] [StrongHomClass L F M N] (g : F)

Mathlib/ModelTheory/Syntax.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,12 @@ noncomputable def iExsUnique [Finite β] (φ : L.Formula (α ⊕ β)) : L.Formul
784784
((φ.relabel (fun a => Sum.elim (.inl ∘ .inl) .inr a)).imp <|
785785
.iInf fun g => Term.equal (var (.inr g)) (var (.inl (.inr g))))
786786

787+
variable [DecidableEq α] in
788+
/-- `exClosure φ` is the sentence asserting that there exist values for all free variables of `φ`
789+
such that `φ` holds. -/
790+
noncomputable def exClosure (φ : L.Formula α) : L.Sentence :=
791+
iExs φ.freeVarFinset (Formula.relabel Sum.inr (φ.restrictFreeVar id))
792+
787793
/-- The biimplication between formulas, as a formula. -/
788794
protected nonrec abbrev iff (φ ψ : L.Formula α) : L.Formula α :=
789795
φ.iff ψ

0 commit comments

Comments
 (0)