import Mathlib
import Optlib


open Set Bornology Filter BigOperators Topology BCD

open BCD

theorem extracted_formal_statement_239.{u_2, u_1} {E : Type u_1} {F : Type u_2} [inst : NormedAddCommGroup E]
  [inst_1 : InnerProductSpace ℝ E] [inst_2 : CompleteSpace E] [inst_3 : NormedAddCommGroup F]
  [inst_4 : InnerProductSpace ℝ F] [inst_5 : CompleteSpace F] {f : E → ℝ} {g : F → ℝ} {H : WithLp 2 (E × F) → ℝ}
  {x0 : E} {y0 : F} {l : NNReal} {alg : BCD f g H l x0 y0} [inst_6 : ProperSpace E] [inst_7 : ProperSpace F] (γ : ℝ)
  (hγ : γ > 1) (ck : ∀ (k : ℕ), alg.c k = 1 / (γ * ↑l)) (dk : ∀ (k : ℕ), alg.d k = 1 / (γ * ↑l))
  (bd : Bornology.IsBounded (z '' univ)) (hψ : KL_function ψ) (lbdψ : BddBelow (ψ '' univ)) (z_ : WithLp 2 (E × F))
  (left : z_ ∈ closure (z '' univ)) (α : ℕ → ℕ) (monoa : StrictMono α) (conv : Tendsto (fun n => z (α n)) atTop (𝓝 z_))
  (ρ1 : ℝ) (ρ1pos : ρ1 > 0)
  (suff_des : ρ1 = (γ - 1) * ↑l ∧ ∀ (k : ℕ), ρ1 / 2 * ‖z (k + 1) - z k‖ ^ 2 ≤ ψ (z k) - ψ (z (k + 1)))
  (z_in : z_ ∈ limit_set z) (final : ∀ (m : ℕ), ∃ n, m ≤ α n)
  (psiconv : Tendsto (fun n => ψ (z (α n))) atTop (𝓝 (ψ z_))) (monopsi : ∀ (m n : ℕ), ψ (z (m + n)) ≤ ψ (z m))
  (h : ∀ (n : ℕ), ψ (z (α n)) > ψ z_) (L1 : ∀ η > 0, ∃ l1, ∀ k ≥ l1, ψ z_ < ψ (z k) ∧ ψ (z k) < ψ z_ + η)
  (L2 : ∀ ε > 0, ∃ l2, ∀ k > l2, (EMetric.infEdist (z k) (limit_set z)).toReal < ε)
  (wklpt : ∀ z0 ∈ limit_set z, KL_point ψ z0) (cons : is_constant_on ψ (limit_set z)) (ε : ℝ) (eppos : ε ∈ Ioi 0)
  (η : ℝ) (etpos : η ∈ Ioi 0) (φ : ℝ → ℝ) (hφ : φ ∈ desingularizing_function η)
  (pro :
    ∀ u ∈ limit_set z,
      ∀ x ∈ {y | (EMetric.infEdist y (limit_set z)).toReal < ε} ∩ {y | ψ u < ψ y ∧ ψ y < ψ u + η},
        ENNReal.ofReal (deriv φ (ψ x - ψ u)) * EMetric.infEdist 0 (subdifferential ψ x) ≥ 1)
  (l1 : ℕ) (lem1 : ∀ k ≥ l1, ψ z_ < ψ (z k) ∧ ψ (z k) < ψ z_ + η) (l2 : ℕ)
  (lem2 : ∀ k > l2, (EMetric.infEdist (z k) (limit_set z)).toReal < ε) (n : ℕ) (ngt : n > l1 ⊔ l2) :
  ψ (z n) < ψ z_ + η := sorry

Tactic state before:
case intro.intro.intro.intro.intro.intro.intro.intro.right.a.right.right
E : Type u_1
F : Type u_2
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : InnerProductSpace ℝ E
inst✝⁵ : CompleteSpace E
inst✝⁴ : NormedAddCommGroup F
inst✝³ : InnerProductSpace ℝ F
inst✝² : CompleteSpace F
f : E → ℝ
g : F → ℝ
H : WithLp 2 (E × F) → ℝ
x0 : E
y0 : F
l : NNReal
alg : BCD f g H l x0 y0
inst✝¹ : ProperSpace E
inst✝ : ProperSpace F
γ : ℝ
hγ : γ > 1
ck : ∀ (k : ℕ), alg.c k = 1 / (γ * ↑l)
dk : ∀ (k : ℕ), alg.d k = 1 / (γ * ↑l)
bd : Bornology.IsBounded (z '' univ)
hψ : KL_function ψ
lbdψ : BddBelow (ψ '' univ)
z_ : WithLp 2 (E × F)
left✝ : z_ ∈ closure (z '' univ)
α : ℕ → ℕ
monoa : StrictMono α
conv : Tendsto (fun n => z (α n)) atTop (𝓝 z_)
ρ1 : ℝ
ρ1pos : ρ1 > 0
suff_des : ρ1 = (γ - 1) * ↑l ∧ ∀ (k : ℕ), ρ1 / 2 * ‖z (k + 1) - z k‖ ^ 2 ≤ ψ (z k) - ψ (z (k + 1))
z_in : z_ ∈ limit_set z
final : ∀ (m : ℕ), ∃ n, m ≤ α n
psiconv : Tendsto (fun n => ψ (z (α n))) atTop (𝓝 (ψ z_))
monopsi : ∀ (m n : ℕ), ψ (z (m + n)) ≤ ψ (z m)
h : ∀ (n : ℕ), ψ (z (α n)) > ψ z_
L1 : ∀ η > 0, ∃ l1, ∀ k ≥ l1, ψ z_ < ψ (z k) ∧ ψ (z k) < ψ z_ + η
L2 : ∀ ε > 0, ∃ l2, ∀ k > l2, (EMetric.infEdist (z k) (limit_set z)).toReal < ε
wklpt : ∀ z0 ∈ limit_set z, KL_point ψ z0
cons : is_constant_on ψ (limit_set z)
ε : ℝ
eppos : ε ∈ Ioi 0
η : ℝ
etpos : η ∈ Ioi 0
φ : ℝ → ℝ
hφ : φ ∈ desingularizing_function η
pro :
  ∀ u ∈ limit_set z,
    ∀ x ∈ {y | (EMetric.infEdist y (limit_set z)).toReal < ε} ∩ {y | ψ u < ψ y ∧ ψ y < ψ u + η},
      ENNReal.ofReal (deriv φ (ψ x - ψ u)) * EMetric.infEdist 0 (subdifferential ψ x) ≥ 1
l1 : ℕ
lem1 : ∀ k ≥ l1, ψ z_ < ψ (z k) ∧ ψ (z k) < ψ z_ + η
l2 : ℕ
lem2 : ∀ k > l2, (EMetric.infEdist (z k) (limit_set z)).toReal < ε
n : ℕ
ngt : n > l1 ⊔ l2
⊢ ψ (z n) < ψ z_ + η

Tactic:
exact (lem1 n (le_of_lt (lt_of_le_of_lt (le_max_left l1 l2) ngt))).2

Tactic state after: