Skip to content

Commit b2d08c9

Browse files
committed
feat(ModelThoery): add exClosure definition for first-order formulas
1 parent 5a2fd49 commit b2d08c9

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Mathlib/ModelTheory/Semantics.lean

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

903903
end BoundedFormula
904904

905+
namespace Formula
906+
907+
@[simp]
908+
theorem realize_exClosure [DecidableEq α] (φ : L.Formula α) :
909+
φ.exClosure.Realize M ↔
910+
∃ v : φ.freeVarFinset → M, Formula.Realize (φ.restrictFreeVar id) v := by
911+
simp [Sentence.Realize, Formula.exClosure, Formula.realize_iExs]
912+
913+
theorem realize_exClosure_of_realize_equivSentence [DecidableEq α] [L[[α]].Structure M]
914+
[(L.lhomWithConstants α).IsExpansionOn M] {φ : L.Formula α}
915+
(h : (Formula.equivSentence φ).Realize M) : φ.exClosure.Realize M := by
916+
rw [Formula.realize_exClosure]
917+
exists fun a => (L.con (a : α) : M)
918+
apply (BoundedFormula.realize_restrictFreeVar'
919+
(s := (φ.freeVarFinset : Set α)) Set.Subset.rfl
920+
(v := fun a => (L.con a : M))).2
921+
exact (φ.realize_equivSentence M).1 h
922+
923+
theorem exists_realize_equivSentence_of_realize_exClosure [DecidableEq α] [Nonempty M]
924+
{φ : L.Formula α} (h : φ.exClosure.Realize (M := M)) :
925+
∃ v : α → M,
926+
@Sentence.Realize _ M (@Language.withConstantsStructure L M _ α (constantsOn.structure v))
927+
(Formula.equivSentence φ) := by
928+
classical
929+
obtain ⟨v, hv⟩ := (φ.realize_exClosure (M := M)).1 h
930+
let v' : α → M := fun a =>
931+
if hmem : a ∈ φ.freeVarFinset then v ⟨a, hmem⟩ else Classical.choice inferInstance
932+
exists v'
933+
have hvEq : v' ∘ (↑) = v := by aesop
934+
have hv' : Formula.Realize (φ.restrictFreeVar id) (v' ∘ (↑)) := by
935+
simp_all only [realize_exClosure]
936+
have hφ : φ.Realize v' := by
937+
apply
938+
(BoundedFormula.realize_restrictFreeVar' (s := (φ.freeVarFinset : Set α))
939+
Set.Subset.rfl).1
940+
simpa [Set.inclusion_eq_id] using hv'
941+
exact
942+
(Formula.realize_equivSentence_symm M (Formula.equivSentence φ) v').1 (by simpa)
943+
944+
end Formula
945+
905946
namespace StrongHomClass
906947

907948
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)