l3lab/ntp-mathlib huggingface dataset:
theorem card_functions_sum_skolem₁ :
    #(Σ n, (L.sum L.skolem₁).Functions n) = #(Σ n, L.BoundedFormula Empty (n + 1)) := by
  simp only [card_functions_sum, skolem₁_Functions, mk_sigma, sum_add_distrib']
  conv_lhs => enter [2, 1, i]; rw [lift_id'.{u, v}]
  rw [add_comm, add_eq_max, max_eq_left]
  · refine' sum_le_sum _ _ fun n => _
    rw [← lift_le.{_, max u v}, lift_lift, lift_mk_le.{v}]
    refine' ⟨⟨fun f => (func f default).bdEqual (func f default), fun f g h => _⟩⟩
    rcases h with ⟨rfl, ⟨rfl⟩⟩
    

Proof state:
case refl
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
n : ℕ
f : Functions L n
⊢ f = f

Next tactic:
rfl
theorem card_functions_sum_skolem₁ :
    #(Σ n, (L.sum L.skolem₁).Functions n) = #(Σ n, L.BoundedFormula Empty (n + 1)) := by
  simp only [card_functions_sum, skolem₁_Functions, mk_sigma, sum_add_distrib']
  conv_lhs => enter [2, 1, i]; rw [lift_id'.{u, v}]
  rw [add_comm, add_eq_max, max_eq_left]
  · refine' sum_le_sum _ _ fun n => _
    rw [← lift_le.{_, max u v}, lift_lift, lift_mk_le.{v}]
    refine' ⟨⟨fun f => (func f default).bdEqual (func f default), fun f g h => _⟩⟩
    rcases h with ⟨rfl, ⟨rfl⟩⟩
    rfl
  · 

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ ℵ₀ ≤ sum fun i => #(BoundedFormula L Empty (i + 1))

Next tactic:
rw [← mk_sigma]
theorem card_functions_sum_skolem₁ :
    #(Σ n, (L.sum L.skolem₁).Functions n) = #(Σ n, L.BoundedFormula Empty (n + 1)) := by
  simp only [card_functions_sum, skolem₁_Functions, mk_sigma, sum_add_distrib']
  conv_lhs => enter [2, 1, i]; rw [lift_id'.{u, v}]
  rw [add_comm, add_eq_max, max_eq_left]
  · refine' sum_le_sum _ _ fun n => _
    rw [← lift_le.{_, max u v}, lift_lift, lift_mk_le.{v}]
    refine' ⟨⟨fun f => (func f default).bdEqual (func f default), fun f g h => _⟩⟩
    rcases h with ⟨rfl, ⟨rfl⟩⟩
    rfl
  · rw [← mk_sigma]
    

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ ℵ₀ ≤ #((i : ℕ) × BoundedFormula L Empty (i + 1))

Next tactic:
exact infinite_iff.1 (Infinite.of_injective (fun n => ⟨n, ⊥⟩) fun x y xy =>
      (Sigma.mk.inj_iff.1 xy).1)
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ #((n : ℕ) × Functions (Language.sum L (skolem₁ L)) n) ≤ max ℵ₀ (card L)

Next tactic:
rw [card_functions_sum_skolem₁]
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  rw [card_functions_sum_skolem₁]
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ #((n : ℕ) × BoundedFormula L Empty (n + 1)) ≤ max ℵ₀ (card L)

Next tactic:
trans #(Σ n, L.BoundedFormula Empty n)
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  rw [card_functions_sum_skolem₁]
  trans #(Σ n, L.BoundedFormula Empty n)
  · 

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ #((n : ℕ) × BoundedFormula L Empty (n + 1)) ≤ #((n : ℕ) × BoundedFormula L Empty n)

Next tactic:
exact
      ⟨⟨Sigma.map Nat.succ fun _ => id,
          Nat.succ_injective.sigma_map fun _ => Function.injective_id⟩⟩
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  rw [card_functions_sum_skolem₁]
  trans #(Σ n, L.BoundedFormula Empty n)
  · exact
      ⟨⟨Sigma.map Nat.succ fun _ => id,
          Nat.succ_injective.sigma_map fun _ => Function.injective_id⟩⟩
  · 

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ #((n : ℕ) × BoundedFormula L Empty n) ≤ max ℵ₀ (card L)

Next tactic:
refine' _root_.trans BoundedFormula.card_le (lift_le.{max u v}.1 _)
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  rw [card_functions_sum_skolem₁]
  trans #(Σ n, L.BoundedFormula Empty n)
  · exact
      ⟨⟨Sigma.map Nat.succ fun _ => id,
          Nat.succ_injective.sigma_map fun _ => Function.injective_id⟩⟩
  · refine' _root_.trans BoundedFormula.card_le (lift_le.{max u v}.1 _)
    

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ lift.{max u v, max u v} (max ℵ₀ (lift.{max u v, 0} #Empty + lift.{0, max u v} (card L))) ≤
    lift.{max u v, max u v} (max ℵ₀ (card L))

Next tactic:
simp only [mk_empty, lift_zero, lift_uzero, zero_add]
theorem card_functions_sum_skolem₁_le : #(Σ n, (L.sum L.skolem₁).Functions n) ≤ max ℵ₀ L.card := by
  rw [card_functions_sum_skolem₁]
  trans #(Σ n, L.BoundedFormula Empty n)
  · exact
      ⟨⟨Sigma.map Nat.succ fun _ => id,
          Nat.succ_injective.sigma_map fun _ => Function.injective_id⟩⟩
  · refine' _root_.trans BoundedFormula.card_le (lift_le.{max u v}.1 _)
    simp only [mk_empty, lift_zero, lift_uzero, zero_add]
    

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ lift.{max u v, max u v} (max ℵ₀ (card L)) ≤ lift.{max u v, max u v} (max ℵ₀ (card L))

Next tactic:
rfl
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
⊢ IsElementary ((LHom.substructureReduct LHom.sumInl) S)

Next tactic:
apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
⊢ ∀ (n : ℕ) (φ : BoundedFormula L Empty (n + 1)) (x : Fin n → ↥((LHom.substructureReduct LHom.sumInl) S)) (a : M),
    BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) a) →
      ∃ b, BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) ↑b)

Next tactic:
intro n φ x a h
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
  intro n φ x a h
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
n : ℕ
φ : BoundedFormula L Empty (n + 1)
x : Fin n → ↥((LHom.substructureReduct LHom.sumInl) S)
a : M
h : BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) a)
⊢ ∃ b, BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) ↑b)

