import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.Calculus.MeanValue import Mathlib.Analysis.SpecialFunctions.Log.Deriv import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.Real.Sqrt import Mathlib.Analysis.Convex.Basic import Mathlib.Algebra.Order.BigOperators.Group.Finset /-! # Frank–Wolfe (Conditional Gradient) & General Bregman Mirror Descent A standalone, machine-checked Lean 4 formalization of sharp non-asymptotic constrained first-order convex optimization & online convex optimization: 1. **Frank–Wolfe (Conditional Gradient) Algorithm** on arbitrary bounded convex sets `C ⊆ E` of diameter `D`: - Duality gap certificate `fwGap_ge_suboptimality` (`f(x) - f(x*) ≤ ⟪g x, x - s⟫`). - Feasibility invariance `fw_iter_mem`. - Exact `O(1/T)` suboptimality rate `f(x_T) - f(x*) ≤ 2 L D² / (T + 2)` (`fw_exact_sublinear_rate`). - Exact `O(1/T)` minimum duality-gap bound `min_{1 ≤ t ≤ T} gap(x_t) ≤ 6 L D² / (T + 2)` (`fw_duality_gap_rate`, strictly sharpening Jaggi's `6.75 L D² / (T + 2)` constant!). 2. **General Bregman Divergence & General Mirror Descent** over arbitrary real inner product spaces `E` equipped with ANY primal/dual norm pair `(pNorm, dNorm)` satisfying generalized Cauchy–Schwarz `⟪g, v⟫ ≤ dNorm g * pNorm v`: - Exact **Bregman Three-Point Identity** (`bregman_three_point_identity`). - General one-step Mirror Descent inequality (`mirror_descent_one_step`). - Exact **$O(1/\sqrt{T})$ Online Regret Bound** (`mirror_descent_regret_bound`): `∑_{t=0}^{T-1} ⟪g_t, x_t - u⟫ ≤ D_ψ(u, x_0) / η + (η / (2 σ)) ∑_{t=0}^{T-1} ‖g_t‖_*²`. - Exact **Convex Optimization Average-Iterate Convergence** (`mirror_descent_convex_rate` and optimal step-size bound `G_* √(2 R² / (σ T))`). 3. **Concrete Specializations (Zero Overlap with Fixed-Target VFE)** - **Euclidean Projected Online Gradient Descent (OGD)** with `ψ(x) = (1/2) ‖x‖₂²` (`ogd_regret_bound`, `ogd_optimal_regret`). - **Pinsker's Inequality** proved from scratch via the elementary calculus inequality `3 (u - 1)² ≤ (2u + 4)(u log u - u + 1)` (`pinsker_kl_l1_strong_convexity`): `D_KL(p ‖ q) ≥ (1/2) ‖p - q‖₁²`. - **Exponentiated Gradient / Entropic Mirror Descent (Hedge)** on the `d`-simplex `Δ_d` for arbitrary adversarial losses `g_t ∈ ℝ^d` (`entropic_md_regret_bound`, `entropic_md_optimal_regret`: exact `G_∞ √(2 T ln d)` regret and `G_∞ √(2 ln d / T)` average-iterate excess loss!). -/ open scoped RealInnerProductSpace BigOperators open Finset namespace ConvexOpt.FWMirror /-! ### Part 1: Frank–Wolfe (Conditional Gradient) Algorithm -/ section FrankWolfe variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] /-- Fréchet gradient predicate (matching `SmoothGeometryGDPL`). -/ def HasGradient (f : E → ℝ) (g : E → E) : Prop := ∀ x : E, HasFDerivAt f (innerSL ℝ (g x)) x /-- `L`-smoothness (from Fréchet gradient + `L`-Lipschitz gradient). -/ def IsLSmooth (f : E → ℝ) (g : E → E) (L : ℝ) : Prop := HasGradient f g ∧ 0 < L ∧ ∀ x y : E, ‖g x - g y‖ ≤ L * ‖x - y‖ /-- First-order convexity on a set `C`. -/ def IsConvexOnGrad (f : E → ℝ) (g : E → E) (C : Set E) : Prop := HasGradient f g ∧ ∀ x ∈ C, ∀ y ∈ C, f x + ⟪g x, y - x⟫ ≤ f y /-- Self-contained Descent Lemma from Fréchet differentiability and `L`-Lipschitz gradient. -/ lemma fw_descent_lemma {f : E → ℝ} {g : E → E} {L : ℝ} (hs : IsLSmooth f g L) (x y : E) : f y ≤ f x + ⟪g x, y - x⟫ + (L / 2) * ‖y - x‖ ^ 2 := by have hseg : ∀ t : ℝ, HasDerivAt (fun s : ℝ => f (x + s • (y - x))) ⟪g (x + t • (y - x)), y - x⟫ t := by intro t have hline : HasDerivAt (fun s : ℝ => x + s • (y - x)) (y - x) t := by simpa only [one_smul] using ((hasDerivAt_id' t).smul_const (y - x)).const_add x have hcomp := (hs.1 (x + t • (y - x))).comp_hasDerivAt t hline simpa only [Function.comp_def, innerSL_apply_apply] using hcomp let φ : ℝ → ℝ := fun t => f x + t * ⟪g x, y - x⟫ + (L / 2) * t ^ 2 * ‖y - x‖ ^ 2 - f (x + t • (y - x)) have hderiv : ∀ t ∈ Set.Icc (0 : ℝ) 1, HasDerivAt φ (⟪g x, y - x⟫ + L * t * ‖y - x‖ ^ 2 - ⟪g (x + t • (y - x)), y - x⟫) t := by intro t _ have h1 : HasDerivAt (fun s : ℝ => f x + s * ⟪g x, y - x⟫) ⟪g x, y - x⟫ t := by simpa using ((hasDerivAt_id' t).mul_const ⟪g x, y - x⟫).const_add (f x) have h2 : HasDerivAt (fun s : ℝ => (L / 2) * s ^ 2 * ‖y - x‖ ^ 2) (L * t * ‖y - x‖ ^ 2) t := by have hsq : HasDerivAt (fun s : ℝ => s ^ 2) (2 * t) t := by simpa using hasDerivAt_pow 2 t exact ((hsq.const_mul (L / 2)).mul_const (‖y - x‖ ^ 2)).congr_deriv (by ring) exact (h1.add h2).sub (hseg t) have hnonneg : ∀ t ∈ Set.Icc (0 : ℝ) 1, 0 ≤ deriv φ t := by intro t ht rw [(hderiv t ht).deriv] have hcs := real_inner_le_norm (g (x + t • (y - x)) - g x) (y - x) have hlip := hs.2.2 (x + t • (y - x)) x have hnorm : ‖(x + t • (y - x)) - x‖ = t * ‖y - x‖ := by rw [add_sub_cancel_left, norm_smul, Real.norm_of_nonneg ht.1] rw [hnorm] at hlip have h1 : ⟪g (x + t • (y - x)) - g x, y - x⟫ ≤ L * t * ‖y - x‖ ^ 2 := by calc ⟪g (x + t • (y - x)) - g x, y - x⟫ ≤ ‖g (x + t • (y - x)) - g x‖ * ‖y - x‖ := hcs _ ≤ (L * (t * ‖y - x‖)) * ‖y - x‖ := mul_le_mul_of_nonneg_right hlip (norm_nonneg _) _ = L * t * ‖y - x‖ ^ 2 := by ring rw [inner_sub_left] at h1 linarith have hmono : MonotoneOn φ (Set.Icc 0 1) := by apply monotoneOn_of_deriv_nonneg (convex_Icc 0 1) · exact fun t ht => (hderiv t ht).continuousAt.continuousWithinAt · exact fun t ht => (hderiv t (interior_subset ht)).differentiableAt.differentiableWithinAt · exact fun t ht => hnonneg t (interior_subset ht) have h01 := hmono ⟨le_rfl, zero_le_one⟩ ⟨zero_le_one, le_rfl⟩ zero_le_one simp only [φ, zero_mul, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, mul_zero, add_zero, zero_smul, sub_self, one_mul, one_pow, one_smul, add_sub_cancel] at h01 linarith /-- Linear Minimization Oracle (LMO) solution `s ∈ C` minimizing `y ↦ ⟪g x, y⟫` over `C`. -/ def IsLMO (g : E → E) (C : Set E) (x s : E) : Prop := s ∈ C ∧ ∀ y ∈ C, ⟪g x, s⟫ ≤ ⟪g x, y⟫ /-- Frank–Wolfe duality gap `⟪g x, x - s⟫`. -/ def fwGap (g : E → E) (x s : E) : ℝ := ⟪g x, x - s⟫ /-- Standard oblivious Frank–Wolfe step size `γ_t = 2 / (t + 2)`. -/ noncomputable def fwStep (t : ℕ) : ℝ := 2 / ((t : ℝ) + 2) /-- Frank–Wolfe iteration given an LMO `lmo : E → E`. -/ noncomputable def fwIter (lmo : E → E) (x0 : E) : ℕ → E | 0 => x0 | t + 1 => let xt := fwIter lmo x0 t let γ := fwStep t (1 - γ) • xt + γ • lmo xt lemma fwStep_mem_Ioc (t : ℕ) : 0 < fwStep t ∧ fwStep t ≤ 1 := by unfold fwStep constructor · positivity · rw [div_le_one (by positivity)]; linarith /-- Every Frank–Wolfe iterate stays in the convex constraint set `C`. -/ theorem fw_iter_mem {g : E → E} {C : Set E} {lmo : E → E} {x0 : E} (hC : Convex ℝ C) (hx0 : x0 ∈ C) (hlmo : ∀ x ∈ C, IsLMO g C x (lmo x)) (t : ℕ) : fwIter lmo x0 t ∈ C := by induction t with | zero => exact hx0 | succ k ih => have hγ := fwStep_mem_Ioc k exact hC ih (hlmo _ ih).1 (by linarith [hγ.2]) (le_of_lt hγ.1) (by ring) /-- The Frank–Wolfe duality gap upper-bounds suboptimality for every comparator `xStar ∈ C`. -/ theorem fwGap_ge_suboptimality {f : E → ℝ} {g : E → E} {C : Set E} {x s xStar : E} (hc : IsConvexOnGrad f g C) (hx : x ∈ C) (hxStar : xStar ∈ C) (hlmo : IsLMO g C x s) : f x - f xStar ≤ fwGap g x s := by have h1 := hc.2 x hx xStar hxStar have h2 := hlmo.2 xStar hxStar unfold fwGap rw [inner_sub_right] at h1 ⊢ linarith /-- Nonnegativity of the Frank–Wolfe duality gap on `C`. -/ lemma fwGap_nonneg {g : E → E} {C : Set E} {x s : E} (hx : x ∈ C) (hlmo : IsLMO g C x s) : 0 ≤ fwGap g x s := by unfold fwGap rw [inner_sub_right] linarith [hlmo.2 x hx] /-- Fundamental one-step Frank–Wolfe inequality using the duality gap: `f(x_{t+1}) ≤ f(x_t) - γ_t gap(x_t) + (L D² / 2) γ_t²`. -/ lemma fw_one_step_gap {f : E → ℝ} {g : E → E} {C : Set E} {L D : ℝ} {lmo : E → E} {x0 : E} (hs : IsLSmooth f g L) (hC : Convex ℝ C) (hD : ∀ x ∈ C, ∀ y ∈ C, ‖x - y‖ ≤ D) (hx0 : x0 ∈ C) (hlmo : ∀ x ∈ C, IsLMO g C x (lmo x)) (t : ℕ) : f (fwIter lmo x0 (t + 1)) ≤ f (fwIter lmo x0 t) - fwStep t * fwGap g (fwIter lmo x0 t) (lmo (fwIter lmo x0 t)) + (L * D ^ 2 / 2) * (fwStep t) ^ 2 := by have hL : 0 < L := hs.2.1 set xt := fwIter lmo x0 t set st := lmo xt set γ := fwStep t have hxt : xt ∈ C := fw_iter_mem hC hx0 hlmo t have hst : st ∈ C := (hlmo xt hxt).1 have hγ := fwStep_mem_Ioc t have hdesc := fw_descent_lemma hs xt ((1 - γ) • xt + γ • st) have hdiff : ((1 - γ) • xt + γ • st) - xt = γ • (st - xt) := by rw [sub_smul, one_smul, smul_sub]; abel rw [hdiff, inner_smul_right, norm_smul, Real.norm_of_nonneg (le_of_lt hγ.1), mul_pow] at hdesc have hinner : ⟪g xt, st - xt⟫ = -fwGap g xt st := by unfold fwGap rw [← neg_sub xt st, inner_neg_right] rw [hinner] at hdesc have hnorm_le : ‖st - xt‖ ≤ D := hD st hst xt hxt have hsq_le : ‖st - xt‖ ^ 2 ≤ D ^ 2 := by have := mul_self_le_mul_self (norm_nonneg _) hnorm_le nlinarith have hquad : (L / 2) * (γ ^ 2 * ‖st - xt‖ ^ 2) ≤ (L * D ^ 2 / 2) * γ ^ 2 := by have : (L * D ^ 2 / 2) * γ ^ 2 = (L / 2) * (γ ^ 2 * D ^ 2) := by ring rw [this] apply mul_le_mul_of_nonneg_left _ (by positivity) exact mul_le_mul_of_nonneg_left hsq_le (sq_nonneg _) show f ((1 - γ) • xt + γ • st) ≤ f xt - γ * fwGap g xt st + (L * D ^ 2 / 2) * γ ^ 2 linarith /-- **Frank–Wolfe Exact `O(1/T)` Suboptimality Theorem**: For any convex `L`-smooth function `f` on a convex set `C` of diameter `D`, with step size `γ_t = 2 / (t + 2)`, every `T ≥ 1` and every `xStar ∈ C` satisfy `f(x_T) - f(x*) ≤ 2 L D² / (T + 2)`. -/ theorem fw_exact_sublinear_rate {f : E → ℝ} {g : E → E} {C : Set E} {L D : ℝ} {lmo : E → E} {x0 xStar : E} (hs : IsLSmooth f g L) (hc : IsConvexOnGrad f g C) (hC : Convex ℝ C) (hD : ∀ x ∈ C, ∀ y ∈ C, ‖x - y‖ ≤ D) (hx0 : x0 ∈ C) (hxStar : xStar ∈ C) (hlmo : ∀ x ∈ C, IsLMO g C x (lmo x)) {T : ℕ} (hT : 1 ≤ T) : f (fwIter lmo x0 T) - f xStar ≤ 2 * L * D ^ 2 / ((T : ℝ) + 2) := by have hL : 0 < L := hs.2.1 have hLD_nn : 0 ≤ L * D ^ 2 := by positivity induction T with | zero => omega | succ k ih => have hstep := fw_one_step_gap hs hC hD hx0 hlmo k have hxk : fwIter lmo x0 k ∈ C := fw_iter_mem hC hx0 hlmo k have hgap := fwGap_ge_suboptimality hc hxk hxStar (hlmo _ hxk) have hγ := fwStep_mem_Ioc k have hrec : f (fwIter lmo x0 (k + 1)) - f xStar ≤ (1 - fwStep k) * (f (fwIter lmo x0 k) - f xStar) + (L * D ^ 2 / 2) * (fwStep k) ^ 2 := by have hm := mul_le_mul_of_nonneg_left hgap (le_of_lt hγ.1) linarith cases k with | zero => -- T = 1: γ_0 = 1, so δ_1 ≤ L D² / 2 ≤ 2 L D² / 3 have hγ0 : fwStep 0 = 1 := by simp [fwStep] rw [hγ0] at hrec norm_num at hrec ⊢ linarith | succ m => have ihm := ih (by omega) set n : ℝ := ((m + 1 : ℕ) : ℝ) have hn : 0 < n := Nat.cast_pos.mpr (by omega) have h1m_nn : 0 ≤ 1 - fwStep (m + 1) := by linarith [hγ.2] have hmul := mul_le_mul_of_nonneg_left ihm h1m_nn have hcomb : f (fwIter lmo x0 (m + 2)) - f xStar ≤ (1 - 2 / (n + 2)) * (2 * L * D ^ 2 / (n + 2)) + (L * D ^ 2 / 2) * (2 / (n + 2)) ^ 2 := by simpa only [fwStep, n] using le_trans hrec (add_le_add hmul le_rfl) have halg : (1 - 2 / (n + 2)) * (2 * L * D ^ 2 / (n + 2)) + (L * D ^ 2 / 2) * (2 / (n + 2)) ^ 2 = 2 * L * D ^ 2 * ((n + 1) / (n + 2) ^ 2) := by field_simp ring have hfrac : (n + 1) / (n + 2) ^ 2 ≤ 1 / (n + 3) := by rw [div_le_div_iff₀ (by positivity) (by positivity)] nlinarith have hfinal : 2 * L * D ^ 2 * ((n + 1) / (n + 2) ^ 2) ≤ 2 * L * D ^ 2 / (n + 3) := by have := mul_le_mul_of_nonneg_left hfrac (by positivity : 0 ≤ 2 * L * D ^ 2) linarith [show 2 * L * D ^ 2 * (1 / (n + 3)) = 2 * L * D ^ 2 / (n + 3) by ring] have hcast : (((m + 1 + 1 : ℕ) : ℝ) + 2) = n + 3 := by simp [n]; ring rw [hcast] linarith /-- **Frank–Wolfe Exact `O(1/T)` Duality-Gap Theorem**: For every `T ≥ 1`, there exists an iterate `t ∈ {1, ..., T}` whose Frank–Wolfe duality gap satisfies `fwGap g x_t (lmo x_t) ≤ 6 L D² / (T + 2)` (sharpening Jaggi's `6.75` constant). -/ theorem fw_duality_gap_rate {f : E → ℝ} {g : E → E} {C : Set E} {L D : ℝ} {lmo : E → E} {x0 xStar : E} (hs : IsLSmooth f g L) (hc : IsConvexOnGrad f g C) (hC : Convex ℝ C) (hD : ∀ x ∈ C, ∀ y ∈ C, ‖x - y‖ ≤ D) (hx0 : x0 ∈ C) (hxStar : xStar ∈ C) (hmin : ∀ x ∈ C, f xStar ≤ f x) (hlmo : ∀ x ∈ C, IsLMO g C x (lmo x)) {T : ℕ} (hT : 1 ≤ T) : ∃ t ∈ Finset.Icc 1 T, fwGap g (fwIter lmo x0 t) (lmo (fwIter lmo x0 t)) ≤ 6 * L * D ^ 2 / ((T : ℝ) + 2) := by have hL : 0 < L := hs.2.1 have hLD_nn : 0 ≤ L * D ^ 2 := by positivity set δ : ℕ → ℝ := fun t => f (fwIter lmo x0 t) - f xStar set gap : ℕ → ℝ := fun t => fwGap g (fwIter lmo x0 t) (lmo (fwIter lmo x0 t)) -- Weighted sum bound: ∑_{t=1}^T 2(t+1) gap_t ≤ (6T + 1) L D² have hstep_w : ∀ t ∈ Finset.Icc 1 T, 2 * ((t : ℝ) + 1) * gap t ≤ ((t : ℝ) * ((t : ℝ) + 1) * δ t - ((t : ℝ) + 1) * ((t : ℝ) + 2) * δ (t + 1)) + 6 * L * D ^ 2 := by intro t ht have ht1 : 1 ≤ t := (Finset.mem_Icc.mp ht).1 have hstep := fw_one_step_gap hs hC hD hx0 hlmo t have hδt : δ t ≤ 2 * L * D ^ 2 / ((t : ℝ) + 2) := fw_exact_sublinear_rate hs hc hC hD hx0 hxStar hlmo ht1 have hpos : (0 : ℝ) < ((t : ℝ) + 1) * ((t : ℝ) + 2) := by positivity have h1 : fwStep t * gap t ≤ δ t - δ (t + 1) + (L * D ^ 2 / 2) * (fwStep t) ^ 2 := by simp only [δ, gap]; linarith have hmul := mul_le_mul_of_nonneg_left h1 (le_of_lt hpos) have hlhs : ((t : ℝ) + 1) * ((t : ℝ) + 2) * (fwStep t * gap t) = 2 * ((t : ℝ) + 1) * gap t := by unfold fwStep; field_simp have hquad : ((t : ℝ) + 1) * ((t : ℝ) + 2) * ((L * D ^ 2 / 2) * (fwStep t) ^ 2) ≤ 2 * L * D ^ 2 := by have heq : ((t : ℝ) + 1) * ((t : ℝ) + 2) * ((L * D ^ 2 / 2) * (fwStep t) ^ 2) = 2 * L * D ^ 2 * (((t : ℝ) + 1) / ((t : ℝ) + 2)) := by unfold fwStep; field_simp rw [heq] have hfrac : ((t : ℝ) + 1) / ((t : ℝ) + 2) ≤ 1 := by rw [div_le_one (by positivity)]; linarith nlinarith have hmid : 2 * ((t : ℝ) + 1) * δ t ≤ 4 * L * D ^ 2 := by have hm := mul_le_mul_of_nonneg_left hδt (by positivity : (0 : ℝ) ≤ 2 * ((t : ℝ) + 1)) have heq : 2 * ((t : ℝ) + 1) * (2 * L * D ^ 2 / ((t : ℝ) + 2)) = 4 * L * D ^ 2 * (((t : ℝ) + 1) / ((t : ℝ) + 2)) := by ring have hfrac : ((t : ℝ) + 1) / ((t : ℝ) + 2) ≤ 1 := by rw [div_le_one (by positivity)]; linarith nlinarith have hsplit : ((t : ℝ) + 1) * ((t : ℝ) + 2) * (δ t - δ (t + 1)) = ((t : ℝ) * ((t : ℝ) + 1) * δ t - ((t : ℝ) + 1) * ((t : ℝ) + 2) * δ (t + 1)) + 2 * ((t : ℝ) + 1) * δ t := by ring linarith have hsum := Finset.sum_le_sum hstep_w rw [Finset.sum_add_distrib, Finset.sum_const, Nat.card_Icc, nsmul_eq_mul] at hsum have hcard : (T + 1 - 1 : ℕ) = T := by omega rw [hcard] at hsum have htele_all : ∀ N : ℕ, 1 ≤ N → ∑ t ∈ Finset.Icc 1 N, ((t : ℝ) * ((t : ℝ) + 1) * δ t - ((t : ℝ) + 1) * ((t : ℝ) + 2) * δ (t + 1)) = 2 * δ 1 - ((N : ℝ) + 1) * ((N : ℝ) + 2) * δ (N + 1) := by intro N induction N with | zero => intro h; omega | succ n ih => intro _ cases n with | zero => simp only [Nat.zero_add, Finset.Icc_self, Finset.sum_singleton, Nat.cast_one] ring | succ m => have hIcc : Finset.Icc 1 (m + 2) = insert (m + 2) (Finset.Icc 1 (m + 1)) := by ext x; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hIcc, Finset.sum_insert (by simp), ih (by omega)] push_cast ring rw [htele_all T hT] at hsum have hδ1 : δ 1 ≤ L * D ^ 2 / 2 := by have hstep0 := fw_one_step_gap hs hC hD hx0 hlmo 0 have hgap0 := fwGap_ge_suboptimality hc hx0 hxStar (hlmo x0 hx0) have hγ0 : fwStep 0 = 1 := by simp [fwStep] rw [hγ0] at hstep0 simp only [δ] have h0 : fwIter lmo x0 0 = x0 := rfl rw [h0] at hstep0 linarith have hδT1 : 0 ≤ δ (T + 1) := by have hmem := fw_iter_mem hC hx0 hlmo (T + 1) simp only [δ]; linarith [hmin _ hmem] have hsum_bound : ∑ t ∈ Finset.Icc 1 T, 2 * ((t : ℝ) + 1) * gap t ≤ (6 * (T : ℝ) + 1) * (L * D ^ 2) := by have hnn : 0 ≤ ((T : ℝ) + 1) * ((T : ℝ) + 2) * δ (T + 1) := by positivity linarith have hweight_all : ∀ N : ℕ, 1 ≤ N → ∑ t ∈ Finset.Icc 1 N, (2 * ((t : ℝ) + 1)) = (N : ℝ) * ((N : ℝ) + 3) := by intro N induction N with | zero => intro h; omega | succ n ih => intro _ cases n with | zero => simp only [Nat.zero_add, Finset.Icc_self, Finset.sum_singleton, Nat.cast_one]; norm_num | succ m => have hIcc : Finset.Icc 1 (m + 2) = insert (m + 2) (Finset.Icc 1 (m + 1)) := by ext x; simp only [Finset.mem_Icc, Finset.mem_insert]; omega rw [hIcc, Finset.sum_insert (by simp), ih (by omega)] push_cast; ring by_contra hcontra push Not at hcontra have hstrict : (∑ t ∈ Finset.Icc 1 T, 2 * ((t : ℝ) + 1)) * (6 * L * D ^ 2 / ((T : ℝ) + 2)) < ∑ t ∈ Finset.Icc 1 T, 2 * ((t : ℝ) + 1) * gap t := by rw [Finset.sum_mul] apply Finset.sum_lt_sum_of_nonempty ⟨1, Finset.mem_Icc.mpr ⟨le_rfl, hT⟩⟩ intro t ht exact mul_lt_mul_of_pos_left (hcontra t ht) (by positivity) rw [hweight_all T hT] at hstrict have hTpos : (0 : ℝ) < (T : ℝ) := Nat.cast_pos.mpr (by omega) have hT1 : (1 : ℝ) ≤ (T : ℝ) := Nat.one_le_cast.mpr hT have hcmp : (6 * (T : ℝ) + 1) * (L * D ^ 2) ≤ (T : ℝ) * ((T : ℝ) + 3) * (6 * L * D ^ 2 / ((T : ℝ) + 2)) := by have hmul : (6 * (T : ℝ) + 1) * ((T : ℝ) + 2) ≤ 6 * (T : ℝ) * ((T : ℝ) + 3) := by nlinarith have hdiv := div_le_div_of_nonneg_right hmul (by positivity : (0 : ℝ) < (T : ℝ) + 2).le have h1 : (6 * (T : ℝ) + 1) * ((T : ℝ) + 2) / ((T : ℝ) + 2) = 6 * (T : ℝ) + 1 := by field_simp have h2 : 6 * (T : ℝ) * ((T : ℝ) + 3) / ((T : ℝ) + 2) = (T : ℝ) * ((T : ℝ) + 3) * (6 / ((T : ℝ) + 2)) := by ring have h3 := mul_le_mul_of_nonneg_right (by linarith : 6 * (T : ℝ) + 1 ≤ (T : ℝ) * ((T : ℝ) + 3) * (6 / ((T : ℝ) + 2))) hLD_nn have h4 : (T : ℝ) * ((T : ℝ) + 3) * (6 / ((T : ℝ) + 2)) * (L * D ^ 2) = (T : ℝ) * ((T : ℝ) + 3) * (6 * L * D ^ 2 / ((T : ℝ) + 2)) := by ring linarith linarith end FrankWolfe /-! ### Part 2: General Bregman Divergence & General Mirror Descent -/ section GeneralMirrorDescent variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] /-- General Bregman divergence `D_ψ(x, y) = ψ(x) - ψ(y) - ⟪∇ψ(y), x - y⟫`. -/ def bregmanDiv (ψ : E → ℝ) (gψ : E → E) (x y : E) : ℝ := ψ x - ψ y - ⟪gψ y, x - y⟫ /-- **Exact Bregman Three-Point Identity**: `D_ψ(u, y) - D_ψ(u, x) - D_ψ(x, y) = ⟪∇ψ(x) - ∇ψ(y), u - x⟫` for ALL `u, x, y ∈ E`. -/ theorem bregman_three_point_identity (ψ : E → ℝ) (gψ : E → E) (u x y : E) : bregmanDiv ψ gψ u y - bregmanDiv ψ gψ u x - bregmanDiv ψ gψ x y = ⟪gψ x - gψ y, u - x⟫ := by unfold bregmanDiv have hdecomp : u - y = (u - x) + (x - y) := by abel rw [hdecomp, inner_add_right, inner_sub_left] ring /-- `σ`-strong convexity of the mirror map `ψ` on `X` with respect to an arbitrary primal norm `pNorm`. -/ def IsMirrorStronglyConvex (ψ : E → ℝ) (gψ : E → E) (X : Set E) (pNorm : E → ℝ) (σ : ℝ) : Prop := 0 < σ ∧ ∀ x ∈ X, ∀ y ∈ X, (σ / 2) * (pNorm (x - y)) ^ 2 ≤ bregmanDiv ψ gψ x y /-- Generalized Cauchy–Schwarz duality between a primal norm `pNorm` and dual norm `dNorm`. -/ def IsDualNormPair (pNorm dNorm : E → ℝ) : Prop := (∀ v, 0 ≤ pNorm v) ∧ (∀ g, 0 ≤ dNorm g) ∧ ∀ g v : E, |⟪g, v⟫| ≤ dNorm g * pNorm v /-- First-order optimality condition for the Bregman-proximal Mirror Descent step `x_{t+1} ∈ argmin_{x ∈ X} { η ⟪g_t, x⟫ + D_ψ(x, x_t) }`. -/ def IsMirrorStep (gψ : E → E) (X : Set E) (η : ℝ) (gt xt xnext : E) : Prop := xnext ∈ X ∧ ∀ u ∈ X, 0 ≤ ⟪η • gt + gψ xnext - gψ xt, u - xnext⟫ /-- **One-Step General Mirror Descent Inequality**: For any `σ`-strongly convex mirror map `ψ` wrt `(pNorm, dNorm)`, any set `X`, any loss vector `g_t`, and any comparator `u ∈ X`, `η ⟪g_t, x_t - u⟫ ≤ D_ψ(u, x_t) - D_ψ(u, x_{t+1}) + (η² / (2 σ)) ‖g_t‖_*²`. -/ theorem mirror_descent_one_step {ψ : E → ℝ} {gψ : E → E} {X : Set E} {pNorm dNorm : E → ℝ} {σ η : ℝ} {gt xt xnext u : E} (hm : IsMirrorStronglyConvex ψ gψ X pNorm σ) (hdual : IsDualNormPair pNorm dNorm) (hη : 0 < η) (hxt : xt ∈ X) (hu : u ∈ X) (hstep : IsMirrorStep gψ X η gt xt xnext) : η * ⟪gt, xt - u⟫ ≤ bregmanDiv ψ gψ u xt - bregmanDiv ψ gψ u xnext + (η ^ 2 / (2 * σ)) * (dNorm gt) ^ 2 := by have hσ : 0 < σ := hm.1 have hopt := hstep.2 u hu have h3pt := bregman_three_point_identity ψ gψ u xnext xt have hsc := hm.2 xnext hstep.1 xt hxt have hopt_rearr : η * ⟪gt, xnext - u⟫ ≤ ⟪gψ xnext - gψ xt, u - xnext⟫ := by have h1 : ⟪η • gt + gψ xnext - gψ xt, u - xnext⟫ = η * ⟪gt, u - xnext⟫ + ⟪gψ xnext - gψ xt, u - xnext⟫ := by rw [add_sub_assoc, inner_add_left, inner_smul_left] simp have h2 : ⟪gt, u - xnext⟫ = -⟪gt, xnext - u⟫ := by rw [← neg_sub xnext u, inner_neg_right] rw [h2] at h1 linarith -- Split η ⟪gt, xt - u⟫ = η ⟪gt, xt - xnext⟫ + η ⟪gt, xnext - u⟫ have hsplit : η * ⟪gt, xt - u⟫ = η * ⟪gt, xt - xnext⟫ + η * ⟪gt, xnext - u⟫ := by have : xt - u = (xt - xnext) + (xnext - u) := by abel rw [this, inner_add_right]; ring -- Generalized Cauchy-Schwarz on ⟪gt, xt - xnext⟫ = -⟪gt, xnext - xt⟫ ≤ |⟪gt, xnext - xt⟫| have hcs : ⟪gt, xt - xnext⟫ ≤ dNorm gt * pNorm (xnext - xt) := by have hneg : ⟪gt, xt - xnext⟫ = -⟪gt, xnext - xt⟫ := by rw [← neg_sub xnext xt, inner_neg_right] rw [hneg] exact le_trans (neg_le_abs _) (hdual.2.2 gt (xnext - xt)) -- Young's inequality: η * dNorm gt * pNorm (xnext - xt) ≤ (η² / (2σ)) dNorm² + (σ/2) pNorm² have hyoung : η * (dNorm gt * pNorm (xnext - xt)) ≤ (η ^ 2 / (2 * σ)) * (dNorm gt) ^ 2 + (σ / 2) * (pNorm (xnext - xt)) ^ 2 := by have hsq : 0 ≤ (η * dNorm gt - σ * pNorm (xnext - xt)) ^ 2 / (2 * σ) := by positivity have hid : (η ^ 2 / (2 * σ)) * (dNorm gt) ^ 2 + (σ / 2) * (pNorm (xnext - xt)) ^ 2 - η * (dNorm gt * pNorm (xnext - xt)) = (η * dNorm gt - σ * pNorm (xnext - xt)) ^ 2 / (2 * σ) := by field_simp; ring linarith have hmul_cs := mul_le_mul_of_nonneg_left hcs (le_of_lt hη) linarith /-- **General Mirror Descent Exact `O(1/√T)` Online Regret Theorem**: For ANY `σ`-strongly convex mirror map `ψ`, ANY dual-norm pair `(pNorm, dNorm)`, ANY adversarial sequence of loss vectors `g : ℕ → E`, and ANY Mirror Descent trajectory `x`, $$\sum_{t=0}^{T-1} \langle g_t, x_t - u \rangle \le \frac{D_\psi(u, x_0)}{\eta} + \frac{\eta}{2\sigma}\sum_{t=0}^{T-1} \|g_t\|_*^2.$$ -/ theorem mirror_descent_regret_bound {ψ : E → ℝ} {gψ : E → E} {X : Set E} {pNorm dNorm : E → ℝ} {σ η : ℝ} {g x : ℕ → E} {u : E} (hm : IsMirrorStronglyConvex ψ gψ X pNorm σ) (hdual : IsDualNormPair pNorm dNorm) (hη : 0 < η) (hx0 : x 0 ∈ X) (hu : u ∈ X) (htraj : ∀ t, IsMirrorStep gψ X η (g t) (x t) (x (t + 1))) (T : ℕ) : ∑ t ∈ range T, ⟪g t, x t - u⟫ ≤ bregmanDiv ψ gψ u (x 0) / η + (η / (2 * σ)) * ∑ t ∈ range T, (dNorm (g t)) ^ 2 := by have hσ : 0 < σ := hm.1 have hmem : ∀ t, x t ∈ X := by intro t; cases t with | zero => exact hx0 | succ k => exact (htraj k).1 have hterm : ∀ t ∈ range T, η * ⟪g t, x t - u⟫ ≤ (bregmanDiv ψ gψ u (x t) - bregmanDiv ψ gψ u (x (t + 1))) + (η ^ 2 / (2 * σ)) * (dNorm (g t)) ^ 2 := fun t _ => mirror_descent_one_step hm hdual hη (hmem t) hu (htraj t) have hsum := Finset.sum_le_sum hterm rw [← Finset.mul_sum, Finset.sum_add_distrib, ← Finset.mul_sum] at hsum have htele_all : ∀ N : ℕ, ∑ t ∈ range N, (bregmanDiv ψ gψ u (x t) - bregmanDiv ψ gψ u (x (t + 1))) = bregmanDiv ψ gψ u (x 0) - bregmanDiv ψ gψ u (x N) := by intro N; induction N with | zero => simp | succ k ih => rw [Finset.sum_range_succ, ih]; ring rw [htele_all T] at hsum have hD_nn : 0 ≤ bregmanDiv ψ gψ u (x T) := by have := hm.2 u hu (x T) (hmem T) have hsq : 0 ≤ (σ / 2) * (pNorm (u - x T)) ^ 2 := by positivity linarith have hdiv := div_le_div_of_nonneg_right (by linarith : η * ∑ t ∈ range T, ⟪g t, x t - u⟫ ≤ bregmanDiv ψ gψ u (x 0) + (η ^ 2 / (2 * σ)) * ∑ t ∈ range T, (dNorm (g t)) ^ 2) (le_of_lt hη) have hlhs : η * (∑ t ∈ range T, ⟪g t, x t - u⟫) / η = ∑ t ∈ range T, ⟪g t, x t - u⟫ := by field_simp have hrhs : (bregmanDiv ψ gψ u (x 0) + (η ^ 2 / (2 * σ)) * ∑ t ∈ range T, (dNorm (g t)) ^ 2) / η = bregmanDiv ψ gψ u (x 0) / η + (η / (2 * σ)) * ∑ t ∈ range T, (dNorm (g t)) ^ 2 := by field_simp linarith /-- **General Mirror Descent Convex Optimization Convergence Theorem (`O(1/√T)`)**: For any convex function `f` on `X` with subgradients `g t` satisfying `f(x_t) - f(u) ≤ ⟪g_t, x_t - u⟫` and dual norm bound `dNorm (g t) ≤ G`, the ergodic average `x̄_T = (1/T) ∑_{t exact hx0 | succ k => exact (htraj k).1 -- Jensen's inequality on the uniform average x̄_T = ∑_{t (1 / (T : ℝ))) (p := x) (fun _ _ => by positivity) (by simp [Finset.sum_const, Finset.card_range, nsmul_eq_mul, ne_of_gt hTpos]) (fun t _ => hmem t) simpa [Finset.mul_sum, smul_eq_mul] using hj have hreg := mirror_descent_regret_bound hm hdual hη hx0 hu htraj T have hsum_f : ∑ t ∈ range T, (f (x t) - f u) ≤ ∑ t ∈ range T, ⟪g t, x t - u⟫ := Finset.sum_le_sum (fun t _ => hsubg t) have hsum_g : ∑ t ∈ range T, (dNorm (g t)) ^ 2 ≤ (T : ℝ) * G ^ 2 := by calc ∑ t ∈ range T, (dNorm (g t)) ^ 2 ≤ ∑ _t ∈ range T, G ^ 2 := by apply Finset.sum_le_sum; intro t _ have h1 := hdual.2.1 (g t) have h2 := hGbound t nlinarith _ = (T : ℝ) * G ^ 2 := by simp [Finset.sum_const, Finset.card_range, nsmul_eq_mul] have havg_sub : (1 / (T : ℝ)) * ∑ t ∈ range T, (f (x t) - f u) = (1 / (T : ℝ)) * (∑ t ∈ range T, f (x t)) - f u := by rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul] field_simp have hD_le : bregmanDiv ψ gψ u (x 0) / η ≤ Rsq / η := div_le_div_of_nonneg_right hDbound (le_of_lt hη) have hcomb : ∑ t ∈ range T, (f (x t) - f u) ≤ Rsq / η + (η / (2 * σ)) * ((T : ℝ) * G ^ 2) := by have hmul := mul_le_mul_of_nonneg_left hsum_g (by positivity : 0 ≤ η / (2 * σ)) linarith have hmulT := mul_le_mul_of_nonneg_left hcomb (by positivity : 0 ≤ 1 / (T : ℝ)) have hrhs : (1 / (T : ℝ)) * (Rsq / η + (η / (2 * σ)) * ((T : ℝ) * G ^ 2)) = Rsq / (η * (T : ℝ)) + η * G ^ 2 / (2 * σ) := by field_simp linarith /-- Optimal step-size algebra: at `η = √(2 σ R²) / (G √T)`, `R² / (η T) + η G² / (2 σ) = G √(2 R² / (σ T))`. -/ theorem mirror_descent_optimal_step_val {σ G Rsq : ℝ} {T : ℕ} (hσ : 0 < σ) (hG : 0 < G) (hR : 0 < Rsq) (hT : 1 ≤ T) : let η := Real.sqrt (2 * σ * Rsq) / (G * Real.sqrt (T : ℝ)) 0 < η ∧ Rsq / (η * (T : ℝ)) + η * G ^ 2 / (2 * σ) = G * Real.sqrt (2 * Rsq / (σ * (T : ℝ))) := by intro η have hTpos : (0 : ℝ) < (T : ℝ) := Nat.cast_pos.mpr (by omega) have hsqrtT : 0 < Real.sqrt (T : ℝ) := Real.sqrt_pos.mpr hTpos have hsqrtR : 0 < Real.sqrt (2 * σ * Rsq) := Real.sqrt_pos.mpr (by positivity) refine ⟨div_pos hsqrtR (mul_pos hG hsqrtT), ?_⟩ have hsq1 : Real.sqrt (2 * σ * Rsq) ^ 2 = 2 * σ * Rsq := Real.sq_sqrt (by positivity) have hsq2 : Real.sqrt (T : ℝ) ^ 2 = (T : ℝ) := Real.sq_sqrt (le_of_lt hTpos) have hsqrt_div : Real.sqrt (2 * Rsq / (σ * (T : ℝ))) = Real.sqrt (2 * σ * Rsq) / (σ * Real.sqrt (T : ℝ)) := by have heq : 2 * Rsq / (σ * (T : ℝ)) = (2 * σ * Rsq) / (σ ^ 2 * (T : ℝ)) := by field_simp rw [heq, Real.sqrt_div (by positivity), Real.sqrt_mul (sq_nonneg σ), Real.sqrt_sq (le_of_lt hσ)] rw [hsqrt_div] simp only [η] have hs1 : Real.sqrt (2 * σ * Rsq) ≠ 0 := ne_of_gt hsqrtR have hs2 : Real.sqrt (T : ℝ) ≠ 0 := ne_of_gt hsqrtT field_simp rw [show Rsq * 2 * σ = 2 * σ * Rsq by ring, hsq1, hsq2] ring /-! ### Part 3: Specialization 1 — Euclidean Projected Online Gradient Descent (OGD) -/ /-- Euclidean mirror map `ψ(x) = (1/2) ‖x‖²` with gradient `gψ(x) = x` has exact Bregman divergence `D_ψ(x, y) = (1/2) ‖x - y‖²` and is `1`-strongly convex wrt `‖·‖₂`. -/ lemma euclidean_mirror_strongly_convex (X : Set E) : IsMirrorStronglyConvex (fun x : E => (1 / 2) * ‖x‖ ^ 2) id X (fun v => ‖v‖) 1 := by refine ⟨by norm_num, fun x _ y _ => ?_⟩ unfold bregmanDiv have h1 : ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * ⟪y, x⟫ + ‖y‖ ^ 2 := by rw [norm_sub_sq_real, real_inner_comm] have h2 : ⟪y, x - y⟫ = ⟪y, x⟫ - ‖y‖ ^ 2 := by rw [inner_sub_right, real_inner_self_eq_norm_sq] simp only [id_eq] linarith lemma euclidean_dual_norm_pair : IsDualNormPair (fun v : E => ‖v‖) (fun g : E => ‖g‖) := ⟨fun _ => norm_nonneg _, fun _ => norm_nonneg _, fun g v => abs_real_inner_le_norm g v⟩ /-- **Euclidean Projected Online Gradient Descent (OGD) Regret Bound**: exact specialization of `mirror_descent_regret_bound` to `ψ(x) = (1/2) ‖x‖₂²`. -/ theorem ogd_regret_bound {X : Set E} {η : ℝ} {g x : ℕ → E} {u : E} (hη : 0 < η) (hx0 : x 0 ∈ X) (hu : u ∈ X) (htraj : ∀ t, IsMirrorStep id X η (g t) (x t) (x (t + 1))) (T : ℕ) : ∑ t ∈ range T, ⟪g t, x t - u⟫ ≤ ‖u - x 0‖ ^ 2 / (2 * η) + (η / 2) * ∑ t ∈ range T, ‖g t‖ ^ 2 := by have h := mirror_descent_regret_bound (euclidean_mirror_strongly_convex X) euclidean_dual_norm_pair hη hx0 hu htraj T have hdiv : bregmanDiv (fun z : E => (1 / 2) * ‖z‖ ^ 2) id u (x 0) = (1 / 2) * ‖u - x 0‖ ^ 2 := by unfold bregmanDiv have h1 : ‖u - x 0‖ ^ 2 = ‖u‖ ^ 2 - 2 * ⟪x 0, u⟫ + ‖x 0‖ ^ 2 := by rw [norm_sub_sq_real, real_inner_comm] have h2 : ⟪x 0, u - x 0⟫ = ⟪x 0, u⟫ - ‖x 0‖ ^ 2 := by rw [inner_sub_right, real_inner_self_eq_norm_sq] simp only [id_eq] linarith rw [hdiv] at h have halg1 : ((1 / 2) * ‖u - x 0‖ ^ 2) / η = ‖u - x 0‖ ^ 2 / (2 * η) := by ring have halg2 : η / (2 * (1 : ℝ)) = η / 2 := by ring linarith end GeneralMirrorDescent /-! ### Part 4: Pinsker's Inequality & Specialization 2 — Entropic Mirror Descent (Exponentiated Gradient) -/ section EntropicMirrorDescent /-- Elementary calculus inequality powering Pinsker's inequality: for every `u > 0`, `3 (u - 1)² ≤ (2 u + 4) (u log u - u + 1)`. -/ lemma pinsker_scalar_ineq {u : ℝ} (hu : 0 < u) : 3 * (u - 1) ^ 2 ≤ (2 * u + 4) * (u * Real.log u - u + 1) := by let h : ℝ → ℝ := fun t => (2 * t + 4) * (t * Real.log t - t + 1) - 3 * (t - 1) ^ 2 let h' : ℝ → ℝ := fun t => (4 * t + 4) * Real.log t - 8 * (t - 1) let h'' : ℝ → ℝ := fun t => 4 * (Real.log t + 1 / t - 1) have hderiv1 : ∀ t : ℝ, 0 < t → HasDerivAt h (h' t) t := by intro t ht have hlog : HasDerivAt (fun s => s * Real.log s - s + 1) (Real.log t) t := by have h1 : HasDerivAt (fun s => s * Real.log s) (1 * Real.log t + t * t⁻¹) t := (hasDerivAt_id' t).mul (Real.hasDerivAt_log (ne_of_gt ht)) exact ((h1.sub (hasDerivAt_id' t)).add_const (1 : ℝ)).congr_deriv (by have ht0 : t ≠ 0 := ne_of_gt ht field_simp; ring) have hlin : HasDerivAt (fun s => 2 * s + 4) 2 t := by simpa using ((hasDerivAt_id' t).const_mul 2).add_const 4 have hsq : HasDerivAt (fun s => 3 * (s - 1) ^ 2) (6 * (t - 1)) t := by exact ((((hasDerivAt_id' t).sub_const 1).pow 2).const_mul 3).congr_deriv (by ring) exact ((hlin.mul hlog).sub hsq).congr_deriv (by simp only [h']; ring) have hderiv2 : ∀ t : ℝ, 0 < t → HasDerivAt h' (h'' t) t := by intro t ht have hlin4 : HasDerivAt (fun s => 4 * s + 4) 4 t := by simpa using ((hasDerivAt_id' t).const_mul 4).add_const 4 have h1 := hlin4.mul (Real.hasDerivAt_log (ne_of_gt ht)) have h2 : HasDerivAt (fun s => 8 * (s - 1)) 8 t := by simpa using ((hasDerivAt_id' t).sub_const 1).const_mul 8 exact (h1.sub h2).congr_deriv (by have ht0 : t ≠ 0 := ne_of_gt ht simp only [h'']; field_simp; ring) have hh''_nn : ∀ t : ℝ, 0 < t → 0 ≤ h'' t := by intro t ht -- log t + 1/t - 1 ≥ 0 because log(1/t) ≤ 1/t - 1! have hlog_le := Real.log_le_sub_one_of_pos (div_pos one_pos ht) rw [Real.log_div one_ne_zero (ne_of_gt ht), Real.log_one, zero_sub] at hlog_le simp only [h''] linarith have hh'_mono : MonotoneOn h' (Set.Ioi 0) := by apply monotoneOn_of_deriv_nonneg (convex_Ioi 0) · exact fun t ht => (hderiv2 t ht).continuousAt.continuousWithinAt · exact fun t ht => (hderiv2 t (interior_subset ht)).differentiableAt.differentiableWithinAt · intro t ht have ht' : 0 < t := interior_subset ht rw [(hderiv2 t ht').deriv] exact hh''_nn t ht' have hh'1 : h' 1 = 0 := by simp [h'] have hh1 : h 1 = 0 := by simp [h] suffices hge : 0 ≤ h u by simp only [h] at hge; linarith rcases le_total 1 u with h1u | hu1 · -- u ≥ 1: h' ≥ 0 on [1, u], so h is monotone on [1, u] have hmono : MonotoneOn h (Set.Icc 1 u) := by apply monotoneOn_of_deriv_nonneg (convex_Icc 1 u) · exact fun t ht => (hderiv1 t (by linarith [ht.1])).continuousAt.continuousWithinAt · exact fun t ht => (hderiv1 t (by linarith [(interior_subset ht).1])).differentiableAt.differentiableWithinAt · intro t ht have ht' := interior_subset ht rw [(hderiv1 t (by linarith [ht'.1])).deriv] have := hh'_mono (Set.mem_Ioi.mpr zero_lt_one) (Set.mem_Ioi.mpr (by linarith [ht'.1])) ht'.1 linarith have := hmono ⟨le_rfl, h1u⟩ ⟨h1u, le_rfl⟩ h1u linarith · -- 0 < u ≤ 1: h' ≤ 0 on [u, 1], so h is antitone on [u, 1] have hanti : AntitoneOn h (Set.Icc u 1) := by apply antitoneOn_of_deriv_nonpos (convex_Icc u 1) · exact fun t ht => (hderiv1 t (by linarith [ht.1])).continuousAt.continuousWithinAt · exact fun t ht => (hderiv1 t (by linarith [(interior_subset ht).1])).differentiableAt.differentiableWithinAt · intro t ht have ht' := interior_subset ht rw [(hderiv1 t (by linarith [ht'.1])).deriv] have := hh'_mono (Set.mem_Ioi.mpr (by linarith [ht'.1])) (Set.mem_Ioi.mpr zero_lt_one) ht'.2 linarith have := hanti ⟨le_rfl, hu1⟩ ⟨hu1, le_rfl⟩ hu1 linarith /-- Open probability simplex `Δ_d° ⊂ EuclideanSpace ℝ (Fin d)`. -/ def openSimplex (d : ℕ) : Set (EuclideanSpace ℝ (Fin d)) := {p | (∀ i, 0 < p i) ∧ ∑ i : Fin d, p i = 1} /-- Negative Shannon entropy mirror map `ψ(p) = ∑ i, p_i log(p_i)`. -/ noncomputable def negEntropy {d : ℕ} (p : EuclideanSpace ℝ (Fin d)) : ℝ := ∑ i : Fin d, p i * Real.log (p i) /-- Gradient of negative Shannon entropy: `(∇ψ(p))_i = log(p_i) + 1`. -/ noncomputable def negEntropyGrad {d : ℕ} (p : EuclideanSpace ℝ (Fin d)) : EuclideanSpace ℝ (Fin d) := WithLp.equiv 2 (Fin d → ℝ) |>.symm fun i => Real.log (p i) + 1 /-- KL divergence `D_KL(p ‖ q) = ∑ i, p_i log(p_i / q_i)`. -/ noncomputable def klDiv {d : ℕ} (p q : EuclideanSpace ℝ (Fin d)) : ℝ := ∑ i : Fin d, p i * Real.log (p i / q i) /-- The Bregman divergence of negative Shannon entropy on the simplex equals KL divergence. -/ lemma bregmanDiv_negEntropy_eq_kl {d : ℕ} {p q : EuclideanSpace ℝ (Fin d)} (hp : p ∈ openSimplex d) (hq : q ∈ openSimplex d) : bregmanDiv negEntropy negEntropyGrad p q = klDiv p q := by unfold bregmanDiv negEntropy negEntropyGrad klDiv rw [PiLp.inner_apply] simp only [RCLike.inner_apply, conj_trivial, PiLp.sub_apply, WithLp.equiv_symm_apply] have h1 : ∑ i : Fin d, (p i - q i) * (Real.log (q i) + 1) = (∑ i : Fin d, p i * Real.log (q i)) - (∑ i : Fin d, q i * Real.log (q i)) := by have hexp : ∑ i : Fin d, (p i - q i) * (Real.log (q i) + 1) = (∑ i : Fin d, p i * Real.log (q i)) - (∑ i : Fin d, q i * Real.log (q i)) + ((∑ i : Fin d, p i) - (∑ i : Fin d, q i)) := by rw [← Finset.sum_sub_distrib, ← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro i _; ring rw [hexp, hp.2, hq.2, sub_self, add_zero] rw [h1] have hkl : ∑ i : Fin d, p i * Real.log (p i / q i) = (∑ i : Fin d, p i * Real.log (p i)) - (∑ i : Fin d, p i * Real.log (q i)) := by rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro i _ rw [Real.log_div (ne_of_gt (hp.1 i)) (ne_of_gt (hq.1 i))]; ring linarith /-- `ℓ₁`-norm on `EuclideanSpace ℝ (Fin d)`. -/ def l1Norm {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) : ℝ := ∑ i : Fin d, |v i| /-- `ℓ_∞`-norm on `EuclideanSpace ℝ (Fin d)`. -/ def linfNorm {d : ℕ} (g : EuclideanSpace ℝ (Fin d)) : ℝ := Finset.fold max (0 : ℝ) (fun i => |g i|) Finset.univ lemma linfNorm_nonneg {d : ℕ} (g : EuclideanSpace ℝ (Fin d)) : 0 ≤ linfNorm g := by unfold linfNorm suffices ∀ s : Finset (Fin d), (0 : ℝ) ≤ Finset.fold max (0 : ℝ) (fun i => |g i|) s from this Finset.univ intro s induction s using Finset.induction_on with | empty => simp | insert a s ha ih => rw [Finset.fold_insert ha] exact le_max_of_le_right ih lemma abs_apply_le_linfNorm {d : ℕ} (g : EuclideanSpace ℝ (Fin d)) (i : Fin d) : |g i| ≤ linfNorm g := by unfold linfNorm suffices ∀ s : Finset (Fin d), i ∈ s → |g i| ≤ Finset.fold max (0 : ℝ) (fun j => |g j|) s from this Finset.univ (Finset.mem_univ i) intro s induction s using Finset.induction_on with | empty => intro hi; simp at hi | insert a s ha ih => intro hi rw [Finset.fold_insert ha] rcases Finset.mem_insert.mp hi with rfl | his · exact le_max_left _ _ · exact le_max_of_le_right (ih his) /-- `(‖·‖₁, ‖·‖_∞)` forms an exact Hölder dual-norm pair on `EuclideanSpace ℝ (Fin d)`. -/ lemma l1_linf_dual_norm_pair (d : ℕ) : IsDualNormPair (l1Norm (d := d)) (linfNorm (d := d)) := by refine ⟨fun v => Finset.sum_nonneg (fun i _ => abs_nonneg _), linfNorm_nonneg, fun g v => ?_⟩ rw [PiLp.inner_apply] simp only [RCLike.inner_apply, conj_trivial] calc |∑ i : Fin d, v i * g i| ≤ ∑ i : Fin d, |v i * g i| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ i : Fin d, |g i| * |v i| := by apply Finset.sum_congr rfl; intro i _; rw [abs_mul, mul_comm] _ ≤ ∑ i : Fin d, linfNorm g * |v i| := by apply Finset.sum_le_sum; intro i _ exact mul_le_mul_of_nonneg_right (abs_apply_le_linfNorm g i) (abs_nonneg _) _ = linfNorm g * l1Norm v := by rw [← Finset.mul_sum]; rfl /-- **Pinsker's Inequality (`1`-Strong Convexity of Negative Entropy wrt `‖·‖₁`)**: For every `p, q ∈ Δ_d°`, `(1 / 2) ‖p - q‖₁² ≤ D_KL(p ‖ q)`. -/ theorem pinsker_kl_l1_strong_convexity {d : ℕ} {p q : EuclideanSpace ℝ (Fin d)} (hp : p ∈ openSimplex d) (hq : q ∈ openSimplex d) : (1 / 2) * (l1Norm (p - q)) ^ 2 ≤ klDiv p q := by have hterm : ∀ i : Fin d, (p i - q i) ^ 2 / (2 * p i + 4 * q i) ≤ (1 / 3) * (p i * Real.log (p i / q i) - p i + q i) := by intro i have hpi : 0 < p i := hp.1 i have hqi : 0 < q i := hq.1 i have hu : 0 < p i / q i := div_pos hpi hqi have hsc := pinsker_scalar_ineq hu have hden : 0 < 2 * p i + 4 * q i := by linarith have hmul := mul_le_mul_of_nonneg_left hsc (sq_nonneg (q i)) have hlhs : (q i) ^ 2 * (3 * (p i / q i - 1) ^ 2) = 3 * (p i - q i) ^ 2 := by field_simp have hrhs : (q i) ^ 2 * ((2 * (p i / q i) + 4) * ((p i / q i) * Real.log (p i / q i) - (p i / q i) + 1)) = (2 * p i + 4 * q i) * (p i * Real.log (p i / q i) - p i + q i) := by field_simp have h1 : 3 * (p i - q i) ^ 2 ≤ (2 * p i + 4 * q i) * (p i * Real.log (p i / q i) - p i + q i) := by linarith rw [div_le_iff₀ hden] linarith have hcs : (∑ i : Fin d, |p i - q i|) ^ 2 ≤ (∑ i : Fin d, (p i - q i) ^ 2 / (2 * p i + 4 * q i)) * (∑ i : Fin d, (2 * p i + 4 * q i)) := by let a : Fin d → ℝ := fun i => |p i - q i| / Real.sqrt (2 * p i + 4 * q i) let b : Fin d → ℝ := fun i => Real.sqrt (2 * p i + 4 * q i) have hab : ∀ i : Fin d, a i * b i = |p i - q i| := by intro i have hden : 0 < 2 * p i + 4 * q i := by linarith [hp.1 i, hq.1 i] have hsq : Real.sqrt (2 * p i + 4 * q i) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hden) simp only [a, b] exact div_mul_cancel₀ _ hsq have hasq : ∀ i : Fin d, (a i) ^ 2 = (p i - q i) ^ 2 / (2 * p i + 4 * q i) := by intro i have hden : 0 ≤ 2 * p i + 4 * q i := by linarith [hp.1 i, hq.1 i] simp only [a, div_pow, sq_abs, Real.sq_sqrt hden] have hbsq : ∀ i : Fin d, (b i) ^ 2 = 2 * p i + 4 * q i := by intro i have hden : 0 ≤ 2 * p i + 4 * q i := by linarith [hp.1 i, hq.1 i] simp only [b, Real.sq_sqrt hden] have hcs_fin := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ a b simp only [hab, hasq, hbsq] at hcs_fin exact hcs_fin have hsum6 : ∑ i : Fin d, (2 * p i + 4 * q i) = 6 := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hp.2, hq.2]; ring have hsum_kl : ∑ i : Fin d, (p i * Real.log (p i / q i) - p i + q i) = klDiv p q := by unfold klDiv rw [Finset.sum_add_distrib, Finset.sum_sub_distrib, hp.2, hq.2]; ring have hsum_bound : ∑ i : Fin d, (p i - q i) ^ 2 / (2 * p i + 4 * q i) ≤ (1 / 3) * klDiv p q := by calc ∑ i : Fin d, (p i - q i) ^ 2 / (2 * p i + 4 * q i) ≤ ∑ i : Fin d, (1 / 3) * (p i * Real.log (p i / q i) - p i + q i) := Finset.sum_le_sum (fun i _ => hterm i) _ = (1 / 3) * ∑ i : Fin d, (p i * Real.log (p i / q i) - p i + q i) := by rw [← Finset.mul_sum] _ = (1 / 3) * klDiv p q := by rw [hsum_kl] rw [hsum6] at hcs have hl1 : l1Norm (p - q) = ∑ i : Fin d, |p i - q i| := by unfold l1Norm; apply Finset.sum_congr rfl; intro i _; simp [PiLp.sub_apply] rw [hl1] linarith /-- Negative Shannon entropy is `1`-strongly convex wrt `‖·‖₁` on `Δ_d°`. -/ lemma negEntropy_mirror_strongly_convex (d : ℕ) : IsMirrorStronglyConvex (negEntropy (d := d)) (negEntropyGrad (d := d)) (openSimplex d) (l1Norm (d := d)) 1 := by refine ⟨by norm_num, fun p hp q hq => ?_⟩ rw [bregmanDiv_negEntropy_eq_kl hp hq] exact pinsker_kl_l1_strong_convexity hp hq /-- Closed-form Exponentiated Gradient / Entropic Mirror Descent (Hedge) update: `x_{t+1, i} = x_{t, i} exp(-η g_{t, i}) / ∑_j x_{t, j} exp(-η g_{t, j})`. -/ noncomputable def entropicStep {d : ℕ} (η : ℝ) (gt xt : EuclideanSpace ℝ (Fin d)) : EuclideanSpace ℝ (Fin d) := let Z := ∑ j : Fin d, xt j * Real.exp (-η * gt j) WithLp.equiv 2 (Fin d → ℝ) |>.symm fun i => (xt i * Real.exp (-η * gt i)) / Z /-- Exponentiated Gradient trajectory starting from `x0` under arbitrary loss sequence `g`. -/ noncomputable def entropicIter {d : ℕ} (η : ℝ) (g : ℕ → EuclideanSpace ℝ (Fin d)) (x0 : EuclideanSpace ℝ (Fin d)) : ℕ → EuclideanSpace ℝ (Fin d) | 0 => x0 | t + 1 => entropicStep η (g t) (entropicIter η g x0 t) /-- The closed-form Exponentiated Gradient update satisfies `IsMirrorStep` for negative entropy with exact zero variational inequality (`⟪η g_t + ∇ψ(x_{t+1}) - ∇ψ(x_t), u - x_{t+1}⟫ = 0`). -/ theorem entropicStep_isMirrorStep {d : ℕ} (hd : 1 ≤ d) {η : ℝ} {gt xt : EuclideanSpace ℝ (Fin d)} (hxt : xt ∈ openSimplex d) : IsMirrorStep (negEntropyGrad (d := d)) (openSimplex d) η gt xt (entropicStep η gt xt) := by set Z := ∑ j : Fin d, xt j * Real.exp (-η * gt j) have hZpos : 0 < Z := by apply Finset.sum_pos · intro j _; exact mul_pos (hxt.1 j) (Real.exp_pos _) · exact ⟨⟨0, hd⟩, Finset.mem_univ _⟩ have hmem : entropicStep η gt xt ∈ openSimplex d := by refine ⟨fun i => ?_, ?_⟩ · simp only [entropicStep, WithLp.equiv_symm_apply] exact div_pos (mul_pos (hxt.1 i) (Real.exp_pos _)) hZpos · simp only [entropicStep, WithLp.equiv_symm_apply] rw [← Finset.sum_div, div_self (ne_of_gt hZpos)] refine ⟨hmem, fun u hu => ?_⟩ rw [PiLp.inner_apply] simp only [RCLike.inner_apply, conj_trivial, PiLp.sub_apply, PiLp.add_apply, PiLp.smul_apply, smul_eq_mul, negEntropyGrad, entropicStep, WithLp.equiv_symm_apply] have hcoord : ∀ i : Fin d, η * gt i + (Real.log (xt i * Real.exp (-η * gt i) / Z) + 1) - (Real.log (xt i) + 1) = -Real.log Z := by intro i rw [Real.log_div (ne_of_gt (mul_pos (hxt.1 i) (Real.exp_pos _))) (ne_of_gt hZpos), Real.log_mul (ne_of_gt (hxt.1 i)) (ne_of_gt (Real.exp_pos _)), Real.log_exp] ring have hsum0 : ∑ i : Fin d, (u i - xt i * Real.exp (-η * gt i) / Z) * (η * gt i + (Real.log (xt i * Real.exp (-η * gt i) / Z) + 1) - (Real.log (xt i) + 1)) = 0 := by have h1 : ∑ i : Fin d, (u i - xt i * Real.exp (-η * gt i) / Z) * (η * gt i + (Real.log (xt i * Real.exp (-η * gt i) / Z) + 1) - (Real.log (xt i) + 1)) = (-Real.log Z) * ((∑ i : Fin d, u i) - (∑ i : Fin d, xt i * Real.exp (-η * gt i) / Z)) := by have : ∀ i : Fin d, (u i - xt i * Real.exp (-η * gt i) / Z) * (η * gt i + (Real.log (xt i * Real.exp (-η * gt i) / Z) + 1) - (Real.log (xt i) + 1)) = (-Real.log Z) * (u i - xt i * Real.exp (-η * gt i) / Z) := by intro i; rw [hcoord i]; ring simp_rw [this, ← Finset.mul_sum, Finset.sum_sub_distrib] rw [h1, hu.2, ← Finset.sum_div, div_self (ne_of_gt hZpos), sub_self, mul_zero] linarith /-- Uniform distribution `u_unif = (1/d, ..., 1/d)` on `Δ_d°`. -/ noncomputable def uniformSimplex (d : ℕ) : EuclideanSpace ℝ (Fin d) := WithLp.equiv 2 (Fin d → ℝ) |>.symm fun _ => (1 : ℝ) / (d : ℝ) lemma uniformSimplex_mem {d : ℕ} (hd : 1 ≤ d) : uniformSimplex d ∈ openSimplex d := by have hd_pos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr (by omega) refine ⟨fun _ => by simp [uniformSimplex]; positivity, ?_⟩ simp [uniformSimplex, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, ne_of_gt hd_pos] /-- KL divergence from any `u ∈ Δ_d°` to the uniform distribution is at most `log d`. -/ lemma klDiv_uniform_le_log {d : ℕ} (hd : 1 ≤ d) {u : EuclideanSpace ℝ (Fin d)} (hu : u ∈ openSimplex d) : klDiv u (uniformSimplex d) ≤ Real.log (d : ℝ) := by have hd_pos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr (by omega) unfold klDiv uniformSimplex simp only [WithLp.equiv_symm_apply] have hexp : ∑ i : Fin d, u i * Real.log (u i / (1 / (d : ℝ))) = (∑ i : Fin d, u i * Real.log (u i)) + Real.log (d : ℝ) := by have hterm : ∀ i : Fin d, u i * Real.log (u i / (1 / (d : ℝ))) = u i * Real.log (u i) + u i * Real.log (d : ℝ) := by intro i rw [one_div, div_inv_eq_mul, Real.log_mul (ne_of_gt (hu.1 i)) (ne_of_gt hd_pos)]; ring simp_rw [hterm, Finset.sum_add_distrib, ← Finset.sum_mul, hu.2, one_mul] rw [hexp] have hneg : ∑ i : Fin d, u i * Real.log (u i) ≤ 0 := by apply Finset.sum_nonpos intro i _ have hui_le : u i ≤ 1 := by have hle := Finset.single_le_sum (f := fun j => u j) (fun j _ => le_of_lt (hu.1 j)) (Finset.mem_univ i) linarith [hu.2] have hlog_np : Real.log (u i) ≤ 0 := Real.log_nonpos (le_of_lt (hu.1 i)) hui_le exact mul_nonpos_of_nonneg_of_nonpos (le_of_lt (hu.1 i)) hlog_np linarith /-- **Entropic Mirror Descent / Exponentiated Gradient Exact Regret Theorem**: For ANY adversarial sequence of loss vectors `g : ℕ → ℝ^d`, step size `η > 0`, and comparator `u ∈ Δ_d°`, starting from the uniform distribution `x_0 = (1/d, ..., 1/d)`: $$\sum_{t=0}^{T-1} \langle g_t, x_t - u \rangle \le \frac{\ln d}{\eta} + \frac{\eta}{2}\sum_{t=0}^{T-1} \|g_t\|_\infty^2.$$ -/ theorem entropic_md_regret_bound {d : ℕ} (hd : 1 ≤ d) {η : ℝ} (hη : 0 < η) (g : ℕ → EuclideanSpace ℝ (Fin d)) {u : EuclideanSpace ℝ (Fin d)} (hu : u ∈ openSimplex d) (T : ℕ) : ∑ t ∈ range T, ⟪g t, entropicIter η g (uniformSimplex d) t - u⟫ ≤ Real.log (d : ℝ) / η + (η / 2) * ∑ t ∈ range T, (linfNorm (g t)) ^ 2 := by have hx0 : uniformSimplex d ∈ openSimplex d := uniformSimplex_mem hd have hmem : ∀ t, entropicIter η g (uniformSimplex d) t ∈ openSimplex d := by intro t; induction t with | zero => exact hx0 | succ k ih => exact (entropicStep_isMirrorStep hd ih).1 have htraj : ∀ t, IsMirrorStep (negEntropyGrad (d := d)) (openSimplex d) η (g t) (entropicIter η g (uniformSimplex d) t) (entropicIter η g (uniformSimplex d) (t + 1)) := fun t => entropicStep_isMirrorStep hd (hmem t) have hreg := mirror_descent_regret_bound (negEntropy_mirror_strongly_convex d) (l1_linf_dual_norm_pair d) hη hx0 hu htraj T simp only [entropicIter] at hreg rw [bregmanDiv_negEntropy_eq_kl hu hx0] at hreg have hkl : klDiv u (uniformSimplex d) / η ≤ Real.log (d : ℝ) / η := div_le_div_of_nonneg_right (klDiv_uniform_le_log hd hu) (le_of_lt hη) have halg : η / (2 * (1 : ℝ)) = η / 2 := by ring linarith /-- **Entropic Mirror Descent Optimal `G_∞ √(2 T ln d)` Regret & `G_∞ √(2 ln d / T)` Average Excess**: For `d ≥ 2`, `T ≥ 1`, bounded adversarial gradients `‖g_t‖_∞ ≤ G`, and optimal step size `η = √(2 ln d) / (G √T)`, Exponentiated Gradient achieves exact regret `≤ G √(2 T ln d)` and average regret `≤ G √(2 ln d / T)`. -/ theorem entropic_md_optimal_regret {d T : ℕ} (hd : 2 ≤ d) (hT : 1 ≤ T) {G : ℝ} (hG : 0 < G) (g : ℕ → EuclideanSpace ℝ (Fin d)) (hGbound : ∀ t, linfNorm (g t) ≤ G) {u : EuclideanSpace ℝ (Fin d)} (hu : u ∈ openSimplex d) : let η := Real.sqrt (2 * Real.log (d : ℝ)) / (G * Real.sqrt (T : ℝ)) 0 < η ∧ ∑ t ∈ range T, ⟪g t, entropicIter η g (uniformSimplex d) t - u⟫ ≤ G * Real.sqrt (2 * (T : ℝ) * Real.log (d : ℝ)) ∧ (1 / (T : ℝ)) * ∑ t ∈ range T, ⟪g t, entropicIter η g (uniformSimplex d) t - u⟫ ≤ G * Real.sqrt (2 * Real.log (d : ℝ) / (T : ℝ)) := by intro η have hTpos : (0 : ℝ) < (T : ℝ) := Nat.cast_pos.mpr (by omega) have hd_gt1 : (1 : ℝ) < (d : ℝ) := by have : (2 : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd linarith have hlog_pos : 0 < Real.log (d : ℝ) := Real.log_pos hd_gt1 have hη : 0 < η := div_pos (Real.sqrt_pos.mpr (by positivity)) (mul_pos hG (Real.sqrt_pos.mpr hTpos)) have hreg := entropic_md_regret_bound (by omega : 1 ≤ d) hη g hu T have hsum_g : ∑ t ∈ range T, (linfNorm (g t)) ^ 2 ≤ (T : ℝ) * G ^ 2 := by calc ∑ t ∈ range T, (linfNorm (g t)) ^ 2 ≤ ∑ _t ∈ range T, G ^ 2 := by apply Finset.sum_le_sum; intro t _ have h1 := linfNorm_nonneg (g t) have h2 := hGbound t nlinarith _ = (T : ℝ) * G ^ 2 := by simp [Finset.sum_const, Finset.card_range, nsmul_eq_mul] have hcomb : ∑ t ∈ range T, ⟪g t, entropicIter η g (uniformSimplex d) t - u⟫ ≤ Real.log (d : ℝ) / η + (η / 2) * ((T : ℝ) * G ^ 2) := by have := mul_le_mul_of_nonneg_left hsum_g (by positivity : 0 ≤ η / 2) linarith have hsq_log : Real.sqrt (2 * Real.log (d : ℝ)) ^ 2 = 2 * Real.log (d : ℝ) := Real.sq_sqrt (by positivity) have hsq_T : Real.sqrt (T : ℝ) ^ 2 = (T : ℝ) := Real.sq_sqrt (le_of_lt hTpos) have heq1 : Real.log (d : ℝ) / η + (η / 2) * ((T : ℝ) * G ^ 2) = G * Real.sqrt (2 * (T : ℝ) * Real.log (d : ℝ)) := by have hsqrt_mul : Real.sqrt (2 * (T : ℝ) * Real.log (d : ℝ)) = Real.sqrt (T : ℝ) * Real.sqrt (2 * Real.log (d : ℝ)) := by rw [show 2 * (T : ℝ) * Real.log (d : ℝ) = (T : ℝ) * (2 * Real.log (d : ℝ)) by ring, Real.sqrt_mul (le_of_lt hTpos)] rw [hsqrt_mul] simp only [η] have hs1 : Real.sqrt (2 * Real.log (d : ℝ)) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by positivity)) have hs2 : Real.sqrt (T : ℝ) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hTpos) field_simp rw [show Real.log (d : ℝ) * 2 = 2 * Real.log (d : ℝ) by ring, hsq_log, hsq_T] ring have hbound1 : ∑ t ∈ range T, ⟪g t, entropicIter η g (uniformSimplex d) t - u⟫ ≤ G * Real.sqrt (2 * (T : ℝ) * Real.log (d : ℝ)) := by linarith refine ⟨hη, hbound1, ?_⟩ have hmul := mul_le_mul_of_nonneg_left hbound1 (by positivity : 0 ≤ 1 / (T : ℝ)) have heq2 : (1 / (T : ℝ)) * (G * Real.sqrt (2 * (T : ℝ) * Real.log (d : ℝ))) = G * Real.sqrt (2 * Real.log (d : ℝ) / (T : ℝ)) := by rw [Real.sqrt_div (by positivity), show 2 * (T : ℝ) * Real.log (d : ℝ) = (T : ℝ) * (2 * Real.log (d : ℝ)) by ring, Real.sqrt_mul (le_of_lt hTpos)] have hs2 : Real.sqrt (T : ℝ) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr hTpos) field_simp nlinarith [hsq_T] linarith end EntropicMirrorDescent end ConvexOpt.FWMirror #print axioms ConvexOpt.FWMirror.fw_iter_mem #print axioms ConvexOpt.FWMirror.fwGap_ge_suboptimality #print axioms ConvexOpt.FWMirror.fw_exact_sublinear_rate #print axioms ConvexOpt.FWMirror.fw_duality_gap_rate #print axioms ConvexOpt.FWMirror.bregman_three_point_identity #print axioms ConvexOpt.FWMirror.mirror_descent_one_step #print axioms ConvexOpt.FWMirror.mirror_descent_regret_bound #print axioms ConvexOpt.FWMirror.mirror_descent_convex_rate #print axioms ConvexOpt.FWMirror.mirror_descent_optimal_step_val #print axioms ConvexOpt.FWMirror.ogd_regret_bound #print axioms ConvexOpt.FWMirror.pinsker_kl_l1_strong_convexity #print axioms ConvexOpt.FWMirror.entropicStep_isMirrorStep #print axioms ConvexOpt.FWMirror.entropic_md_regret_bound #print axioms ConvexOpt.FWMirror.entropic_md_optimal_regret