Ch. 4 preamble, §4.1, (4.2)–(4.3), (4.6) — Bregman divergence, mirror maps, Bregman projection, mirror descent and dual averaging runs
DefinitionConvexOptAlg_MirrorDescent_DefsThroughout, is a finite-dimensional real vector space with an arbitrary norm (the book's with an arbitrary norm). Linear functionals on carry the dual norm , and the book's pairing is . A function comes with an explicit gradient map , a linear functional on .
- Bregman divergence. .
- Mirror map. Let be a convex open set. is a mirror map if (i) is strictly convex and differentiable on with gradient ; (ii) the gradient takes all possible values, ; (iii) the gradient diverges on the boundary of : as within , for every boundary point of .
- Standing setting of Chapter 4. is compact and convex, is a mirror map on , and .
- Subgradient. A linear functional is a subgradient of at (relative to ) if for every .
- -strong convexity of the mirror map on : for all ,
- Bregman projection. means and for every .
- Mirror descent run with step for the steps : and, for , is a subgradient of at , satisfies
and . 8. Dual averaging run with step for the steps : for ,
and for , is a subgradient of at .
These are the objects of Chapter 4 of the book: mirror descent (Section 4.2) and its lazy variant, dual averaging (Section 4.4). Every rate statement of the mission quantifies over all runs, with any choice of subgradient, dual point and minimizer.
Formalization Note The gradient is an explicit map Φ' : E → E →L[ℝ] ℝ with HasFDerivAt Φ (Φ' x) x on ; only the values of and on matter. The dual norm is the operator norm on E →L[ℝ] ℝ. Sequences are indexed from (index is unused). Strong convexity of is stated with the gradient, the form the book's proofs use; the preamble's subgradient form implies it. Dual averaging is encoded by its closed form (4.6), as the book does.
import Mathlib
namespace ConvexOptAlg.MirrorDescent
/-- Bubeck, Ch. 4 preamble, p. 297: the Bregman divergence
`D_Φ(x, y) = Φ(x) − Φ(y) − ∇Φ(y)ᵀ(x − y)`. The gradient `∇Φ(y)` is the explicit map `Φ' y`, a
continuous linear functional on `E` (the book's `∇Φ(y)ᵀv` is `Φ' y v`). -/
def bregman {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) (x y : E) : ℝ :=
Φ x - Φ y - Φ' y (x - y)
/-- Bubeck, §4.1, p. 298: `Φ : D → ℝ` is a mirror map on the convex open set `D` if
(i) `Φ` is strictly convex and differentiable on `D`, with gradient `Φ' x` at every `x ∈ D`;
(ii) the gradient takes all possible values, `∇Φ(D) = ℝⁿ` (every continuous linear functional is
`Φ' y` for some `y ∈ D`);
(iii) the gradient diverges on the boundary of `D`: `‖∇Φ(x)‖ → +∞` as `x → z ∈ ∂D` within `D`.
Only the values of `Φ` and `Φ'` on `D` matter. -/
def IsMirrorMap {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(D : Set E) (Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) : Prop :=
IsOpen D ∧ Convex ℝ D ∧ StrictConvexOn ℝ D Φ ∧
(∀ x ∈ D, HasFDerivAt Φ (Φ' x) x) ∧
(∀ φ : E →L[ℝ] ℝ, ∃ y ∈ D, Φ' y = φ) ∧
(∀ z ∈ frontier D, Filter.Tendsto (fun x => ‖Φ' x‖) (nhdsWithin z D) Filter.atTop)
/-- Bubeck, Ch. 4 preamble (p. 297) and §4.1 (p. 298): the standing setting of the chapter. `X` is a
compact convex set, `Φ` is a mirror map on the convex open set `D`, `X` is included in the closure
of `D`, and `X ∩ D ≠ ∅`. -/
def IsMirrorSetting {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X D : Set E) (Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) : Prop :=
IsCompact X ∧ Convex ℝ X ∧ IsMirrorMap D Φ Φ' ∧ X ⊆ closure D ∧ (X ∩ D).Nonempty
/-- Bubeck, Definition 1.2 (p. 235) in the dual-norm setting of Ch. 4: the continuous linear
functional `g` is a subgradient of `f` at `x` relative to `X` if `f(x) − f(y) ≤ gᵀ(x − y)` for every
`y ∈ X`. -/
def IsSubgradientOnN {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X : Set E) (f : E → ℝ) (x : E) (g : E →L[ℝ] ℝ) : Prop :=
∀ y ∈ X, f x - f y ≤ g (x - y)
/-- Bubeck, Ch. 4 preamble (iii), p. 297, for the differentiable mirror map: `Φ` is `ρ`-strongly
convex on `X ∩ D` w.r.t. `‖·‖` if
`Φ(x) − Φ(y) ≤ ∇Φ(x)ᵀ(x − y) − (ρ/2)‖x − y‖²` for all `x, y ∈ X ∩ D`. -/
def IsStronglyConvexMirror {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X D : Set E) (Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) (ρ : ℝ) : Prop :=
∀ x ∈ X ∩ D, ∀ y ∈ X ∩ D, Φ x - Φ y ≤ Φ' x (x - y) - ρ / 2 * ‖x - y‖ ^ 2
/-- Bubeck, §4.1, p. 298: `z` is the Bregman projection `Π^Φ_X(y) = argmin_{x ∈ X ∩ D} D_Φ(x, y)`,
i.e. `z ∈ X ∩ D` and `D_Φ(z, y) ≤ D_Φ(x, y)` for every `x ∈ X ∩ D`. -/
def IsBregmanProjection {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X D : Set E) (Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) (y z : E) : Prop :=
z ∈ X ∩ D ∧ ∀ x ∈ X ∩ D, bregman Φ Φ' z y ≤ bregman Φ Φ' x y
/-- Bubeck, §4.2, (4.2)–(4.3), p. 299: `(x, y, g)` is a run of mirror descent on `f` with step `η`
for the steps `t = 1, …, T`. The first iterate `x 1 ∈ argmin_{x ∈ X ∩ D} Φ(x)` (index `0` is
unused); at every step `1 ≤ t ≤ T`, `g t` is a subgradient of `f` at `x t` (any one),
`y (t+1) ∈ D` satisfies `∇Φ(y_{t+1}) = ∇Φ(x_t) − η g_t` (4.2), and `x (t+1)` is the Bregman
projection `Π^Φ_X(y_{t+1})` (4.3). -/
def IsMirrorDescentRun {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X D : Set E) (Φ : E → ℝ) (Φ' : E → E →L[ℝ] ℝ) (f : E → ℝ) (η : ℝ)
(x y : ℕ → E) (g : ℕ → E →L[ℝ] ℝ) (T : ℕ) : Prop :=
x 1 ∈ X ∩ D ∧ (∀ z ∈ X ∩ D, Φ (x 1) ≤ Φ z) ∧
∀ t : ℕ, 1 ≤ t → t ≤ T →
IsSubgradientOnN X f (x t) (g t) ∧
y (t + 1) ∈ D ∧
Φ' (y (t + 1)) = Φ' (x t) - η • g t ∧
IsBregmanProjection X D Φ Φ' (y (t + 1)) (x (t + 1))
/-- Bubeck, §4.4, (4.6), p. 303: `(x, g)` is a run of dual averaging (lazy mirror descent) on `f`
with step `η` for the steps `t = 1, …, T`: for every `1 ≤ t ≤ T + 1`, the iterate
`x t ∈ argmin_{x ∈ X ∩ D} η ∑_{s=1}^{t−1} g_sᵀx + Φ(x)` (so `x 1` minimizes `Φ` on `X ∩ D`), and
for every `1 ≤ t ≤ T`, `g t` is a subgradient of `f` at `x t` (any one). The sum over `s < t` is
written `∑ s ∈ Finset.Ico 1 t`. -/
def IsDualAveragingRun {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(X D : Set E) (Φ : E → ℝ) (f : E → ℝ) (η : ℝ)
(x : ℕ → E) (g : ℕ → E →L[ℝ] ℝ) (T : ℕ) : Prop :=
(∀ t : ℕ, 1 ≤ t → t ≤ T + 1 →
x t ∈ X ∩ D ∧
∀ z ∈ X ∩ D,
η * (∑ s ∈ Finset.Ico 1 t, g s (x t)) + Φ (x t) ≤
η * (∑ s ∈ Finset.Ico 1 t, g s z) + Φ z) ∧
∀ t : ℕ, 1 ≤ t → t ≤ T → IsSubgradientOnN X f (x t) (g t)
end ConvexOptAlg.MirrorDescent