import Mathlib
import Optlib


open Filter Topology Set InnerProductSpace Finset

open Finset

theorem extracted_formal_statement_15.{u_1} {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : InnerProductSpace ℝ E]
  [inst_2 : CompleteSpace E] {f : E → ℝ} (xm x₀ : E) {alg : subgradient_method f x₀} {t : ℝ}
  (ha' : ∀ (n : ℕ), subgradient_method.a f x₀ n = t) (k : ℕ) (ht : t > 0)
  (h₁ :
    ∀ (k : ℕ),
      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)
  (hk :
    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)
  (h_original_goal :
    sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm ≤
      ‖x₀ - xm‖ ^ 2 / (2 * (↑k + 1) * t) + ↑(subgradient_method.G f x₀) ^ 2 * t / 2) :
  2 * ((↑k + 1) * t) * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) ≤
    2 * ((↑k + 1) * t) * (‖x₀ - xm‖ ^ 2 / (2 * (↑k + 1) * t) + ↑(subgradient_method.G f x₀) ^ 2 * t / 2) := sorry

Tactic state before:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : InnerProductSpace ℝ E
inst✝ : CompleteSpace E
f : E → ℝ
xm x₀ : E
alg : subgradient_method f x₀
t : ℝ
ha' : ∀ (n : ℕ), subgradient_method.a f x₀ n = t
k : ℕ
ht : t > 0
h₁ :
  ∀ (k : ℕ),
    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
hk :
  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
⊢ sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm ≤
    ‖x₀ - xm‖ ^ 2 / (2 * (↑k + 1) * t) + ↑(subgradient_method.G f x₀) ^ 2 * t / 2

Tactic:
simp [ha'] at hk
    have hpos : 2 * ((↑k + 1) * t) > 0 := by
  simp
  apply mul_pos _ ht
  · apply add_pos_of_nonneg_of_pos (Nat.cast_nonneg k) zero_lt_one
    apply (mul_le_mul_left hpos).mp

Tactic state after:
[E : Type u_1
 inst✝² : NormedAddCommGroup E
 inst✝¹ : InnerProductSpace ℝ E
 inst✝ : CompleteSpace E
 f : E → ℝ
 xm x₀ : E
 alg : subgradient_method f x₀
 t : ℝ
 ha' : ∀ (n : ℕ), subgradient_method.a f x₀ n = t
 k : ℕ
 ht : t > 0
 h₁ :
   ∀ (k : ℕ),
     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
 hk :
   2 * ((↑k + 1) * t) * (sInf {x | ∃ i < k + 1, f (subgradient_method.x f x₀ i) = x} - f xm) ≤
     ‖x₀ - xm‖ ^ 2 + ↑(subgradient_method.G f x₀) ^ 2 * ((↑k + 1) * t ^ 2)
 hpos : 2 * ((↑k + 1) * t) > 0
 ⊢ 2 * ((↑k + 1) * t) * (sInf {x | ∃ i ∈ Finset.range (k + 1), f (subgradient_method.x f x₀ i) = x} - f xm) ≤
     2 * ((↑k + 1) * t) * (‖x₀ - xm‖ ^ 2 / (2 * (↑k + 1) * t) + ↑(subgradient_method.G f x₀) ^ 2 * t / 2)]