theorem extracted_formal_statement_8.{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})
  ⦃i : ℕ⦄ (left : i ≥ 0) (hi₂ : i ≤ k)
  (h_original_goal :
    ‖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) :
  ‖subgradient_method.x f x₀ i - xm‖ ^ 2 +
        -(2 * ⟪subgradient_method.x f x₀ i - xm, subgradient_method.a f x₀ i • subgradient_method.g f x₀ i⟫_ℝ) +
      ‖subgradient_method.a f x₀ i‖ ^ 2 * ‖subgradient_method.g f x₀ i‖ ^ 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 := sorry

State before:
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}
i : ℕ
left✝ : i ≥ 0
hi₂ : 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

Tactic: rw [alg.update i, sub_right_comm, norm_sub_sq_real, norm_smul, mul_pow, sub_eq_add_neg]
    have :
  ‖alg.x i - xm‖ ^ 2 - 2 * alg.a i * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (alg.x i) = x} - f xm) +
      ↑alg.G ^ 2 * alg.a i ^ 2 =
    ‖alg.x i - xm‖ ^ 2 + -(2 * alg.a i * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (alg.x i) = x} - f xm)) +
      ↑alg.G ^ 2 * alg.a i ^ 2 :=
  by ring
    rw [this]

State after:
[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}
 i : ℕ
 left✝ : i ≥ 0
 hi₂ : i ≤ k
 this :
   ‖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 =
     ‖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
 ⊢ ‖subgradient_method.x f x₀ i - xm‖ ^ 2 +
         -(2 * ⟪subgradient_method.x f x₀ i - xm, subgradient_method.a f x₀ i • subgradient_method.g f x₀ i⟫_ℝ) +
       ‖subgradient_method.a f x₀ i‖ ^ 2 * ‖subgradient_method.g f x₀ i‖ ^ 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]

Relevant lemmas:
sub_eq_add_neg : ∀ {G : Type u_1} [inst : SubNegMonoid G] (a b : G), a - b = a + -b
norm_smul : ∀ {α : Type u_1} {β : Type u_2} [inst : NormedDivisionRing α] [inst_2 : SeminormedAddGroup β]
  [inst_3 : MulActionWithZero α β] [inst_4 : IsBoundedSMul α β] (r : α) (x : β), ‖r • x‖ = ‖r‖ * ‖x‖
sub_right_comm : ∀ {α : Type u_1} [inst : SubtractionCommMonoid α] (a b c : α), a - b - c = a - c - b
norm_sub_sq_real : ∀ {F : Type u_3} [inst : SeminormedAddCommGroup F] [inst_2 : InnerProductSpace ℝ F] (x y : F),
  ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * ⟪x, y⟫_ℝ + ‖y‖ ^ 2
mul_pow : ∀ {M : Type u_4} [inst : CommMonoid M] (a b : M) (n : ℕ), (a * b) ^ n = a ^ n * b ^ n