import Mathlib
import Optlib


open Set

theorem extracted_formal_statement_25.{u_1} {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : InnerProductSpace ℝ E]
  [inst_2 : CompleteSpace E] {f : E → ℝ} {m : ℝ} {f' : E → E} {xm x₀ : E} {alg : Gradient_Descent_fix_stepsize f f' x₀}
  (hm : m > 0) (min : IsMinOn f univ xm)
  (step₂ : Gradient_Descent_fix_stepsize.a f f' x₀ ≤ 2 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀)))
  (hsc : StrongConvexOn univ m f) (this_1 : LipschitzWith (Gradient_Descent_fix_stepsize.l f f' x₀) f')
  (this_2 : ↑(Gradient_Descent_fix_stepsize.l f f' x₀) > 0) (k : ℕ)
  (this :
    inner (Gradient_Descent_fix_stepsize.x f f' x₀ k - xm) (f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)) ≥
      m * ↑(Gradient_Descent_fix_stepsize.l f f' x₀) / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀)) *
          ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
        1 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀)) * ‖f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)‖ ^ 2) :
  ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
      -(2 * Gradient_Descent_fix_stepsize.a f f' x₀ *
          inner (Gradient_Descent_fix_stepsize.x f f' x₀ k - xm) (f' (Gradient_Descent_fix_stepsize.x f f' x₀ k))) ≤
    ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
      -(Gradient_Descent_fix_stepsize.a f f' x₀ *
              (2 * m * ↑(Gradient_Descent_fix_stepsize.l f f' x₀) / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀))) *
            ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
          Gradient_Descent_fix_stepsize.a f f' x₀ * (2 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀))) *
            ‖f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)‖ ^ 2) := sorry

Tactic state before:
case bc
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
inst✝ : CompleteSpace E
f : E → ℝ
m : ℝ
f' : E → E
xm x₀ : E
alg : Gradient_Descent_fix_stepsize f f' x₀
hm : m > 0
min : IsMinOn f univ xm
step₂ : Gradient_Descent_fix_stepsize.a f f' x₀ ≤ 2 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀))
hsc : StrongConvexOn univ m f
this✝¹ : LipschitzWith (Gradient_Descent_fix_stepsize.l f f' x₀) f'
this✝ : ↑(Gradient_Descent_fix_stepsize.l f f' x₀) > 0
k : ℕ
this :
  inner (Gradient_Descent_fix_stepsize.x f f' x₀ k - xm) (f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)) ≥
    m * ↑(Gradient_Descent_fix_stepsize.l f f' x₀) / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀)) *
        ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
      1 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀)) * ‖f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)‖ ^ 2
⊢ ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
      -(2 * Gradient_Descent_fix_stepsize.a f f' x₀ *
          inner (Gradient_Descent_fix_stepsize.x f f' x₀ k - xm) (f' (Gradient_Descent_fix_stepsize.x f f' x₀ k))) ≤
    ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
      -(Gradient_Descent_fix_stepsize.a f f' x₀ *
              (2 * m * ↑(Gradient_Descent_fix_stepsize.l f f' x₀) / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀))) *
            ‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 +
          Gradient_Descent_fix_stepsize.a f f' x₀ * (2 / (m + ↑(Gradient_Descent_fix_stepsize.l f f' x₀))) *
            ‖f' (Gradient_Descent_fix_stepsize.x f f' x₀ k)‖ ^ 2)

Tactic:
apply add_le_add_left
    apply neg_le_neg
    calc
  _ = 2 * alg.a * ((m * alg.l / (m + alg.l)) * ‖alg.x k - xm‖ ^ 2 + (1 / (m + alg.l)) * ‖f' (alg.x k)‖ ^ 2) :=
    by
    field_simp; rw [mul_add, mul_comm alg.a 2, ← mul_assoc, ← mul_assoc, mul_comm alg.a 2]
    ring_nf
  _ ≤ 2 * alg.a * inner (alg.x k - xm) (f' (alg.x k)) := by
    to_theorem
      rw [ge_iff_le] at this have twoapos : 0 < 2 * alg.a := by linarith [alg.step₁]rw [mul_le_mul_left twoapos];
    apply this

Tactic state after: