Documentation

CslibFrontier.MachineLearning.OnlineLearning.OnlineNewtonStep

Online Newton Step for exp-concave losses #

An α-exp-concave function f on a convex set K (IsExpConcaveOn K α f, α > 0) satisfies ConcaveOn ℝ K (fun x => Real.exp (-α * f x)) [Hazan2022, HazanAgarwalKale2007]. Exp-concave functions are convex (IsExpConcaveOn.convexOn), monotone in α (IsExpConcaveOn.mono), and admit a directional quadratic lower bound (IsExpConcaveOn.quadratic_lower_bound, IsExpConcaveOn.quadratic_lower_bound_of_bounds): for 0 < β ≤ (1 / 2) * min (1 / (4 * G * D)) α, diameter D, and gradients of norm at most G,

f x + ⟪g, y - x⟫ + (β / 2) * ⟪g, y - x⟫ ^ 2 ≤ f y.

Online Newton Step (ons) [HazanAgarwalKale2007, Hazan2022] on a nonempty closed convex set K ⊆ EuclideanSpace ℝ (Fin d) maintains the regularized gradient outer-product matrix A 0 = ε • 1, A (t + 1) = A t + vecMulVec g_t g_t (with g_t = grad t (x t)), takes the preconditioned Newton step x t - (1 / β) • A (t + 1)⁻¹ g_t, and projects back onto K under the Mahalanobis norm induced by A (t + 1) (mahalanobisProj). Because A (t + 1) is positive definite (onsGram_posDef), conjugating Cslib.metricProjection by the symmetric square root CFC.sqrt A constructs mahalanobisProj directly with existence, uniqueness (mahalanobisProj_eq_iff_isMinOn), the generalized Pythagorean inequality (mahalanobisProj_pythagorean), and the adaptive OMD optimality condition (isAdaptiveOMDStep_mahalanobisProj).

Applying the master adaptive local-norm OMD inequality with directional curvature (omd_adaptive_regret_le) to ψ t z = (β / 2) * mahalanobisSq (A (t + 1)) z and μ t u x = (β / 2) * ⟪g t, u - x⟫ ^ 2 cancels the inter-round potential drift identically against the exp-concavity curvature term. Combining the resulting dual-norm sum with the elliptical potential / log-determinant lemma (elliptical_potential_le: ∑ t < T, g_tᵀ A_{t+1}⁻¹ g_t ≤ d * log (1 + T * G ^ 2 / (d * ε)), proved via the matrix determinant lemma det_sub_vecMulVec_self and the eigenvalue AM–GM bound log_det_le_card_mul_log_trace_div) yields:

Main definitions #

Main results #

References #

Exact section, lemma, and theorem numbers in the sources below are unverified against primary PDFs.

Exp-concave functions and quadratic lower bound #

A function f : E → ℝ is α-exp-concave on K if α > 0 and x ↦ exp (-α * f x) is concave on K [Hazan2022, HazanAgarwalKale2007].

Every α-exp-concave function is convex on K.

theorem Cslib.MachineLearning.OnlineLearning.OCO.IsExpConcaveOn.mono {E : Type u_1} [AddCommMonoid E] [Module ℝ E] {K : Set E} {α α' : ℝ} {f : E → ℝ} (hf : IsExpConcaveOn K α f) (hα' : 0 < α') (hle : α' ≤ α) :

Monotonicity of exp-concavity in α: if f is α-exp-concave and 0 < α' ≤ α, then f is α'-exp-concave.

theorem Cslib.MachineLearning.OnlineLearning.OCO.IsExpConcaveOn.quadratic_lower_bound {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] {K : Set E} {α β : ℝ} {f : E → ℝ} (hf : IsExpConcaveOn K α f) (hβ : 0 < β) (h2β : 2 * β ≤ α) {x y g : E} (hx : x ∈ K) (hy : y ∈ K) (hg : HasGradientWithinAt f g K x) (hbound : -(3 / 4) ≤ 2 * β * inner ℝ g (y - x)) :
f x + inner ℝ g (y - x) + β / 2 * inner ℝ g (y - x) ^ 2 ≤ f y

Quadratic lower bound for exp-concave functions (compare [Haz22], [HAK07]): if f is α-exp-concave on K, f has gradient g at x ∈ K within K, 0 < β, 2 * β ≤ α, and -(3 / 4) ≤ 2 * β * ⟪g, y - x⟫, then f x + ⟪g, y - x⟫ + β / 2 * ⟪g, y - x⟫ ^ 2 ≤ f y.

theorem Cslib.MachineLearning.OnlineLearning.OCO.IsExpConcaveOn.quadratic_lower_bound_of_bounds {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] {K : Set E} {α β G D : ℝ} {f : E → ℝ} (hf : IsExpConcaveOn K α f) (hβ : 0 < β) (h2β : 2 * β ≤ α) (hβGD : β * G * D ≤ 3 / 8) {x y g : E} (hx : x ∈ K) (hy : y ∈ K) (hg : HasGradientWithinAt f g K x) (hG : ‖g‖ ≤ G) (hD : ‖y - x‖ ≤ D) :
f x + inner ℝ g (y - x) + β / 2 * inner ℝ g (y - x) ^ 2 ≤ f y

Quadratic lower bound under diameter and gradient bounds [Hazan2022, HazanAgarwalKale2007]: for 0 < β with 2 * β ≤ α and β * G * D ≤ 3 / 8 (covering the standard choice β ≤ (1 / 2) * min (1 / (4 * G * D)) α), ‖g‖ ≤ G, and ‖y - x‖ ≤ D, f x + ⟪g, y - x⟫ + β / 2 * ⟪g, y - x⟫ ^ 2 ≤ f y.

theorem Cslib.MachineLearning.OnlineLearning.OCO.isExpConcaveOn_sq_norm_sub {E : Type u_1} [NormedAddCommGroup E] [InnerProductSpace ℝ E] {K : Set E} (hK : Convex ℝ K) (c : E) {B : ℝ} (hB : 0 < B) (hbound : ∀ x ∈ K, ‖x - c‖ ≤ B) :
IsExpConcaveOn K (1 / (2 * B ^ 2)) fun (x : E) => ‖x - c‖ ^ 2

Squared Euclidean distance x ↦ ‖x - c‖ ^ 2 is 1 / (2 * B ^ 2)-exp-concave on any convex set K contained in the closed ball of radius B > 0 around c.

Mahalanobis quadratic form and generalized projection #

The Mahalanobis squared norm vᵀ A v on EuclideanSpace ℝ (Fin d) induced by a matrix A : Matrix (Fin d) (Fin d) ℝ.

Mahalanobis projection onto K ⊆ EuclideanSpace ℝ (Fin d) with respect to a matrix A: when A is positive definite and K is nonempty, closed, and convex, this is the unique minimizer of z ↦ (z - y)ᵀ A (z - y) over K, obtained by conjugating Cslib.metricProjection by CFC.sqrt A.

theorem Cslib.MachineLearning.OnlineLearning.OCO.mahalanobisProj_eq_iff_isMinOn {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hcl : IsClosed K) (hK : Convex ℝ K) {A : Matrix (Fin d) (Fin d) ℝ} (hA : A.PosDef) {y x : EuclideanSpace ℝ (Fin d)} (hx : x ∈ K) :
mahalanobisProj K A y = x ↔ IsMinOn (fun (z : EuclideanSpace ℝ (Fin d)) => mahalanobisSq A (z - y)) K x

Existence and uniqueness of the Mahalanobis projection: for positive definite A and nonempty closed convex K, a point x ∈ K equals mahalanobisProj K A y iff it minimizes z ↦ mahalanobisSq A (z - y) over K.

theorem Cslib.MachineLearning.OnlineLearning.OCO.mahalanobisProj_isMinOn {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hne : K.Nonempty) (hcl : IsClosed K) (hK : Convex ℝ K) {A : Matrix (Fin d) (Fin d) ℝ} (hA : A.PosDef) (y : EuclideanSpace ℝ (Fin d)) :
IsMinOn (fun (z : EuclideanSpace ℝ (Fin d)) => mahalanobisSq A (z - y)) K (mahalanobisProj K A y)

mahalanobisProj K A y minimizes z ↦ (z - y)ᵀ A (z - y) over K.

Generalized Pythagorean inequality for Mahalanobis projection: for positive definite A and u ∈ K, (mahalanobisProj K A y - u)ᵀ A (mahalanobisProj K A y - u) ≤ (y - u)ᵀ A (y - u).

