theorem extracted_formal_statement_14.{u_1} {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : InnerProductSpace ℝ E]
  {f : E → ℝ} (xm x₀ : E) {alg : subgradient_method f x₀} (k : ℕ)
  (h' : ∀ ⦃x g : E⦄, g ∈ SubderivAt f x → ‖g‖ ≤ ↑(subgradient_method.G f x₀)) (k₀ : ¬k = 0)
  (heq :
    (Set.range fun x => f (subgradient_method.x f x₀ ↑x)) =
      {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x})
  (h₁ :
    ∀ ⦃i : ℕ⦄,
      i ≥ 0 ∧ i ≤ k →
        ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 ≤
          ‖subgradient_method.x f x₀ i - xm‖ ^ 2 -
              2 * subgradient_method.a f x₀ i *
                (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) +
            ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2)
  (h₁' :
    ∀ ⦃i : ℕ⦄,
      i ≥ 0 ∧ i ≤ k →
        subgradient_method.a f x₀ i *
            (2 * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm)) ≤
          ‖subgradient_method.x f x₀ i - xm‖ ^ 2 - ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 +
            ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2)
  (h₂ :
    ∑ i ∈ Finset.range (k + 1),
        subgradient_method.a f x₀ i *
          (2 * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm)) ≤
      ∑ i ∈ Finset.range (k + 1),
        (‖subgradient_method.x f x₀ i - xm‖ ^ 2 - ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 +
          ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2)) :
  2 * (Finset.range (k + 1)).sum (subgradient_method.a f x₀) *
      (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) ≤
    ‖x₀ - xm‖ ^ 2 +
      ↑(subgradient_method.G f x₀) ^ 2 * ∑ i ∈ Finset.range (k + 1), subgradient_method.a f x₀ i ^ 2 := sorry

State before:
case neg
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : InnerProductSpace ℝ E
f : E → ℝ
xm x₀ : E
alg : subgradient_method f x₀
k : ℕ
h' : ∀ ⦃x g : E⦄, g ∈ SubderivAt f x → ‖g‖ ≤ ↑(subgradient_method.G f x₀)
k₀ : ¬k = 0
heq :
  (Set.range fun x => f (subgradient_method.x f x₀ ↑x)) =
    {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x}
h₁ :
  ∀ ⦃i : ℕ⦄,
    i ≥ 0 ∧ i ≤ k →
      ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 ≤
        ‖subgradient_method.x f x₀ i - xm‖ ^ 2 -
            2 * subgradient_method.a f x₀ i *
              (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) +
          ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2
h₁' :
  ∀ ⦃i : ℕ⦄,
    i ≥ 0 ∧ i ≤ k →
      subgradient_method.a f x₀ i *
          (2 * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm)) ≤
        ‖subgradient_method.x f x₀ i - xm‖ ^ 2 - ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 +
          ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2
h₂ :
  ∑ i ∈ Finset.range (k + 1),
      subgradient_method.a f x₀ i *
        (2 * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm)) ≤
    ∑ i ∈ Finset.range (k + 1),
      (‖subgradient_method.x f x₀ i - xm‖ ^ 2 - ‖subgradient_method.x f x₀ (i + 1) - xm‖ ^ 2 +
        ↑(subgradient_method.G f x₀) ^ 2 * subgradient_method.a f x₀ i ^ 2)
⊢ 2 * (Finset.range (k + 1)).sum (subgradient_method.a f x₀) *
      (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) ≤
    ‖x₀ - xm‖ ^ 2 + ↑(subgradient_method.G f x₀) ^ 2 * ∑ i ∈ Finset.range (k + 1), subgradient_method.a f x₀ i ^ 2

Tactic: rw [← sum_mul, ← mul_assoc, mul_comm _ 2, sum_add_distrib] at h₂
    rw [sum_range_sub' _, ← mul_sum, alg.initial] at h₂
    calc
  _ =
      (2 * Finset.sum (Finset.range (k + 1)) fun x => alg.a x) *
        (sInf {x | ∃ i ∈ Finset.range (k + 1), f (alg.x i) = x} - f xm) :=
    by simp
  _ ≤ ‖x₀ - xm‖ ^ 2 - ‖alg.x (k + 1) - xm‖ ^ 2 + ↑alg.G ^ 2 * Finset.sum (Finset.range (k + 1)) fun x => alg.a x ^ 2 :=
    by apply h₂
  _ ≤ ‖x₀ - xm‖ ^ 2 + alg.G ^ 2 * Finset.sum (Finset.range (k + 1)) fun x => alg.a x ^ 2 := by simp

State after:

Relevant lemmas:
Finset.sum_add_distrib : ∀ {α : Type u_3} {β : Type u_4} {s : Finset α} {f g : α → β} [inst : AddCommMonoid β],
  ∑ x ∈ s, (f x + g x) = ∑ x ∈ s, f x + ∑ x ∈ s, g x
Finset.sum_mul : ∀ {ι : Type u_1} {α : Type u_3} [inst : NonUnitalNonAssocSemiring α] (s : Finset ι) (f : ι → α)
  (a : α), (∑ i ∈ s, f i) * a = ∑ i ∈ s, f i * a
mul_comm : ∀ {G : Type u_1} [inst : CommMagma G] (a b : G), a * b = b * a
mul_assoc : ∀ {G : Type u_1} [inst : Semigroup G] (a b c : G), a * b * c = a * (b * c)
Finset.mul_sum : ∀ {ι : Type u_1} {α : Type u_3} [inst : NonUnitalNonAssocSemiring α] (s : Finset ι) (f : ι → α)
  (a : α), a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i
Finset.sum_range_sub' : ∀ {M : Type u_6} [inst : AddCommGroup M] (f : ℕ → M) (n : ℕ),
  ∑ i ∈ Finset.range n, (f i - f (i + 1)) = f 0 - f n