Documentation

CslibFrontier.MachineLearning.OnlineLearning.ZeroSum

Solving zero-sum games with multiplicative weights #

Let M : I → J → ℝ be the loss matrix of a finite zero-sum game with entries in [0, 1]: the row player pays M i j. Run multiplicative weights on the rows with learning rate ε / 2, where the loss vector of round t is the column M · (col t) of a column col t that best responds to the current distribution (bestResponse). After T ≥ 4 ln n / ε ^ 2 rounds, with n = card I [AroraHazanKale2012, §3.2, Theorem 3.1], [FS99]:

This is an algorithmic minimax theorem. The last inequality shows min_p max_j ≤ max_q min_i + ε for every ε > 0 without the exact minimax theorem, and it gives an explicit approximate form of Convexity.StdSimplex.exists_forall_sum_le_of_forall_exists_sum_le (sum_averageProb_mul_le_add_of_forall_exists_sum_le). The value v is that of the exact minimax theorem (Cslib.Probability.IsMinimaxValue, Cslib.Probability.exists_isMinimaxValue).

The theorems take the best-response property of the columns as a hypothesis, so they apply to any best-response oracle; bestResponsePlay is one, defined by choice (bestResponsePlay_spec), and bestResponsePlay_approx_optimal is the result for it with T = ⌈4 ln n / ε ^ 2⌉, the number of rounds of [AroraHazanKale2012, proof of Theorem 3.1].

[AroraHazanKale2012, §3.2, proof of Theorem 3.1] proves all three bounds: the average payoff bound is their (3.5), the empirical column bound is derived from (3.5), and the bound for the average row strategy is their footnote 1 (their main text uses the distribution of the best single round instead). They note that the algorithm and the result are those of [FS99], whose proof of convergence is different. [AHK12] apply Corollary 2.2 against an optimal row strategy p*. Here Theorem 2.1 (mw_regret_le) is applied against each single row i, and the comparison is with the payoff of i against the empirical column distribution. This avoids p* and gives the inequality without v above; the ε-optimality bounds then follow from it and the defining properties of the value (IsMinimaxValue.exists_le, IsMinimaxValue.exists_ge).

Main definitions #

Main results #

References #

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.averageProb {I : Type u_1} (p : ℕ → I → ℝ) (T : ℕ) (i : I) :

The average of the distributions p t over the first T rounds.

@[simp]
theorem Cslib.MachineLearning.OnlineLearning.Experts.averageProb_apply {I : Type u_1} (p : ℕ → I → ℝ) (T : ℕ) (i : I) :
averageProb p T i = (∑ t ∈ Finset.range T, p t i) / ↑T
noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.empirical {J : Type u_2} [DecidableEq J] (col : ℕ → J) (T : ℕ) (j : J) :

The empirical distribution of the first T entries of the sequence col.

theorem Cslib.MachineLearning.OnlineLearning.Experts.averageProb_nonneg {I : Type u_1} {p : ℕ → I → ℝ} {T : ℕ} (hp : ∀ t < T, ∀ (i : I), 0 ≤ p t i) (i : I) :

The average is nonnegative if the averaged distributions are.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_averageProb_mul {I : Type u_1} [Fintype I] (p : ℕ → I → ℝ) (T : ℕ) (f : I → ℝ) :
∑ i : I, averageProb p T i * f i = (∑ t ∈ Finset.range T, ∑ i : I, p t i * f i) / ↑T

A weighted sum against the average weights equals the average of the individual weighted sums. For a positive horizon and probability weights, this gives the expected payoff under the average distribution.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_averageProb {I : Type u_1} [Fintype I] {p : ℕ → I → ℝ} {T : ℕ} (hT : 0 < T) (hp : ∀ t < T, ∑ i : I, p t i = 1) :
∑ i : I, averageProb p T i = 1

The average of T > 0 distributions is a distribution.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_empirical_mul {J : Type u_2} [Fintype J] [DecidableEq J] (col : ℕ → J) (T : ℕ) (f : J → ℝ) :
∑ j : J, empirical col T j * f j = (∑ t ∈ Finset.range T, f (col t)) / ↑T

The expectation of f under the empirical distribution is the average of f along the sequence.

theorem Cslib.MachineLearning.OnlineLearning.Experts.empirical_nonneg {J : Type u_2} [DecidableEq J] (col : ℕ → J) (T : ℕ) (j : J) :
0 ≤ empirical col T j

The empirical distribution is nonnegative.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_empirical {J : Type u_2} [Fintype J] [DecidableEq J] (col : ℕ → J) {T : ℕ} (hT : 0 < T) :
∑ j : J, empirical col T j = 1

The empirical distribution of T > 0 entries is a distribution.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.bestResponse {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] [Nonempty J] (M : I → J → ℝ) (p : I → ℝ) :
J

A best response of the column player to the row distribution p: a column maximizing the expected loss ∑ i, p i * M i j of the row player.

theorem Cslib.MachineLearning.OnlineLearning.Experts.le_bestResponse {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] [Nonempty J] (M : I → J → ℝ) (p : I → ℝ) (j : J) :
∑ i : I, p i * M i j ≤ ∑ i : I, p i * M i (bestResponse M p)

bestResponse M p maximizes the row player's expected loss under p.

noncomputable def Cslib.MachineLearning.OnlineLearning.Experts.bestResponsePlay {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] [Nonempty J] (M : I → J → ℝ) (η : ℝ) (t : ℕ) :
J

The column played in round t when multiplicative weights with learning rate η plays the rows against best responses: the column that best responds to the current distribution.

theorem Cslib.MachineLearning.OnlineLearning.Experts.bestResponsePlay_spec {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] [Nonempty J] (M : I → J → ℝ) (η : ℝ) (t : ℕ) (j : J) :
∑ i : I, prob (mwFactor η) (fun (s : ℕ) (i : I) => M i (bestResponsePlay M η s)) t i * M i j ≤ ∑ i : I, prob (mwFactor η) (fun (s : ℕ) (i : I) => M i (bestResponsePlay M η s)) t i * M i (bestResponsePlay M η t)

bestResponsePlay best responds to the learner's distribution in every round.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_averageProb_mul_le_sum_empirical_mul_add {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] {M : I → J → ℝ} {ε : ℝ} {T : ℕ} {col : ℕ → J} [DecidableEq J] (hM : ∀ (i : I) (j : J), M i j ∈ Set.Icc 0 1) (hε : 0 < ε) (hε' : ε ≤ 1) (hT0 : 0 < T) (hT : 4 * Real.log ↑(Fintype.card I) ≤ ε ^ 2 * ↑T) (hbr : ∀ t < T, ∀ (j : J), ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i j ≤ ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i (col t)) (i : I) (j : J) :
∑ k : I, averageProb (prob (mwFactor (ε / 2)) fun (s : ℕ) (i : I) => M i (col s)) T k * M k j ≤ ∑ l : J, empirical col T l * M i l + ε

The approximate minimax inequality: for a loss matrix with entries in [0, 1], 0 < ε ≤ 1 and T > 0 rounds with ε ^ 2 T ≥ 4 ln n, if every column col t best responds to the distribution of multiplicative weights with learning rate ε / 2, then against every column j the average distribution pays at most ε more than every row i pays against the empirical distribution of the columns.

theorem Cslib.MachineLearning.OnlineLearning.Experts.averagePayoff_mem_Icc {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] {M : I → J → ℝ} {ε : ℝ} {T : ℕ} {col : ℕ → J} (hM : ∀ (i : I) (j : J), M i j ∈ Set.Icc 0 1) (hε : 0 < ε) (hε' : ε ≤ 1) (hT0 : 0 < T) (hT : 4 * Real.log ↑(Fintype.card I) ≤ ε ^ 2 * ↑T) (hbr : ∀ t < T, ∀ (j : J), ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i j ≤ ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i (col t)) {v : ℝ} (hv : Probability.IsMinimaxValue M v) :
(∑ t ∈ Finset.range T, ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i (col t)) / ↑T ∈ Set.Icc v (v + ε)

Multiplicative weights against best responses approximates the value [AroraHazanKale2012, (3.5)]: under the hypotheses of sum_averageProb_mul_le_sum_empirical_mul_add, the average payoff (1 / T) ∑ t, ⟨p t, M · (col t)⟩ lies in [v, v + ε], where v is the value of the game.

theorem Cslib.MachineLearning.OnlineLearning.Experts.mw_bestResponse_approx_optimal {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] {M : I → J → ℝ} {ε : ℝ} {T : ℕ} {col : ℕ → J} [DecidableEq J] (hM : ∀ (i : I) (j : J), M i j ∈ Set.Icc 0 1) (hε : 0 < ε) (hε' : ε ≤ 1) (hT0 : 0 < T) (hT : 4 * Real.log ↑(Fintype.card I) ≤ ε ^ 2 * ↑T) (hbr : ∀ t < T, ∀ (j : J), ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i j ≤ ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i (col t)) {v : ℝ} (hv : Probability.IsMinimaxValue M v) :
(∀ (j : J), ∑ k : I, averageProb (prob (mwFactor (ε / 2)) fun (s : ℕ) (i : I) => M i (col s)) T k * M k j ≤ v + ε) ∧ ∀ (i : I), v - ε ≤ ∑ l : J, empirical col T l * M i l

Multiplicative weights solves zero-sum games [AroraHazanKale2012, Theorem 3.1], [FS99]: under the hypotheses of sum_averageProb_mul_le_sum_empirical_mul_add, the average distribution of the row player pays at most v + ε against every column, and the empirical distribution of the columns collects at least v - ε against every row, where v is the value of the game.

theorem Cslib.MachineLearning.OnlineLearning.Experts.sum_averageProb_mul_le_add_of_forall_exists_sum_le {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] {M : I → J → ℝ} {ε : ℝ} {T : ℕ} {col : ℕ → J} (hM : ∀ (i : I) (j : J), M i j ∈ Set.Icc 0 1) (hε : 0 < ε) (hε' : ε ≤ 1) (hT0 : 0 < T) (hT : 4 * Real.log ↑(Fintype.card I) ≤ ε ^ 2 * ↑T) (hbr : ∀ t < T, ∀ (j : J), ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i j ≤ ∑ i : I, prob (mwFactor (ε / 2)) (fun (s : ℕ) (i : I) => M i (col s)) t i * M i (col t)) {c : ℝ} (h : ∀ (q : Convexity.StdSimplex ℝ J), ∃ (i : I), ∑ j : J, q.weights j * M i j ≤ c) (j : J) :
∑ k : I, averageProb (prob (mwFactor (ε / 2)) fun (s : ℕ) (i : I) => M i (col s)) T k * M k j ≤ c + ε

An algorithmic minimax theorem: under the hypothesis of Convexity.StdSimplex.exists_forall_sum_le_of_forall_exists_sum_le (against every mixed column strategy some row pays at most c) and the hypotheses of sum_averageProb_mul_le_sum_empirical_mul_add, the explicit average distribution of multiplicative weights pays at most c + ε against every column.

theorem Cslib.MachineLearning.OnlineLearning.Experts.bestResponsePlay_approx_optimal {I : Type u_1} {J : Type u_2} [Fintype I] [Fintype J] [DecidableEq J] [Nonempty J] {M : I → J → ℝ} {ε v : ℝ} (hn : 2 ≤ Fintype.card I) (hM : ∀ (i : I) (j : J), M i j ∈ Set.Icc 0 1) (hε : 0 < ε) (hε' : ε ≤ 1) (hv : Probability.IsMinimaxValue M v) :
have T := ⌈4 * Real.log ↑(Fintype.card I) / ε ^ 2⌉₊; (∀ (j : J), ∑ k : I, averageProb (prob (mwFactor (ε / 2)) fun (s : ℕ) (i : I) => M i (bestResponsePlay M (ε / 2) s)) T k * M k j ≤ v + ε) ∧ ∀ (i : I), v - ε ≤ ∑ l : J, empirical (bestResponsePlay M (ε / 2)) T l * M i l

Multiplicative weights solves zero-sum games [AroraHazanKale2012, Theorem 3.1], for the best-response oracle bestResponsePlay: for a game with n ≥ 2 rows, entries in [0, 1] and value v, and 0 < ε ≤ 1, after T = ⌈4 ln n / ε ^ 2⌉ rounds of multiplicative weights with learning rate ε / 2 against best responses, the average row distribution pays at most v + ε against every column, and the empirical column distribution collects at least v - ε against every row.