l3lab/ntp-mathlib huggingface dataset:
theorem agree : f.range = { x | h x = g x } := by
  refine' Set.ext fun b => ⟨_, fun hb : h b = g b => by_contradiction fun r => _⟩
  · rintro ⟨a, rfl⟩
    change h (f a) = g (f a)
    ext ⟨⟨_, ⟨y, rfl⟩⟩⟩
    · rw [g_apply_fromCoset]
      by_cases m : y ∈ f.range
      · rw [h_apply_fromCoset' _ _ _ m, fromCoset_eq_of_mem_range _ m]
        change fromCoset _ = fromCoset ⟨f a • (y • _), _⟩
        simp only [← fromCoset_eq_of_mem_range _ (Subgroup.mul_mem _ ⟨a, rfl⟩ m), smul_smul]
      · rw [h_apply_fromCoset_nin_range f (f a) ⟨_, rfl⟩ _ m]
        simp only [leftCoset_assoc]
    · rw [g_apply_infinity, h_apply_infinity f (f a) ⟨_, rfl⟩]
  · have eq1 : (h b) (fromCoset ⟨f.range, 1, one_leftCoset _⟩) =
        fromCoset ⟨f.range, 1, one_leftCoset _⟩ := by
      change ((τ).symm.trans (g b)).trans τ _ = _
      dsimp [tau]
      simp [g_apply_infinity f]
    have eq2 :
      g b (fromCoset ⟨f.range, 1, one_leftCoset _⟩) = fromCoset ⟨b • ↑f.range, b, rfl⟩ := rfl
    exact (fromCoset_ne_of_nin_range _ r).symm (by 

Proof state:
A B : GroupCat
f : A ⟶ B
b : ↑B
hb : h b = g b
r : b ∉ ↑(MonoidHom.range f)
eq1 :
  (h b)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }) =
    fromCoset
      { val := ↑(MonoidHom.range f),
        property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }
eq2 :
  (g b)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }) =
    fromCoset
      { val := b • ↑(MonoidHom.range f),
        property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = b • ↑(MonoidHom.range f)) }
⊢ fromCoset
      { val := ↑(MonoidHom.range f),
        property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) } =
    fromCoset
      { val := b • ↑(MonoidHom.range f),
        property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = b • ↑(MonoidHom.range f)) }

Next tactic:
rw [← eq1, ← eq2, FunLike.congr_fun hb]
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  

Proof state:
A B : GroupCat
f : A ⟶ B
⊢ (f ≫
      let_fun this := g;
      this) =
    f ≫
      let_fun this := h;
      this

Next tactic:
ext a
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  ext a
  

Proof state:
case w
A B : GroupCat
f : A ⟶ B
a : ↑A
⊢ (f ≫
        let_fun this := g;
        this)
      a =
    (f ≫
        let_fun this := h;
        this)
      a

Next tactic:
change g (f a) = h (f a)
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  ext a
  change g (f a) = h (f a)
  

Proof state:
case w
A B : GroupCat
f : A ⟶ B
a : ↑A
⊢ g (f a) = h (f a)

Next tactic:
have : f a ∈ { b | h b = g b } := by
    rw [← agree]
    use a
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  ext a
  change g (f a) = h (f a)
  have : f a ∈ { b | h b = g b } := by
    

Proof state:
A B : GroupCat
f : A ⟶ B
a : ↑A
⊢ f a ∈ {b | h b = g b}

Next tactic:
rw [← agree]
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  ext a
  change g (f a) = h (f a)
  have : f a ∈ { b | h b = g b } := by
    rw [← agree]
    

Proof state:
A B : GroupCat
f : A ⟶ B
a : ↑A
⊢ f a ∈ ↑(MonoidHom.range f)

Next tactic:
use a
theorem comp_eq : (f ≫ show B ⟶ GroupCat.of SX' from g) = f ≫ show B ⟶ GroupCat.of SX' from h := by
  ext a
  change g (f a) = h (f a)
  have : f a ∈ { b | h b = g b } := by
    rw [← agree]
    use a
  

Proof state:
case w
A B : GroupCat
f : A ⟶ B
a : ↑A
this : f a ∈ {b | h b = g b}
⊢ g (f a) = h (f a)

Next tactic:
rw [this]
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
⊢ g ≠ h

Next tactic:
intro r
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r : g = h
⊢ False

Next tactic:
replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r :
  (g x)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }) =
    (h x)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) })
⊢ False

Next tactic:
change _ = ((τ).symm.trans (g x)).trans τ _ at r
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
  change _ = ((τ).symm.trans (g x)).trans τ _ at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r :
  (g x)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }) =
    ((τ.symm.trans (g x)).trans τ)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) })
⊢ False

Next tactic:
rw [g_apply_fromCoset, MonoidHom.coe_mk] at r
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
  change _ = ((τ).symm.trans (g x)).trans τ _ at r
  rw [g_apply_fromCoset, MonoidHom.coe_mk] at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r :
  fromCoset
      {
        val :=
          x •
            ↑{ val := ↑(MonoidHom.range f),
                property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) },
        property :=
          (_ :
            x •
                ↑{ val := ↑(MonoidHom.range f),
                    property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) } ∈
              Set.range fun x => x • ↑(MonoidHom.range f)) } =
    ((τ.symm.trans (↑g x)).trans τ)
      (fromCoset
        { val := ↑(MonoidHom.range f),
          property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) })
⊢ False

Next tactic:
simp only [MonoidHom.coe_range, Subtype.coe_mk, Equiv.symm_swap, Equiv.toFun_as_coe,
    Equiv.coe_trans, Function.comp_apply] at r
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
  change _ = ((τ).symm.trans (g x)).trans τ _ at r
  rw [g_apply_fromCoset, MonoidHom.coe_mk] at r
  simp only [MonoidHom.coe_range, Subtype.coe_mk, Equiv.symm_swap, Equiv.toFun_as_coe,
    Equiv.coe_trans, Function.comp_apply] at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r :
  fromCoset
      { val := x • Set.range ⇑f,
        property := (_ : (fun x => x ∈ Set.range fun x => x • ↑(MonoidHom.range f)) (x • Set.range ⇑f)) } =
    τ
      ((↑g x)
        (τ.symm
          (fromCoset
            { val := Set.range ⇑f,
              property := (_ : (fun x => x ∈ Set.range fun x => x • ↑(MonoidHom.range f)) (Set.range ⇑f)) })))
⊢ False

Next tactic:
erw [Equiv.swap_apply_left, g_apply_infinity, Equiv.swap_apply_right] at r
theorem g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h := by
  intro r
  replace r :=
    FunLike.congr_fun (FunLike.congr_fun r x) (fromCoset ⟨f.range, ⟨1, one_leftCoset _⟩⟩)
  change _ = ((τ).symm.trans (g x)).trans τ _ at r
  rw [g_apply_fromCoset, MonoidHom.coe_mk] at r
  simp only [MonoidHom.coe_range, Subtype.coe_mk, Equiv.symm_swap, Equiv.toFun_as_coe,
    Equiv.coe_trans, Function.comp_apply] at r
  erw [Equiv.swap_apply_left, g_apply_infinity, Equiv.swap_apply_right] at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
x : ↑B
hx : x ∉ MonoidHom.range f
r :
  fromCoset
      { val := x • Set.range ⇑f,
        property := (_ : (fun x => x ∈ Set.range fun x => x • ↑(MonoidHom.range f)) (x • Set.range ⇑f)) } =
    fromCoset
      { val := ↑(MonoidHom.range f),
        property := (_ : ∃ y, (fun x => x • ↑(MonoidHom.range f)) y = ↑(MonoidHom.range f)) }
⊢ False

Next tactic:
exact fromCoset_ne_of_nin_range _ hx r
theorem surjective_of_epi [Epi f] : Function.Surjective f := by
  

Proof state:
A B : GroupCat
f : A ⟶ B
inst✝ : Epi f
⊢ Function.Surjective ⇑f

Next tactic:
by_contra r
theorem surjective_of_epi [Epi f] : Function.Surjective f := by
  by_contra r
  

Proof state:
A B : GroupCat
f : A ⟶ B
inst✝ : Epi f
r : ¬Function.Surjective ⇑f
⊢ False

Next tactic:
dsimp [Function.Surjective] at r
theorem surjective_of_epi [Epi f] : Function.Surjective f := by
  by_contra r
  dsimp [Function.Surjective] at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
inst✝ : Epi f
r : ¬∀ (b : ↑B), ∃ a, f a = b
⊢ False

Next tactic:
push_neg at r
theorem surjective_of_epi [Epi f] : Function.Surjective f := by
  by_contra r
  dsimp [Function.Surjective] at r
  push_neg at r
  

Proof state:
A B : GroupCat
f : A ⟶ B
inst✝ : Epi f
r : ∃ b, ∀ (a : ↑A), f a ≠ b
⊢ False

Next tactic:
rcases r with ⟨b, hb⟩
theorem surjective_of_epi [Epi f] : Function.Surjective f := by
  by_contra r
  dsimp [Function.Surjective] at r
  push_neg at r
  rcases r with ⟨b, hb⟩
  

Proof state:
case intro
A B : GroupCat
f : A ⟶ B
inst✝ : Epi f
b : ↑B
hb : ∀ (a : ↑A), f a ≠ b
⊢ False

Next tactic:
exact
    SurjectiveOfEpiAuxs.g_ne_h f b (fun ⟨c, hc⟩ => hb _ hc)
      ((cancel_epi f).1 (SurjectiveOfEpiAuxs.comp_eq f))
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  

Proof state:
A B : AddGroupCat
f : A ⟶ B
⊢ Epi f ↔ Function.Surjective ⇑f

Next tactic:
have i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f) := by
    refine' ⟨_, groupAddGroupEquivalence.inverse.epi_of_epi_map⟩
    intro e'
    apply groupAddGroupEquivalence.inverse.map_epi
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  have i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f) := by
    

Proof state:
A B : AddGroupCat
f : A ⟶ B
⊢ Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f)

Next tactic:
refine' ⟨_, groupAddGroupEquivalence.inverse.epi_of_epi_map⟩
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  have i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f) := by
    refine' ⟨_, groupAddGroupEquivalence.inverse.epi_of_epi_map⟩
    

Proof state:
A B : AddGroupCat
f : A ⟶ B
⊢ Epi f → Epi (groupAddGroupEquivalence.inverse.map f)

Next tactic:
intro e'
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  have i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f) := by
    refine' ⟨_, groupAddGroupEquivalence.inverse.epi_of_epi_map⟩
    intro e'
    

Proof state:
A B : AddGroupCat
f : A ⟶ B
e' : Epi f
⊢ Epi (groupAddGroupEquivalence.inverse.map f)

Next tactic:
apply groupAddGroupEquivalence.inverse.map_epi
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  have i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f) := by
    refine' ⟨_, groupAddGroupEquivalence.inverse.epi_of_epi_map⟩
    intro e'
    apply groupAddGroupEquivalence.inverse.map_epi
  

Proof state:
A B : AddGroupCat
f : A ⟶ B
i1 : Epi f ↔ Epi (groupAddGroupEquivalence.inverse.map f)
⊢ Epi f ↔ Function.Surjective ⇑f

Next tactic:
rwa [GroupCat.epi_iff_surjective] at i1
@[to_additive AddGroupCat.forget_groupCat_preserves_mono]
instance forget_groupCat_preserves_mono : (forget GroupCat).PreservesMonomorphisms where
  preserves f e := by 

Proof state:
A B : GroupCat
f✝ : A ⟶ B
X✝ Y✝ : GroupCat
f : X✝ ⟶ Y✝
e : Mono f
⊢ Mono ((forget GroupCat).map f)

Next tactic:
rwa [mono_iff_injective, ← CategoryTheory.mono_iff_injective] at e
@[to_additive AddGroupCat.forget_groupCat_preserves_epi]
instance forget_groupCat_preserves_epi : (forget GroupCat).PreservesEpimorphisms where
  preserves f e := by 

Proof state:
A B : GroupCat
f✝ : A ⟶ B
X✝ Y✝ : GroupCat
f : X✝ ⟶ Y✝
e : Epi f
⊢ Epi ((forget GroupCat).map f)

Next tactic:
rwa [epi_iff_surjective, ← CategoryTheory.epi_iff_surjective] at e
@[to_additive]
theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by
  

Proof state:
A B : CommGroupCat
f : A ⟶ B
⊢ Epi f ↔ Function.Surjective ⇑f

Next tactic:
rw [epi_iff_range_eq_top, MonoidHom.range_top_iff_surjective]
@[to_additive AddCommGroupCat.forget_commGroupCat_preserves_mono]
instance forget_commGroupCat_preserves_mono : (forget CommGroupCat).PreservesMonomorphisms where
  preserves f e := by 

Proof state:
A B : CommGroupCat
f✝ : A ⟶ B
X✝ Y✝ : CommGroupCat
f : X✝ ⟶ Y✝
e : Mono f
⊢ Mono ((forget CommGroupCat).map f)

Next tactic:
rwa [mono_iff_injective, ← CategoryTheory.mono_iff_injective] at e
@[to_additive AddCommGroupCat.forget_commGroupCat_preserves_epi]
instance forget_commGroupCat_preserves_epi : (forget CommGroupCat).PreservesEpimorphisms where
  preserves f e := by 

Proof state:
A B : CommGroupCat
f✝ : A ⟶ B
X✝ Y✝ : CommGroupCat
f : X✝ ⟶ Y✝
e : Epi f
⊢ Epi ((forget CommGroupCat).map f)

Next tactic:
rwa [epi_iff_surjective, ← CategoryTheory.epi_iff_surjective] at e
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
let δ := ⨅ w : K, ‖u - w‖
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
letI : Nonempty K := ne.to_subtype
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
zero_le_δ : 0 ≤ δ
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_range_iff.2 fun _ => norm_nonneg _⟩
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
  have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_range_iff.2 fun _ => norm_nonneg _⟩
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
zero_le_δ : 0 ≤ δ
δ_le : ∀ (w : ↑K), δ ≤ ‖u - ↑w‖
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖ := fun w hw => δ_le ⟨w, hw⟩
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
  have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_range_iff.2 fun _ => norm_nonneg _⟩
  have δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖ := fun w hw => δ_le ⟨w, hw⟩
  -- Step 1: since `δ` is the infimum, can find a sequence `w : ℕ → K` in `K`
  -- such that `‖u - w n‖ < δ + 1 / (n + 1)` (which implies `‖u - w n‖ --> δ`);
  -- maybe this should be a separate lemma
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
zero_le_δ : 0 ≤ δ
δ_le : ∀ (w : ↑K), δ ≤ ‖u - ↑w‖
δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖
⊢ ∃ v ∈ K, ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have exists_seq : ∃ w : ℕ → K, ∀ n, ‖u - w n‖ < δ + 1 / (n + 1) := by
    have hδ : ∀ n : ℕ, δ < δ + 1 / (n + 1) := fun n =>
      lt_add_of_le_of_pos le_rfl Nat.one_div_pos_of_nat
    have h := fun n => exists_lt_of_ciInf_lt (hδ n)
    let w : ℕ → K := fun n => Classical.choose (h n)
    exact ⟨w, fun n => Classical.choose_spec (h n)⟩
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
  have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_range_iff.2 fun _ => norm_nonneg _⟩
  have δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖ := fun w hw => δ_le ⟨w, hw⟩
  -- Step 1: since `δ` is the infimum, can find a sequence `w : ℕ → K` in `K`
  -- such that `‖u - w n‖ < δ + 1 / (n + 1)` (which implies `‖u - w n‖ --> δ`);
  -- maybe this should be a separate lemma
  have exists_seq : ∃ w : ℕ → K, ∀ n, ‖u - w n‖ < δ + 1 / (n + 1) := by
    

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
zero_le_δ : 0 ≤ δ
δ_le : ∀ (w : ↑K), δ ≤ ‖u - ↑w‖
δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖
⊢ ∃ w, ∀ (n : ℕ), ‖u - ↑(w n)‖ < δ + 1 / (↑n + 1)

Next tactic:
have hδ : ∀ n : ℕ, δ < δ + 1 / (n + 1) := fun n =>
      lt_add_of_le_of_pos le_rfl Nat.one_div_pos_of_nat
/-- Existence of minimizers
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
 -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
    (h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
  let δ := ⨅ w : K, ‖u - w‖
  letI : Nonempty K := ne.to_subtype
  have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
  have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_range_iff.2 fun _ => norm_nonneg _⟩
  have δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖ := fun w hw => δ_le ⟨w, hw⟩
  -- Step 1: since `δ` is the infimum, can find a sequence `w : ℕ → K` in `K`
  -- such that `‖u - w n‖ < δ + 1 / (n + 1)` (which implies `‖u - w n‖ --> δ`);
  -- maybe this should be a separate lemma
  have exists_seq : ∃ w : ℕ → K, ∀ n, ‖u - w n‖ < δ + 1 / (n + 1) := by
    have hδ : ∀ n : ℕ, δ < δ + 1 / (n + 1) := fun n =>
      lt_add_of_le_of_pos le_rfl Nat.one_div_pos_of_nat
    

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K : Set F
ne : Set.Nonempty K
h₁ : IsComplete K
h₂ : Convex ℝ K
u : F
δ : ℝ := ⨅ w, ‖u - ↑w‖
this : Nonempty ↑K := Set.Nonempty.to_subtype ne
zero_le_δ : 0 ≤ δ
δ_le : ∀ (w : ↑K), δ ≤ ‖u - ↑w‖
δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖
hδ : ∀ (n : ℕ), δ < δ + 1 / (↑n + 1)
⊢ ∃ w, ∀ (n : ℕ), ‖u - ↑(w n)‖ < δ + 1 / (↑n + 1)

Next tactic:
have h := fun n => exists_lt_of_ciInf_lt (hδ n)