l3lab/ntp-mathlib huggingface dataset:
/-- In characteristic zero if there is no torsion, to check that a family of roots form a root
system, we do not need to check that the coroots are stable under reflections since this follows
from the corresponding property for the roots. -/
def mk' [CharZero R] [NoZeroSMulDivisors R M]
    (p : PerfectPairing R M N)
    (root : ι ↪ M)
    (coroot : ι ↪ N)
    (hp : ∀ i, p.toLin (root i) (coroot i) = 2)
    (hs : ∀ i, MapsTo (preReflection (root i) (p.toLin.flip (coroot i))) (range root) (range root))
    (hsp : span R (range root) = ⊤) :
    RootSystem ι R M N where
  toPerfectPairing := p
  root := root
  coroot := coroot
  root_coroot_two := hp
  mapsTo_preReflection_root := hs
  span_eq_top := hsp
  mapsTo_preReflection_coroot := by
    rintro i - ⟨j, rfl⟩
    

Proof state:
case intro
ι : Type u_1
R : Type u_2
M : Type u_3
N : Type u_4
inst✝⁷ : _root_.Finite ι
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : Module R M
inst✝³ : AddCommGroup N
inst✝² : Module R N
P : RootSystem ι R M N
inst✝¹ : CharZero R
inst✝ : NoZeroSMulDivisors R M
p : PerfectPairing R M N
root : ι ↪ M
coroot : ι ↪ N
hp : ∀ (i : ι), (p.toLin (root i)) (coroot i) = 2
hs : ∀ (i : ι), MapsTo (⇑(preReflection (root i) ((LinearMap.flip p.toLin) (coroot i)))) (range ⇑root) (range ⇑root)
hsp : span R (range ⇑root) = ⊤
i j : ι
⊢ (preReflection (coroot i) (p.toLin (root i))) (coroot j) ∈ range ⇑coroot

Next tactic:
obtain ⟨k, h⟩ := hs i (mem_range_self j)
/-- In characteristic zero if there is no torsion, to check that a family of roots form a root
system, we do not need to check that the coroots are stable under reflections since this follows
from the corresponding property for the roots. -/
def mk' [CharZero R] [NoZeroSMulDivisors R M]
    (p : PerfectPairing R M N)
    (root : ι ↪ M)
    (coroot : ι ↪ N)
    (hp : ∀ i, p.toLin (root i) (coroot i) = 2)
    (hs : ∀ i, MapsTo (preReflection (root i) (p.toLin.flip (coroot i))) (range root) (range root))
    (hsp : span R (range root) = ⊤) :
    RootSystem ι R M N where
  toPerfectPairing := p
  root := root
  coroot := coroot
  root_coroot_two := hp
  mapsTo_preReflection_root := hs
  span_eq_top := hsp
  mapsTo_preReflection_coroot := by
    rintro i - ⟨j, rfl⟩
    obtain ⟨k, h⟩ := hs i (mem_range_self j)
    

Proof state:
case intro.intro
ι : Type u_1
R : Type u_2
M : Type u_3
N : Type u_4
inst✝⁷ : _root_.Finite ι
inst✝⁶ : CommRing R
inst✝⁵ : AddCommGroup M
inst✝⁴ : Module R M
inst✝³ : AddCommGroup N
inst✝² : Module R N
P : RootSystem ι R M N
inst✝¹ : CharZero R
inst✝ : NoZeroSMulDivisors R M
p : PerfectPairing R M N
root : ι ↪ M
coroot : ι ↪ N
hp : ∀ (i : ι), (p.toLin (root i)) (coroot i) = 2
hs : ∀ (i : ι), MapsTo (⇑(preReflection (root i) ((LinearMap.flip p.toLin) (coroot i)))) (range ⇑root) (range ⇑root)
hsp : span R (range ⇑root) = ⊤
i j k : ι
h : root k = (preReflection (root i) ((LinearMap.flip p.toLin) (coroot i))) (root j)
⊢ (preReflection (coroot i) (p.toLin (root i))) (coroot j) ∈ range ⇑coroot

