An online algorithm with vanishing swap regret
ProvedAGT.no_swap_regret_algorithmThere is an online algorithm whose swap regret against every adversary is at most — the mission goal, Corollary 4.16 of Algorithmic Game Theory in explicit form. For every number of actions and every known horizon there exists an online algorithm , playing a genuine probability distribution after every history, whose swap regret is uniformly small: against every -valued loss sequence and every modification rule ,
Per round, the swap regret vanishes at rate ; combined with Theorem 4.12, if every player of a finite game runs such an algorithm, the empirical joint play is a -correlated equilibrium — the chapter's punchline, and the algorithmic foundation of correlated equilibrium.
A note on the constant and the quantifiers. The book states the bound as ; the constant is the one its own route produces — Polynomial Weights tuned at has external regret (in the small-horizon regime this follows from the trivial bound rather than from the potential argument), and the reduction of Theorem 4.15 multiplies it by . The algorithm is quantified before the loss sequence and the rule : one must serve every adversary, so no witness can be chosen with hindsight. may depend on (the book's known-horizon convention; guess-and-double removes this at a constant-factor cost and is out of scope).
import Definitions.Def_agt_regret import Mathlib.Analysis.SpecialFunctions.Sqrt import Mathlib.Analysis.SpecialFunctions.Log.Basic
namespace AGT
/-- **Corollary 4.16 of *Algorithmic Game Theory* (explicit form)**, the
capstone of Chapter 4: there is an online algorithm with vanishing swap
regret. For every number of actions `n + 1` and every known horizon `T`
there is an online algorithm `H` playing genuine distributions such that
against every `[0,1]`-valued loss sequence and every modification rule `F`,
`L_H ≤ L_{H,F} + 2 (n+1) √(T ln(n+1))`.
The explicit constant is the one the chapter's own route produces: the
Polynomial Weights bound (Theorem 4.6) tuned at `η = min{√(ln N / T), 1/2}`
gives external regret `2√(T ln N)`, and the external-to-swap reduction
(Theorem 4.15) multiplies it by `N`. Combined with Theorem 4.12, an `H` of
this quality for every player drives the empirical joint play into an
`ε`-correlated equilibrium at rate `ε = 2N√(ln N / T)`. -/
theorem no_swap_regret_algorithm {n : ℕ} (T : ℕ) :
∃ H : OnlineAlgorithm (n + 1), (∀ h, IsLottery (H h)) ∧
∀ ℓ : ℕ → Fin (n + 1) → ℝ, (∀ t i, ℓ t i ∈ Set.Icc (0 : ℝ) 1) →
∀ F : Fin (n + 1) → Fin (n + 1),
algLoss H ℓ T ≤ swapLoss H ℓ F T +
2 * (n + 1) * Real.sqrt (T * Real.log (n + 1)) := by
sorry
end AGTRead-back
What the Lean code literally says, in plain math · claude-fable-5
Read-back: no_swap_regret_algorithm
Setting. Fix a natural number (implicit) and a natural number (the time horizon, given as an explicit argument). Throughout, the action set is , i.e. it has exactly elements (so it is never empty). An online algorithm on actions is, by the custom definition being used, simply a function that maps every finite list of loss vectors in (a "history") to a single vector in ; nothing in the type forces the output to be a probability distribution — that is imposed separately below. The algorithm is deterministic as a function of the history.
What the theorem asserts. For every and every , there exists an online algorithm (which may depend on both and , since both are fixed before the existential) satisfying both of the following.
- always outputs a lottery. For every finite list of loss vectors — including the empty list, and including lists of arbitrary length and with arbitrary real entries, whether or not they could ever arise as an actual history — the output satisfies the custom lottery predicate:
- A uniform swap-regret bound at horizon . For every loss sequence such that (the closed interval, endpoints included) for all times and all actions , and for every function (an arbitrary "swap" map, not required to be injective or surjective), the following inequality holds:
Unfolding the two loss quantities. Write for the vector the algorithm outputs at time when fed the list of the first loss vectors in order (at this is the empty list). Then, by the custom definitions:
- the algorithm's (expected) cumulative loss is
- and the swapped loss under is
i.e. the same play distributions , but each action 's loss replaced by the loss of the swapped action . Both sums run over the time steps .
Quantifier order, precisely. The single algorithm is chosen after and are fixed, but before and : one and the same must satisfy the lottery condition for all histories and the regret inequality uniformly over all -valued loss sequences and all swap functions , with the same additive slack . The inequality is non-strict (), and it is asserted only at the single horizon named in the statement, not for all horizons.
The bound expression. The additive term is exactly , where and are the natural numbers cast to reals, is the natural logarithm, and is the real square root (Lean's total square root, which returns on negative inputs; here the argument is nonnegative since ). Note the bound scales linearly in the number of actions outside the square root, while also appears inside via .
Degenerate cases silently included. If , all three loss quantities are empty sums and the bound term is , so the claim reduces to . If (one action), then , the bound term is , and must be the identity, so the claim reduces to . The loss sequence is defined on all of and the constraint is required at every time , including times that never enter the sums.
Confirmed by the mission captain (proposal self-audit).