Documentation

CslibFrontier.MachineLearning.OnlineLearning.InternalRegret

Modification rules, internal/swap regret separations, and dominated-action weight decay #

This module formalizes the memoryless modification-rule framework R_F of [BlumMansour2007AGT, §4.2, pp. 81–82], specializing to external regret (Set.range (Function.const ι)), pairwise internal regret (internalRules ι), and swap regret (Set.univ), together with Exercises 4.1, 4.2, and 4.8 ([BlumMansour2007AGT, §4.4.4, pp. 91–92, and p. 101]):

Main definitions #

Main results #

References #

Memoryless modification rules and F-regret #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.modRegret {ι : Type u_1} [Fintype ι] (F : Set (ι → ι)) (p ℓ : ℕ → ι → ℝ) (T : ℕ) :

Cumulative regret R_F = sup_{f ∈ F} (L_H^T - L_{H, f}^T) of round weights p against a family F : Set (ι → ι) of memoryless modification rules over T rounds [BlumMansour2007AGT, §4.2, p. 82].

theorem Cslib.MachineLearning.OnlineLearning.Experts.sub_le_modRegret {ι : Type u_1} [Fintype ι] {F : Set (ι → ι)} (p ℓ : ℕ → ι → ℝ) (T : ℕ) {f : ι → ι} (hf : f ∈ F) :
∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i - ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t (f i) ≤ modRegret F p ℓ T

Regret against any single rule f ∈ F is bounded by modRegret F p ℓ T.

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_le_iff {ι : Type u_1} [Fintype ι] {F : Set (ι → ι)} (hF : F.Nonempty) {p ℓ : ℕ → ι → ℝ} {T : ℕ} {R : ℝ} :
modRegret F p ℓ T ≤ R ↔ ∀ f ∈ F, ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i ≤ ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t (f i) + R

For nonempty F, modRegret F p ℓ T ≤ R iff shifting actions by any f ∈ F reduces total expected loss by at most R.

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_mono {ι : Type u_1} [Fintype ι] {F₁ F₂ : Set (ι → ι)} (hF₁ : F₁.Nonempty) (hsub : F₁ ⊆ F₂) (p ℓ : ℕ → ι → ℝ) (T : ℕ) :
modRegret F₁ p ℓ T ≤ modRegret F₂ p ℓ T

Larger modification-rule families have larger modRegret [BlumMansour2007AGT, §4.2, p. 82].

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_nonneg_of_id_mem {ι : Type u_1} [Fintype ι] {F : Set (ι → ι)} (hid : id ∈ F) (p ℓ : ℕ → ι → ℝ) (T : ℕ) :
0 ≤ modRegret F p ℓ T

Any rule family containing id has nonnegative modRegret.

Bridges to swap regret, external regret, and internal regret #

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_univ_le_iff {ι : Type u_1} [Fintype ι] {p ℓ : ℕ → ι → ℝ} {T : ℕ} {R : ℝ} :
modRegret Set.univ p ℓ T ≤ R ↔ ∀ (δ : ι → ι), ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i ≤ ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t (δ i) + R

Bridge from modRegret Set.univ (R_{F^sw}) to the universal swap-regret inequality of SwapRegret.lean [BlumMansour2007AGT, §4.2, p. 82].

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_univ_eq_sum_sup {ι : Type u_1} [Fintype ι] [Nonempty ι] (p ℓ : ℕ → ι → ℝ) (T : ℕ) :
modRegret Set.univ p ℓ T = ∑ i : ι, Finset.univ.sup' ⋯ fun (j : ι) => ∑ t ∈ Finset.range T, p t i * (ℓ t i - ℓ t j)

Coordinatewise closed form of swap regret modRegret Set.univ: ∑ i, max_j ∑ t < T, p t i * (ℓ t i - ℓ t j) [BlumMansour2007AGT, §4.2, p. 82].

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_range_const {ι : Type u_1} [Fintype ι] [Nonempty ι] {p ℓ : ℕ → ι → ℝ} {T : ℕ} (hp : ∀ t < T, ∑ i : ι, p t i = 1) :
modRegret (Set.range (Function.const ι)) p ℓ T = ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i - minCumLoss ℓ T

When p t sums to 1 in every round t < T, modRegret over the constant modification rules Set.range (Function.const ι) (F^ex) equals (∑ t < T, ⟨p t, ℓ t⟩) - minCumLoss ℓ T [BlumMansour2007AGT, §4.2, pp. 81–82].

theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_range_const_le_iff {ι : Type u_1} [Fintype ι] [Nonempty ι] {p ℓ : ℕ → ι → ℝ} {T : ℕ} {R : ℝ} (hp : ∀ t < T, ∑ i : ι, p t i = 1) :
modRegret (Set.range (Function.const ι)) p ℓ T ≤ R ↔ ∀ (k : ι), ∑ t ∈ Finset.range T, ∑ i : ι, p t i * ℓ t i ≤ ∑ t ∈ Finset.range T, ℓ t k + R

Characterization of bounded external regret via modRegret (Set.range (Function.const ι)) when p t sums to 1 in every round t < T.

The family F^in of pairwise single-action switch modification rules Function.update id a b, replacing action a by b and leaving all other actions fixed [BlumMansour2007AGT, §4.2, p. 82, and §4.4.3, p. 90]. Includes a = b (id), matching the displayed formula max_{i, j ∈ X} ∑_t p_i^t (ℓ_i^t - ℓ_j^t) on p. 82 so that internal regret is always nonnegative.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.mem_internalRules {ι : Type u_1} [DecidableEq ι] {f : ι → ι} :
f ∈ internalRules ι ↔ ∃ (a : ι) (b : ι), f = Function.update id a b
@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.modRegret_internalRules_le_iff {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {p ℓ : ℕ → ι → ℝ} {T : ℕ} {R : ℝ} :
modRegret (internalRules ι) p ℓ T ≤ R ↔ ∀ (a b : ι), ∑ t ∈ Finset.range T, p t a * (ℓ t a - ℓ t b) ≤ R

Pairwise characterization of internal regret modRegret (internalRules ι) [BlumMansour2007AGT, §4.2, p. 82].

Exercise 4.1: Swap regret vs. internal regret #

Swap regret is at most N times internal regret [BlumMansour2007AGT, Exercise 4.1, p. 101].

theorem Cslib.MachineLearning.OnlineLearning.Experts.exists_modRegret_univ_eq_sub_one {N : ℕ} (hN : 2 ≤ N) :
∃ (p : ℕ → Fin N → ℝ) (ℓ : ℕ → Fin N → ℝ), (∀ t < N, (∀ (i : Fin N), 0 ≤ p t i) ∧ ∑ i : Fin N, p t i = 1) ∧ (∀ t < N, ∀ (i : Fin N), ℓ t i = 0 ∨ ℓ t i = 1) ∧ modRegret (internalRules (Fin N)) p ℓ N = 1 ∧ modRegret Set.univ p ℓ N = ↑N - 1

Original Ω(N) tightness witness complementing [BlumMansour2007AGT, Exercise 4.1, p. 101]: for every N ≥ 2, uniform play over T = N rounds on Fin N against the constant {0, 1} loss vector (0, 1, …, 1) achieves internal regret 1 and swap regret N - 1.

Exercise 4.2: Unbounded swap-to-external regret ratio for N = 3 #

theorem Cslib.MachineLearning.OnlineLearning.Experts.exists_modRegret_const_zero_and_univ_eq (m : ℕ) :
∃ (p : ℕ → Fin 3 → ℝ) (ℓ : ℕ → Fin 3 → ℝ), (∀ t < 6 * m, (∀ (i : Fin 3), p t i = 0 ∨ p t i = 1) ∧ ∑ i : Fin 3, p t i = 1) ∧ (∀ t < 6 * m, ∀ (i : Fin 3), ℓ t i = 0 ∨ ℓ t i = 1) ∧ modRegret (Set.range (Function.const (Fin 3))) p ℓ (6 * m) = 0 ∧ modRegret Set.univ p ℓ (6 * m) = 3 * ↑m

Zero external regret with arbitrarily large swap regret for N = 3 [BlumMansour2007AGT, Exercise 4.2, p. 101]: for every m : ℕ, over T = 6 * m rounds on Fin 3 there exist deterministic {0, 1} plays p and {0, 1} losses ℓ with modRegret (Set.range (Function.const (Fin 3))) p ℓ (6 * m) = 0 and modRegret Set.univ p ℓ (6 * m) = 3 * m.

theorem Cslib.MachineLearning.OnlineLearning.Experts.exists_unbounded_modRegret_univ_div_const (M : ℝ) :
∃ (T : ℕ) (p : ℕ → Fin 3 → ℝ) (ℓ : ℕ → Fin 3 → ℝ), (∀ t < T, (∀ (i : Fin 3), p t i = 0 ∨ p t i = 1) ∧ ∑ i : Fin 3, p t i = 1) ∧ (∀ t < T, ∀ (i : Fin 3), ℓ t i = 0 ∨ ℓ t i = 1) ∧ 0 < modRegret (Set.range (Function.const (Fin 3))) p ℓ T ∧ M < modRegret Set.univ p ℓ T / modRegret (Set.range (Function.const (Fin 3))) p ℓ T

Unbounded ratio between swap regret and positive external regret for N = 3 [BlumMansour2007AGT, Exercise 4.2, p. 101]: for every real M, there exist a horizon T, deterministic {0, 1} plays p, and {0, 1} losses ℓ on Fin 3 such that external regret is strictly positive and the ratio of swap regret to external regret strictly exceeds M.

Exercise 4.8: Multiplicative weight decay on ε-dominated actions vs. external regret #

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_prob_hedgeFactor_le_of_dominated {ι : Type u_1} [Fintype ι] {η ε : ℝ} (hη : 0 < η) (hε : 0 < ε) {ℓ : ℕ → ι → ℝ} {T : ℕ} {j : ι} {y : ι → ℝ} (hy0 : ∀ (i : ι), 0 ≤ y i) (hy1 : ∑ i : ι, y i = 1) (hdom : ∀ s < T, ∑ i : ι, y i * ℓ s i + ε ≤ ℓ s j) :
∑ t ∈ Finset.range T, prob (hedgeFactor η) ℓ t j ≤ 1 / (1 - Real.exp (-(η * ε)))

Cumulative Hedge weight on an action ε-dominated by a mixed strategy [BlumMansour2007AGT, §4.4.4 and Exercise 4.8, pp. 91–92, 101]: if 0 < η, 0 < ε, and in every round s < T action j incurs loss at least ε above a fixed mixed strategy y (∑ i, y i * ℓ s i + ε ≤ ℓ s j), then the total probability mass assigned to j by prob (hedgeFactor η) over all T rounds is at most 1 / (1 - exp (-(η * ε))). Since (1 - η') ^ x = hedgeFactor (-log (1 - η')) x for 0 < η' < 1, this also covers the [0, 1] Randomized Weighted Majority update w_i ← w_i (1 - η') ^ ℓ_i.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_prob_mwFactor_le_of_dominated {ι : Type u_1} [Fintype ι] {η ε : ℝ} (hη : 0 < η) (hε : 0 < ε) {ℓ : ℕ → ι → ℝ} {T : ℕ} {j k : ι} (hpos : ∀ s < T, ∀ (i : ι), 0 < mwFactor η (ℓ s i)) (hk0 : ∀ s < T, 0 ≤ ℓ s k) (hdom : ∀ s < T, ℓ s k + ε ≤ ℓ s j) :
∑ t ∈ Finset.range T, prob (mwFactor η) ℓ t j ≤ 1 / (η * ε)