theorem Cslib.MachineLearning.OnlineLearning.OCO.isAdaptiveOMDStep_mahalanobisProj {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hne : K.Nonempty) (hcl : IsClosed K) (hK : Convex ℝ K) {A : Matrix (Fin d) (Fin d) ℝ} (hA : A.PosDef) {β : ℝ} (hβ : 0 < β) (g x : EuclideanSpace ℝ (Fin d)) :

Adaptive OMD optimality for Mahalanobis projection: for positive definite A, β > 0, and nonempty closed convex K, the Mahalanobis-projected Newton step satisfies IsAdaptiveOMDStep for the mirror gradient z ↦ β • A z.

Elliptical potential / log-determinant lemma #

Rank-one downdate determinant identity (matrix determinant lemma): for positive definite M and any v : Fin d → ℝ, (M - vecMulVec v v).det = (1 - v ⬝ᵥ (M⁻¹ *ᵥ v)) * M.det.

Eigenvalue AM–GM inequality in logarithmic form: for a positive definite d × d matrix A with 0 < d, Real.log A.det ≤ d * Real.log (A.trace / d).

theorem Cslib.MachineLearning.OnlineLearning.OCO.elliptical_potential_le {d : ℕ} {ε G : ℝ} (hε : 0 < ε) (hd : 0 < d) (g : ℕ → EuclideanSpace ℝ (Fin d)) {T : ℕ} (hG : ∀ t < T, ‖g t‖ ≤ G) :
have A := fun (t : ℕ) => ε • 1 + ∑ s ∈ Finset.range t, Matrix.vecMulVec (g s).ofLp (g s).ofLp; ∑ t ∈ Finset.range T, (g t).ofLp ⬝ᵥ (A (t + 1))⁻¹.mulVec (g t).ofLp ≤ ↑d * Real.log (1 + ↑T * G ^ 2 / (↑d * ε))

Elliptical potential / log-determinant lemma [Hazan2022, HazanAgarwalKale2007]: for A t = ε • 1 + ∑ s < t, vecMulVec (g s) (g s) with ε > 0, 0 < d, and ‖g t‖ ≤ G for t < T, ∑ t < T, g tᵀ A (t + 1)⁻¹ g t ≤ d * log (1 + T * G ^ 2 / (d * ε)).

Online Newton Step algorithm and logarithmic regret bounds #

State of Online Newton Step: current iterate point and accumulated regularized outer-product matrix gram = ε • 1 + ∑ s < t, g_s g_sᵀ.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.onsState {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) :

Causal state sequence of Online Newton Step (ONS) [HazanAgarwalKale2007, Hazan2022] on K ⊆ EuclideanSpace ℝ (Fin d) with subgradient oracle grad, curvature parameter β, regularization ε, and starting point x₀.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.ons {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :

Iterate sequence of Online Newton Step.

noncomputable def Cslib.MachineLearning.OnlineLearning.OCO.onsGram {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :
Matrix (Fin d) (Fin d) ℝ

Accumulated matrix A t = ε • 1 + ∑ s < t, g_s g_sᵀ of Online Newton Step.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.OCO.ons_zero {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) :
ons K grad β ε x₀ 0 = x₀
@[simp]
theorem Cslib.MachineLearning.OnlineLearning.OCO.onsGram_zero {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) :
onsGram K grad β ε x₀ 0 = ε • 1
theorem Cslib.MachineLearning.OnlineLearning.OCO.onsGram_succ {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :
onsGram K grad β ε x₀ (t + 1) = onsGram K grad β ε x₀ t + Matrix.vecMulVec (grad t (ons K grad β ε x₀ t)).ofLp (grad t (ons K grad β ε x₀ t)).ofLp
theorem Cslib.MachineLearning.OnlineLearning.OCO.ons_succ {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :
ons K grad β ε x₀ (t + 1) = mahalanobisProj K (onsGram K grad β ε x₀ (t + 1)) (ons K grad β ε x₀ t - (1 / β) • (Matrix.toEuclideanLin (onsGram K grad β ε x₀ (t + 1))⁻¹) (grad t (ons K grad β ε x₀ t)))
theorem Cslib.MachineLearning.OnlineLearning.OCO.onsGram_eq {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β ε : ℝ) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :
onsGram K grad β ε x₀ t = ε • 1 + ∑ s ∈ Finset.range t, Matrix.vecMulVec (grad s (ons K grad β ε x₀ s)).ofLp (grad s (ons K grad β ε x₀ s)).ofLp
theorem Cslib.MachineLearning.OnlineLearning.OCO.onsGram_posDef {d : ℕ} (K : Set (EuclideanSpace ℝ (Fin d))) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β : ℝ) {ε : ℝ} (hε : 0 < ε) (x₀ : EuclideanSpace ℝ (Fin d)) (t : ℕ) :
(onsGram K grad β ε x₀ t).PosDef
theorem Cslib.MachineLearning.OnlineLearning.OCO.ons_mem {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hcl : IsClosed K) (hK : Convex ℝ K) (grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)) (β : ℝ) {ε : ℝ} (hε : 0 < ε) {x₀ : EuclideanSpace ℝ (Fin d)} (hx₀ : x₀ ∈ K) (t : ℕ) :
ons K grad β ε x₀ t ∈ K
theorem Cslib.MachineLearning.OnlineLearning.OCO.ons_regret_le {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hcl : IsClosed K) (hK : Convex ℝ K) {f : ℕ → EuclideanSpace ℝ (Fin d) → ℝ} {grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)} {α β ε D G : ℝ} (hβ : 0 < β) (hε : 0 < ε) (h2β : 2 * β ≤ α) (hβGD : β * G * D ≤ 3 / 8) (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hG : ∀ (t : ℕ), ∀ x ∈ K, ‖grad t x‖ ≤ G) (hEC : ∀ (t : ℕ), IsExpConcaveOn K α (f t)) (hgrad : ∀ (t : ℕ), ∀ x ∈ K, HasGradientWithinAt (f t) (grad t x) K x) {x₀ u : EuclideanSpace ℝ (Fin d)} (hx₀ : x₀ ∈ K) (hu : u ∈ K) (T : ℕ) :
∑ t ∈ Finset.range T, (f t (ons K grad β ε x₀ t) - f t u) ≤ β * ε / 2 * D ^ 2 + ↑d / (2 * β) * Real.log (1 + ↑T * G ^ 2 / (↑d * ε))

Closed-form regret bound for Online Newton Step [Hazan2022, HazanAgarwalKale2007]: for α-exp-concave differentiable losses on a nonempty closed convex set K ⊆ EuclideanSpace ℝ (Fin d) of diameter at most D, gradients of norm at most G, and parameters β, ε > 0 satisfying 2 * β ≤ α and β * G * D ≤ 3 / 8, the regret after T rounds against every u ∈ K is at most (β * ε / 2) * D ^ 2 + (d / (2 * β)) * Real.log (1 + T * G ^ 2 / (d * ε)).

theorem Cslib.MachineLearning.OnlineLearning.OCO.ons_regret_le_log {d : ℕ} {K : Set (EuclideanSpace ℝ (Fin d))} (hcl : IsClosed K) (hK : Convex ℝ K) {f : ℕ → EuclideanSpace ℝ (Fin d) → ℝ} {grad : ℕ → EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)} {α D G : ℝ} (hα : 0 < α) (hD0 : 0 < D) (hG0 : 0 < G) (hD : ∀ x ∈ K, ∀ y ∈ K, ‖x - y‖ ≤ D) (hG : ∀ (t : ℕ), ∀ x ∈ K, ‖grad t x‖ ≤ G) (hEC : ∀ (t : ℕ), IsExpConcaveOn K α (f t)) (hgrad : ∀ (t : ℕ), ∀ x ∈ K, HasGradientWithinAt (f t) (grad t x) K x) {x₀ u : EuclideanSpace ℝ (Fin d)} (hx₀ : x₀ ∈ K) (hu : u ∈ K) (T : ℕ) :
have β := 1 / 2 * min (1 / (4 * G * D)) α; have ε := 1 / (β ^ 2 * D ^ 2); ∑ t ∈ Finset.range T, (f t (ons K grad β ε x₀ t) - f t u) ≤ 5 * (1 / α + G * D) * ↑d * Real.log (↑T + 1)

Logarithmic regret of Online Newton Step [HazanAgarwalKale2007, Hazan2022]: for α-exp-concave differentiable losses on a nonempty closed convex set K ⊆ EuclideanSpace ℝ (Fin d) of diameter at most D > 0 and gradients of norm at most G > 0, tuning β = (1 / 2) * min (1 / (4 * G * D)) α and ε = 1 / (β ^ 2 * D ^ 2) guarantees regret at most 5 * (1 / α + G * D) * d * Real.log (T + 1) against every u ∈ K and for every d, T : ℕ.