Next tactic:
exact ⟨k, coroot_eq_coreflection_of_root_eq_of_span_eq_top' p root coroot hp hs hsp h⟩
theorem isSatisfiable_onTheory_iff {L' : Language.{w, w'}} {φ : L →ᴸ L'} (h : φ.Injective) :
    (φ.onTheory T).IsSatisfiable ↔ T.IsSatisfiable := by
  

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
L' : Language
φ : L →ᴸ L'
h : LHom.Injective φ
⊢ IsSatisfiable (LHom.onTheory φ T) ↔ IsSatisfiable T

Next tactic:
classical
    refine' ⟨isSatisfiable_of_isSatisfiable_onTheory φ, fun h' => _⟩
    haveI : Inhabited h'.some := Classical.inhabited_of_nonempty'
    exact Model.isSatisfiable (h'.some.defaultExpansion h)
theorem isSatisfiable_onTheory_iff {L' : Language.{w, w'}} {φ : L →ᴸ L'} (h : φ.Injective) :
    (φ.onTheory T).IsSatisfiable ↔ T.IsSatisfiable := by
  classical
    

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
L' : Language
φ : L →ᴸ L'
h : LHom.Injective φ
⊢ IsSatisfiable (LHom.onTheory φ T) ↔ IsSatisfiable T

Next tactic:
refine' ⟨isSatisfiable_of_isSatisfiable_onTheory φ, fun h' => _⟩
theorem isSatisfiable_onTheory_iff {L' : Language.{w, w'}} {φ : L →ᴸ L'} (h : φ.Injective) :
    (φ.onTheory T).IsSatisfiable ↔ T.IsSatisfiable := by
  classical
    refine' ⟨isSatisfiable_of_isSatisfiable_onTheory φ, fun h' => _⟩
    

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
L' : Language
φ : L →ᴸ L'
h : LHom.Injective φ
h' : IsSatisfiable T
⊢ IsSatisfiable (LHom.onTheory φ T)

Next tactic:
haveI : Inhabited h'.some := Classical.inhabited_of_nonempty'
theorem isSatisfiable_onTheory_iff {L' : Language.{w, w'}} {φ : L →ᴸ L'} (h : φ.Injective) :
    (φ.onTheory T).IsSatisfiable ↔ T.IsSatisfiable := by
  classical
    refine' ⟨isSatisfiable_of_isSatisfiable_onTheory φ, fun h' => _⟩
    haveI : Inhabited h'.some := Classical.inhabited_of_nonempty'
    

Proof state:
L : Language
T : Theory L
α : Type w
n : ℕ
T' : Theory L
L' : Language
φ : L →ᴸ L'
h : LHom.Injective φ
h' : IsSatisfiable T
this : Inhabited ↑(Nonempty.some h')
⊢ IsSatisfiable (LHom.onTheory φ T)

Next tactic:
exact Model.isSatisfiable (h'.some.defaultExpansion h)
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
⊢ IsSatisfiable T

Next tactic:
classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
        simp only [Finset.coe_map, Function.Embedding.coe_subtype, Set.mem_image, Finset.mem_coe,
          Subtype.exists, Subtype.coe_mk, exists_and_right, exists_eq_right]
        exact ⟨hφ, h' (Finset.mem_singleton_self _)⟩
      exact ⟨ModelType.of T M'⟩
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
⊢ IsSatisfiable T

Next tactic:
set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
⊢ IsSatisfiable T

Next tactic:
let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
⊢ IsSatisfiable T

Next tactic:
have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
        simp only [Finset.coe_map, Function.Embedding.coe_subtype, Set.mem_image, Finset.mem_coe,
          Subtype.exists, Subtype.coe_mk, exists_and_right, exists_eq_right]
        exact ⟨hφ, h' (Finset.mem_singleton_self _)⟩
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
⊢ M' ⊨ T

Next tactic:
refine' ⟨fun φ hφ => _⟩
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
φ : Sentence L
hφ : φ ∈ T
⊢ M' ⊨ φ

Next tactic:
rw [Ultraproduct.sentence_realize]
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
φ : Sentence L
hφ : φ ∈ T
⊢ ∀ᶠ (a : Finset ↑T) in ↑(Ultrafilter.of Filter.atTop), M a ⊨ φ

Next tactic:
refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
        

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
φ : Sentence L
hφ : φ ∈ T
s : Finset ↑T
h' : s ≥ {{ val := φ, property := hφ }}
⊢ φ ∈ ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) s)

Next tactic:
simp only [Finset.coe_map, Function.Embedding.coe_subtype, Set.mem_image, Finset.mem_coe,
          Subtype.exists, Subtype.coe_mk, exists_and_right, exists_eq_right]
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
        simp only [Finset.coe_map, Function.Embedding.coe_subtype, Set.mem_image, Finset.mem_coe,
          Subtype.exists, Subtype.coe_mk, exists_and_right, exists_eq_right]
        

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
φ : Sentence L
hφ : φ ∈ T
s : Finset ↑T
h' : s ≥ {{ val := φ, property := hφ }}
⊢ ∃ (x : φ ∈ T), { val := φ, property := (_ : φ ∈ T) } ∈ s

Next tactic:
exact ⟨hφ, h' (Finset.mem_singleton_self _)⟩
/-- The **Compactness Theorem of first-order logic**: A theory is satisfiable if and only if it is
finitely satisfiable. -/
theorem isSatisfiable_iff_isFinitelySatisfiable {T : L.Theory} :
    T.IsSatisfiable ↔ T.IsFinitelySatisfiable :=
  ⟨Theory.IsSatisfiable.isFinitelySatisfiable, fun h => by
    classical
      set M : Finset T → Type max u v := fun T0 : Finset T =>
        (h (T0.map (Function.Embedding.subtype fun x => x ∈ T)) T0.map_subtype_subset).some.Carrier
      let M' := Filter.Product (Ultrafilter.of (Filter.atTop : Filter (Finset T))) M
      have h' : M' ⊨ T := by
        refine' ⟨fun φ hφ => _⟩
        rw [Ultraproduct.sentence_realize]
        refine'
          Filter.Eventually.filter_mono (Ultrafilter.of_le _)
            (Filter.eventually_atTop.2
              ⟨{⟨φ, hφ⟩}, fun s h' =>
                Theory.realize_sentence_of_mem (s.map (Function.Embedding.subtype fun x => x ∈ T))
                  _⟩)
        simp only [Finset.coe_map, Function.Embedding.coe_subtype, Set.mem_image, Finset.mem_coe,
          Subtype.exists, Subtype.coe_mk, exists_and_right, exists_eq_right]
        exact ⟨hφ, h' (Finset.mem_singleton_self _)⟩
      

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
h : IsFinitelySatisfiable T
M : Finset ↑T → Type (max u v) :=
  fun T0 => ↑(Nonempty.some (_ : IsSatisfiable ↑(Finset.map (Function.Embedding.subtype fun x => x ∈ T) T0)))
M' : Type (max u v) := Filter.Product (↑(Ultrafilter.of Filter.atTop)) M
h' : M' ⊨ T
⊢ IsSatisfiable T

Next tactic:
exact ⟨ModelType.of T M'⟩
theorem isSatisfiable_directed_union_iff {ι : Type*} [Nonempty ι] {T : ι → L.Theory}
    (h : Directed (· ⊆ ·) T) : Theory.IsSatisfiable (⋃ i, T i) ↔ ∀ i, (T i).IsSatisfiable := by
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' : Theory L
ι : Type u_1
inst✝ : Nonempty ι
T : ι → Theory L
h : Directed (fun x x_1 => x ⊆ x_1) T
⊢ IsSatisfiable (⋃ i, T i) ↔ ∀ (i : ι), IsSatisfiable (T i)

Next tactic:
refine' ⟨fun h' i => h'.mono (Set.subset_iUnion _ _), fun h' => _⟩
theorem isSatisfiable_directed_union_iff {ι : Type*} [Nonempty ι] {T : ι → L.Theory}
    (h : Directed (· ⊆ ·) T) : Theory.IsSatisfiable (⋃ i, T i) ↔ ∀ i, (T i).IsSatisfiable := by
  refine' ⟨fun h' i => h'.mono (Set.subset_iUnion _ _), fun h' => _⟩
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' : Theory L
ι : Type u_1
inst✝ : Nonempty ι
T : ι → Theory L
h : Directed (fun x x_1 => x ⊆ x_1) T
h' : ∀ (i : ι), IsSatisfiable (T i)
⊢ IsSatisfiable (⋃ i, T i)

Next tactic:
rw [isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
theorem isSatisfiable_directed_union_iff {ι : Type*} [Nonempty ι] {T : ι → L.Theory}
    (h : Directed (· ⊆ ·) T) : Theory.IsSatisfiable (⋃ i, T i) ↔ ∀ i, (T i).IsSatisfiable := by
  refine' ⟨fun h' i => h'.mono (Set.subset_iUnion _ _), fun h' => _⟩
  rw [isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' : Theory L
ι : Type u_1
inst✝ : Nonempty ι
T : ι → Theory L
h : Directed (fun x x_1 => x ⊆ x_1) T
h' : ∀ (i : ι), IsSatisfiable (T i)
⊢ ∀ (T0 : Finset (Sentence L)), ↑T0 ⊆ ⋃ i, T i → IsSatisfiable ↑T0

Next tactic:
intro T0 hT0
theorem isSatisfiable_directed_union_iff {ι : Type*} [Nonempty ι] {T : ι → L.Theory}
    (h : Directed (· ⊆ ·) T) : Theory.IsSatisfiable (⋃ i, T i) ↔ ∀ i, (T i).IsSatisfiable := by
  refine' ⟨fun h' i => h'.mono (Set.subset_iUnion _ _), fun h' => _⟩
  rw [isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  intro T0 hT0
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' : Theory L
ι : Type u_1
inst✝ : Nonempty ι
T : ι → Theory L
h : Directed (fun x x_1 => x ⊆ x_1) T
h' : ∀ (i : ι), IsSatisfiable (T i)
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ ⋃ i, T i
⊢ IsSatisfiable ↑T0

Next tactic:
obtain ⟨i, hi⟩ := h.exists_mem_subset_of_finset_subset_biUnion hT0
theorem isSatisfiable_directed_union_iff {ι : Type*} [Nonempty ι] {T : ι → L.Theory}
    (h : Directed (· ⊆ ·) T) : Theory.IsSatisfiable (⋃ i, T i) ↔ ∀ i, (T i).IsSatisfiable := by
  refine' ⟨fun h' i => h'.mono (Set.subset_iUnion _ _), fun h' => _⟩
  rw [isSatisfiable_iff_isFinitelySatisfiable, IsFinitelySatisfiable]
  intro T0 hT0
  obtain ⟨i, hi⟩ := h.exists_mem_subset_of_finset_subset_biUnion hT0
  

Proof state:
case intro
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' : Theory L
ι : Type u_1
inst✝ : Nonempty ι
T : ι → Theory L
h : Directed (fun x x_1 => x ⊆ x_1) T
h' : ∀ (i : ι), IsSatisfiable (T i)
T0 : Finset (Sentence L)
hT0 : ↑T0 ⊆ ⋃ i, T i
i : ι
hi : ↑T0 ⊆ T i
⊢ IsSatisfiable ↑T0

Next tactic:
exact (h' i).mono hi
theorem isSatisfiable_union_distinctConstantsTheory_of_card_le (T : L.Theory) (s : Set α)
    (M : Type w') [Nonempty M] [L.Structure M] [M ⊨ T]
    (h : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} #M) :
    ((L.lhomWithConstants α).onTheory T ∪ L.distinctConstantsTheory s).IsSatisfiable := by
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
s : Set α
M : Type w'
inst✝² : Nonempty M
inst✝¹ : Structure L M
inst✝ : M ⊨ T
h : lift.{w', w} #↑s ≤ lift.{w, w'} #M
⊢ IsSatisfiable (LHom.onTheory (lhomWithConstants L α) T ∪ distinctConstantsTheory L s)

Next tactic:
haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance
theorem isSatisfiable_union_distinctConstantsTheory_of_card_le (T : L.Theory) (s : Set α)
    (M : Type w') [Nonempty M] [L.Structure M] [M ⊨ T]
    (h : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} #M) :
    ((L.lhomWithConstants α).onTheory T ∪ L.distinctConstantsTheory s).IsSatisfiable := by
  haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
s : Set α
M : Type w'
inst✝² : Nonempty M
inst✝¹ : Structure L M
inst✝ : M ⊨ T
h : lift.{w', w} #↑s ≤ lift.{w, w'} #M
this : Inhabited M
⊢ IsSatisfiable (LHom.onTheory (lhomWithConstants L α) T ∪ distinctConstantsTheory L s)

Next tactic:
rw [Cardinal.lift_mk_le'] at h
theorem isSatisfiable_union_distinctConstantsTheory_of_card_le (T : L.Theory) (s : Set α)
    (M : Type w') [Nonempty M] [L.Structure M] [M ⊨ T]
    (h : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} #M) :
    ((L.lhomWithConstants α).onTheory T ∪ L.distinctConstantsTheory s).IsSatisfiable := by
  haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance
  rw [Cardinal.lift_mk_le'] at h
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
s : Set α
M : Type w'
inst✝² : Nonempty M
inst✝¹ : Structure L M
inst✝ : M ⊨ T
h : Nonempty (↑s ↪ M)
this : Inhabited M
⊢ IsSatisfiable (LHom.onTheory (lhomWithConstants L α) T ∪ distinctConstantsTheory L s)

Next tactic:
letI : (constantsOn α).Structure M := constantsOn.structure (Function.extend (↑) h.some default)
theorem isSatisfiable_union_distinctConstantsTheory_of_card_le (T : L.Theory) (s : Set α)
    (M : Type w') [Nonempty M] [L.Structure M] [M ⊨ T]
    (h : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} #M) :
    ((L.lhomWithConstants α).onTheory T ∪ L.distinctConstantsTheory s).IsSatisfiable := by
  haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance
  rw [Cardinal.lift_mk_le'] at h
  letI : (constantsOn α).Structure M := constantsOn.structure (Function.extend (↑) h.some default)
  

Proof state:
L : Language
T✝ : Theory L
α : Type w
n : ℕ
T' T : Theory L
s : Set α
M : Type w'
inst✝² : Nonempty M
inst✝¹ : Structure L M
inst✝ : M ⊨ T
h : Nonempty (↑s ↪ M)
this✝ : Inhabited M
this : Structure (constantsOn α) M := constantsOn.structure (Function.extend Subtype.val (⇑(Nonempty.some h)) default)
⊢ IsSatisfiable (LHom.onTheory (lhomWithConstants L α) T ∪ distinctConstantsTheory L s)

Next tactic:
have : M ⊨ (L.lhomWithConstants α).onTheory T ∪ L.distinctConstantsTheory s := by
    refine' ((LHom.onTheory_model _ _).2 inferInstance).union _
    rw [model_distinctConstantsTheory]
    refine' fun a as b bs ab => _
    rw [← Subtype.coe_mk a as, ← Subtype.coe_mk b bs, ← Subtype.ext_iff]
    exact
      h.some.injective
        ((Subtype.coe_injective.extend_apply h.some default ⟨a, as⟩).symm.trans
          (ab.trans (Subtype.coe_injective.extend_apply h.some default ⟨b, bs⟩)))