Cumulative Polynomial Weights (mwFactor) weight on a pure-ε-dominated action [BlumMansour2007AGT, §4.4.4 and Exercise 4.8, pp. 91–92, 101]: if 0 < η, 0 < ε, all mwFactor η factors before T are positive, and in every round s < T action k has nonnegative loss with ℓ s k + ε ≤ ℓ s j, then the total probability mass assigned to j by prob (mwFactor η) over all T rounds is at most 1 / (η * ε). On {0, 1} losses mwFactor coincides with Randomized Weighted Majority, so this covers both PW and {0, 1}-RWM.

theorem Cslib.MachineLearning.OnlineLearning.Experts.exists_nonpos_external_regret_dominated_weight {ε : ℝ} (hε0 : 0 ≤ ε) (hεhalf : ε ≤ 1 / 2) (m : ℕ) :
∃ (p : ℕ → Fin 3 → ℝ) (ℓ : ℕ → Fin 3 → ℝ), (∀ (t : ℕ), (∀ (i : Fin 3), p t i = 0 ∨ p t i = 1) ∧ ∑ i : Fin 3, p t i = 1) ∧ (∀ (t : ℕ) (i : Fin 3), ℓ t i ∈ Set.Icc 0 1) ∧ (∀ (t : ℕ), ℓ t 0 + ε ≤ ℓ t 2) ∧ modRegret (Set.range (Function.const (Fin 3))) p ℓ (2 * m) ≤ 0 ∧ ∑ t ∈ Finset.range (2 * m), p t 2 = ↑m

Low external regret does not prevent high weight on an ε-dominated action [BlumMansour2007AGT, §4.4.4 and Exercise 4.8, pp. 92, 101]: for every ε ∈ [0, 1 / 2] and m : ℕ, over T = 2 * m rounds on Fin 3 there exist deterministic {0, 1} plays p and [0, 1] losses ℓ in which action 2 is ε-dominated by action 0 in every round (ℓ t 0 + ε ≤ ℓ t 2), external regret is nonpositive (modRegret (Set.range (Function.const (Fin 3))) p ℓ (2 * m) ≤ 0), and cumulative weight on action 2 equals m (time-average weight 1 / 2).