import Mathlib
import Optlib


open Set Finset

open InnerProductSpace Set

theorem extracted_formal_statement_51.{u_1} {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : InnerProductSpace ℝ E]
  [inst_2 : CompleteSpace E] {f : E → ℝ} {f' : E → E} {xm x₀ : E} {alg : Gradient_Descent_fix_stepsize f f' x₀}
  (hfun : ConvexOn ℝ univ f)
  (step₂ : Gradient_Descent_fix_stepsize.a f f' x₀ ≤ 1 / ↑(Gradient_Descent_fix_stepsize.l f f' x₀)) (k : ℕ)
  (step1₂ : ↑(Gradient_Descent_fix_stepsize.l f f' x₀) ≤ 1 / Gradient_Descent_fix_stepsize.a f f' x₀)
  (this_1 : LipschitzWith (Gradient_Descent_fix_stepsize.l f f' x₀) f')
  (this : Gradient_Descent_fix_stepsize.l f f' x₀ > 0)
  (tα : 1 / (2 * (↑k + 1) * Gradient_Descent_fix_stepsize.a f f' x₀) > 0)
  (xdescent :
    ∀ (k : ℕ),
      f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤
        f xm +
          1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
            (‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 -
              ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2))
  (mono :
    ∀ (k : ℕ), f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤ f (Gradient_Descent_fix_stepsize.x f f' x₀ k))
  (sum_prop_2 :
    ∀ (n : ℕ),
      ∑ k ∈ Finset.range (n + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
        1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
          (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (n + 1) - xm‖ ^ 2))
  (sum_prop_1 :
    f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm ≤
      (∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm)) / (↑k + 1))
  (sum_prop :
    ∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
      1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
        (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2))
  (tt1 : 0 ≤ ↑k + 1)
  (h_original_goal :
    1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
          (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2) /
        (↑k + 1) =
      1 / (2 * (↑k + 1) * Gradient_Descent_fix_stepsize.a f f' x₀) *
        (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)) :
  (Gradient_Descent_fix_stepsize.a f f' x₀)⁻¹ * 2⁻¹ *
        (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2) /
      (↑k + 1) =
    (Gradient_Descent_fix_stepsize.a f f' x₀)⁻¹ * ((↑k + 1)⁻¹ * 2⁻¹) *
      (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2) := sorry

Tactic state before:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
inst✝ : CompleteSpace E
f : E → ℝ
f' : E → E
xm x₀ : E
alg : Gradient_Descent_fix_stepsize f f' x₀
hfun : ConvexOn ℝ univ f
step₂ : Gradient_Descent_fix_stepsize.a f f' x₀ ≤ 1 / ↑(Gradient_Descent_fix_stepsize.l f f' x₀)
k : ℕ
step1₂ : ↑(Gradient_Descent_fix_stepsize.l f f' x₀) ≤ 1 / Gradient_Descent_fix_stepsize.a f f' x₀
this✝ : LipschitzWith (Gradient_Descent_fix_stepsize.l f f' x₀) f'
this : Gradient_Descent_fix_stepsize.l f f' x₀ > 0
tα : 1 / (2 * (↑k + 1) * Gradient_Descent_fix_stepsize.a f f' x₀) > 0
xdescent :
  ∀ (k : ℕ),
    f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤
      f xm +
        1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
          (‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 -
            ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)
mono : ∀ (k : ℕ), f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤ f (Gradient_Descent_fix_stepsize.x f f' x₀ k)
sum_prop✝ :
  ∀ (n : ℕ),
    ∑ k ∈ Finset.range (n + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
      1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
        (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (n + 1) - xm‖ ^ 2)
sum_prop_1 :
  f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm ≤
    (∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm)) / (↑k + 1)
sum_prop :
  ∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
    1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
      (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)
tt1 : 0 ≤ ↑k + 1
⊢ 1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
        (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2) /
      (↑k + 1) =
    1 / (2 * (↑k + 1) * Gradient_Descent_fix_stepsize.a f f' x₀) *
      (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)

Tactic:
simp

Tactic state after:
[E : Type u_1
 inst✝² : NormedAddCommGroup E
 inst✝¹ : InnerProductSpace ℝ E
 inst✝ : CompleteSpace E
 f : E → ℝ
 f' : E → E
 xm x₀ : E
 alg : Gradient_Descent_fix_stepsize f f' x₀
 hfun : ConvexOn ℝ univ f
 step₂ : Gradient_Descent_fix_stepsize.a f f' x₀ ≤ 1 / ↑(Gradient_Descent_fix_stepsize.l f f' x₀)
 k : ℕ
 step1₂ : ↑(Gradient_Descent_fix_stepsize.l f f' x₀) ≤ 1 / Gradient_Descent_fix_stepsize.a f f' x₀
 this✝ : LipschitzWith (Gradient_Descent_fix_stepsize.l f f' x₀) f'
 this : Gradient_Descent_fix_stepsize.l f f' x₀ > 0
 tα : 1 / (2 * (↑k + 1) * Gradient_Descent_fix_stepsize.a f f' x₀) > 0
 xdescent :
   ∀ (k : ℕ),
     f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤
       f xm +
         1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
           (‖Gradient_Descent_fix_stepsize.x f f' x₀ k - xm‖ ^ 2 -
             ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)
 mono : ∀ (k : ℕ), f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) ≤ f (Gradient_Descent_fix_stepsize.x f f' x₀ k)
 sum_prop✝ :
   ∀ (n : ℕ),
     ∑ k ∈ Finset.range (n + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
       1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
         (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (n + 1) - xm‖ ^ 2)
 sum_prop_1 :
   f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm ≤
     (∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm)) / (↑k + 1)
 sum_prop :
   ∑ k ∈ Finset.range (k + 1), (f (Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1)) - f xm) ≤
     1 / (2 * Gradient_Descent_fix_stepsize.a f f' x₀) *
       (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)
 tt1 : 0 ≤ ↑k + 1
 ⊢ (Gradient_Descent_fix_stepsize.a f f' x₀)⁻¹ * 2⁻¹ *
         (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2) /
       (↑k + 1) =
     (Gradient_Descent_fix_stepsize.a f f' x₀)⁻¹ * ((↑k + 1)⁻¹ * 2⁻¹) *
       (‖x₀ - xm‖ ^ 2 - ‖Gradient_Descent_fix_stepsize.x f f' x₀ (k + 1) - xm‖ ^ 2)]