Next tactic:
let φ' : (L.sum L.skolem₁).Functions n := LHom.sumInr.onFunction φ
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
  intro n φ x a h
  let φ' : (L.sum L.skolem₁).Functions n := LHom.sumInr.onFunction φ
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
n : ℕ
φ : BoundedFormula L Empty (n + 1)
x : Fin n → ↥((LHom.substructureReduct LHom.sumInl) S)
a : M
h : BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) a)
φ' : Functions (Language.sum L (skolem₁ L)) n := LHom.onFunction LHom.sumInr φ
⊢ ∃ b, BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) ↑b)

Next tactic:
exact
    ⟨⟨funMap φ' ((↑) ∘ x), S.fun_mem (LHom.sumInr.onFunction φ) ((↑) ∘ x) (by
      exact fun i => (x i).2)⟩,
      by exact Classical.epsilon_spec (p := fun a => BoundedFormula.Realize φ default
          (Fin.snoc (Subtype.val ∘ x) a)) ⟨a, h⟩⟩
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
  intro n φ x a h
  let φ' : (L.sum L.skolem₁).Functions n := LHom.sumInr.onFunction φ
  exact
    ⟨⟨funMap φ' ((↑) ∘ x), S.fun_mem (LHom.sumInr.onFunction φ) ((↑) ∘ x) (by
      

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
n : ℕ
φ : BoundedFormula L Empty (n + 1)
x : Fin n → ↥((LHom.substructureReduct LHom.sumInl) S)
a : M
h : BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) a)
φ' : Functions (Language.sum L (skolem₁ L)) n := LHom.onFunction LHom.sumInr φ
⊢ ∀ (i : Fin n), (Subtype.val ∘ x) i ∈ ↑S

Next tactic:
exact fun i => (x i).2
theorem skolem₁_reduct_isElementary (S : (L.sum L.skolem₁).Substructure M) :
    (LHom.sumInl.substructureReduct S).IsElementary := by
  apply (LHom.sumInl.substructureReduct S).isElementary_of_exists
  intro n φ x a h
  let φ' : (L.sum L.skolem₁).Functions n := LHom.sumInr.onFunction φ
  exact
    ⟨⟨funMap φ' ((↑) ∘ x), S.fun_mem (LHom.sumInr.onFunction φ) ((↑) ∘ x) (by
      exact fun i => (x i).2)⟩,
      by 

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
S : Substructure (Language.sum L (skolem₁ L)) M
n : ℕ
φ : BoundedFormula L Empty (n + 1)
x : Fin n → ↥((LHom.substructureReduct LHom.sumInl) S)
a : M
h : BoundedFormula.Realize φ default (Fin.snoc (Subtype.val ∘ x) a)
φ' : Functions (Language.sum L (skolem₁ L)) n := LHom.onFunction LHom.sumInr φ
⊢ BoundedFormula.Realize φ default
    (Fin.snoc (Subtype.val ∘ x)
      ↑{ val := funMap φ' (Subtype.val ∘ x),
          property := (_ : funMap (LHom.onFunction LHom.sumInr φ) (Subtype.val ∘ x) ∈ ↑S) })

Next tactic:
exact Classical.epsilon_spec (p := fun a => BoundedFormula.Realize φ default
          (Fin.snoc (Subtype.val ∘ x) a)) ⟨a, h⟩
instance Substructure.elementarySkolem₁Reduct.instSmall :
    Small (⊥ : (L.sum L.skolem₁).Substructure M).elementarySkolem₁Reduct := by
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ Small.{?u.38679, w} ↥(elementarySkolem₁Reduct ⊥)

Next tactic:
rw [coeSort_elementarySkolem₁Reduct]
instance Substructure.elementarySkolem₁Reduct.instSmall :
    Small (⊥ : (L.sum L.skolem₁).Substructure M).elementarySkolem₁Reduct := by
  rw [coeSort_elementarySkolem₁Reduct]
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
⊢ Small.{?u.38679, w} ↥⊥

Next tactic:
infer_instance
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  

Proof state:
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h1 : ℵ₀ ≤ κ
h2 : lift.{w', w} #↑s ≤ lift.{w, w'} κ
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
⊢ ∃ S, s ⊆ ↑S ∧ lift.{w', w} #↥S = lift.{w, w'} κ

Next tactic:
obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h1 : ℵ₀ ≤ κ
h2 : lift.{w', w} #↑s ≤ lift.{w, w'} κ
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
hs' : #↑s' = lift.{w, w'} κ
⊢ ∃ S, s ⊆ ↑S ∧ lift.{w', w} #↥S = lift.{w, w'} κ

Next tactic:
rw [← aleph0_le_lift.{_, w}] at h1
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h1 : ℵ₀ ≤ lift.{w, w'} κ
h2 : lift.{w', w} #↑s ≤ lift.{w, w'} κ
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
hs' : #↑s' = lift.{w, w'} κ
⊢ ∃ S, s ⊆ ↑S ∧ lift.{w', w} #↥S = lift.{w, w'} κ

Next tactic:
rw [← hs'] at h1 h2 ⊢
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
⊢ ∃ S, s ⊆ ↑S ∧ lift.{w', w} #↥S = #↑s'

Next tactic:
refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
⊢ lift.{w', w}
      #↥(elementarySkolem₁Reduct (LowerAdjoint.toFun (closure (Language.sum L (skolem₁ L))) (s ∪ ⇑Equiv.ulift '' s'))) =
    #↑s'

Next tactic:
have h := mk_image_eq_lift _ s' Equiv.ulift.injective
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
  have h := mk_image_eq_lift _ s' Equiv.ulift.injective
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
h : lift.{max w w', w} #↑(⇑Equiv.ulift '' s') = lift.{w, max w w'} #↑s'
⊢ lift.{w', w}
      #↥(elementarySkolem₁Reduct (LowerAdjoint.toFun (closure (Language.sum L (skolem₁ L))) (s ∪ ⇑Equiv.ulift '' s'))) =
    #↑s'

Next tactic:
rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
  have h := mk_image_eq_lift _ s' Equiv.ulift.injective
  rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
h : lift.{w', w} #↑(⇑Equiv.ulift '' s') = #↑s'
⊢ lift.{w', w}
      #↥(elementarySkolem₁Reduct (LowerAdjoint.toFun (closure (Language.sum L (skolem₁ L))) (s ∪ ⇑Equiv.ulift '' s'))) =
    #↑s'

Next tactic:
rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
  have h := mk_image_eq_lift _ s' Equiv.ulift.injective
  rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
  rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
h : lift.{w', w} #↑(⇑Equiv.ulift '' s') = #↑s'
⊢ #↥(LowerAdjoint.toFun (closure (Language.sum L (skolem₁ L))) (s ∪ ⇑Equiv.ulift '' s')) = #↑(⇑Equiv.ulift '' s')

Next tactic:
refine'
    le_antisymm (lift_le.1 (lift_card_closure_le.trans _))
      (mk_le_mk_of_subset ((Set.subset_union_right _ _).trans subset_closure))
/-- The **Downward Löwenheim–Skolem theorem** :
  If `s` is a set in an `L`-structure `M` and `κ` an infinite cardinal such that
  `max (#s, L.card) ≤ κ` and `κ ≤ # M`, then `M` has an elementary substructure containing `s` of
  cardinality `κ`.  -/
theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ := by
  obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
  rw [← aleph0_le_lift.{_, w}] at h1
  rw [← hs'] at h1 h2 ⊢
  refine'
    ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),
      (s.subset_union_left _).trans subset_closure, _⟩
  have h := mk_image_eq_lift _ s' Equiv.ulift.injective
  rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
  rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]
  refine'
    le_antisymm (lift_le.1 (lift_card_closure_le.trans _))
      (mk_le_mk_of_subset ((Set.subset_union_right _ _).trans subset_closure))
  

Proof state:
case intro
L : Language
M : Type w
inst✝¹ : Nonempty M
inst✝ : Structure L M
s : Set M
κ : Cardinal.{w'}
h3 : lift.{w', max u v} (card L) ≤ lift.{max u v, w'} κ
h4 : lift.{w, w'} κ ≤ lift.{w', w} #M
s' : Set (ULift.{w', w} M)
h2 : lift.{w', w} #↑s ≤ #↑s'
h1 : ℵ₀ ≤ #↑s'
hs' : #↑s' = lift.{w, w'} κ
h : lift.{w', w} #↑(⇑Equiv.ulift '' s') = #↑s'
⊢ max ℵ₀
      (lift.{max u v, w} #↑(s ∪ ⇑Equiv.ulift '' s') +
        lift.{w, max u v} #((i : ℕ) × Functions (Language.sum L (skolem₁ L)) i)) ≤
    lift.{max u v, w} #↑(⇑Equiv.ulift '' s')

Next tactic:
rw [max_le_iff, aleph0_le_lift, ← aleph0_le_lift.{_, w'}, h, add_eq_max, max_le_iff, lift_le]