diff --git a/LMLRoadmaps/Bandits/README.md b/LMLRoadmaps/Bandits/README.md index 57e557f..9fbcbbb 100644 --- a/LMLRoadmaps/Bandits/README.md +++ b/LMLRoadmaps/Bandits/README.md @@ -2,23 +2,25 @@ Develop the regret theory of multi-armed and linear bandits: stochastic bandits with finitely many arms, their minimax and instance-dependent lower bounds, adversarial bandits with finitely -many arms and with expert advice, online linear optimization, and stochastic and adversarial -linear bandits. The headline results are the regret bounds of MOSS, asymptotically optimal UCB, -KL-UCB, Thompson sampling, Exp3, Exp3-IX, Exp4, OFUL, phased elimination with G-optimal designs, -and mirror descent with bandit feedback, matched by the minimax lower bounds and the Lai–Robbins -lower bound. +many arms and with expert advice, online linear and convex optimization, and stochastic and +adversarial linear bandits. The headline results are the regret bounds of MOSS, asymptotically +optimal UCB, KL-UCB and Thompson sampling for exponential families, Exp3, Exp3-IX and Exp4 against +adaptive adversaries, OFUL, phased elimination with G-optimal designs, and mirror descent with +bandit feedback, matched by the minimax lower bounds and the Lai–Robbins lower bound. Build the surrounding library at the generality the proofs support: index policies and weight-based randomized policies, Ville's inequality and time-uniform concentration, the binary -relative entropy, the Bretagnolle–Huber inequality, Legendre functions and Bregman projections, -follow-the-regularized-leader and mirror descent, regularized least squares with self-normalized -confidence sets, the elliptical potential lemma, and the Kiefer–Wolfowitz theorem. +relative entropy and the upper confidence levels of exponential families, the Bretagnolle–Huber +inequality, Legendre functions and Bregman projections, follow-the-regularized-leader and mirror +descent with time-varying regularizers and local norms, regularized and unregularized least +squares with self-normalized confidence sets, the elliptical potential lemma, and the +Kiefer–Wolfowitz theorem. `README.md` is the definitive specification; `Suggested.lean` records selected interfaces and is not an exhaustive checklist. Suggested homes: `LMLExplore/Bandits/` for bandit material, `LMLExplore/OnlineLearning/` for -online linear optimization, and the mathematical home of each general tool (for example +online linear and convex optimization, and the mathematical home of each general tool (for example `LMLExplore/Probability/Martingale/` for Ville's inequality, `LMLExplore/InformationTheory/` for the binary relative entropy and Bretagnolle–Huber, `LMLExplore/Analysis/Convex/` for Legendre functions, `LMLExplore/Analysis/InnerProductSpace/` for design operators and the Kiefer–Wolfowitz @@ -27,22 +29,28 @@ theorem). ## Scope and dependencies This roadmap owns regret minimization for: stochastic bandits with a finite set of arms; -adversarial bandits with a finite set of arms against an oblivious reward table, including bandits -with expert advice; online linear optimization with full information; stochastic linear bandits -with possibly changing decision sets; and adversarial linear bandits with finite action sets or the -Euclidean unit ball. +adversarial bandits with a finite set of arms against adaptive adversaries, oblivious reward tables +included, and bandits with expert advice; online linear and convex optimization with full +information; stochastic linear bandits with possibly changing decision sets; and adversarial linear +bandits with finite action sets or the Euclidean unit ball. | Material | Owner and interface consumed here | | --- | --- | | Interaction protocol, runs, trajectory measure, stochastic and oblivious environments | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `stationaryEnv`, `obliviousEnv`, `onlineEvalEnv`, `detAlgorithm` | | Pull counts, reward sums, empirical means, the per-arm reward stream model | LML `SequentialLearning/FiniteActions.lean`, `SumRewards.lean`, `Online/Bandit/ArrayProbSpace.lean`, `Online/Bandit/RewardByCountMeasure.lean` | | Stochastic regret, gaps, regret decomposition; regret of explore-then-commit, UCB and Bayesian Thompson sampling | LML `Online/Bandit/Regret.lean` and `Online/Bandit/Algorithms/` | +| Means of the feedback laws along a run | LML `SequentialLearning/Means.lean` (`Environment.means`) | | KL divergence of interaction histories (time-sum form) | LML `SequentialLearning/DivergenceDecomposition.lean` | | KL divergence, chain rule, data processing, Pinsker, Donsker–Varadhan | Mathlib `InformationTheory/KullbackLeibler/`, LML `ForMathlib/InformationTheory/KullbackLeibler/`, Tau Ceti `InformationTheory/KullbackLeibler/` | +| Exponential families: members, means, natural parameters, divergence and Cramér–Chernoff rate function; the Cramér–Chernoff bound under domination by a member | Identification roadmap, Layer 1.2 (`expFamily`, `expFamilyMeans`, `natParam`, `expFamilyDiv`) | +| Conditional MGF domination, its supermartingale and time-uniform bound; σ²-sub-Gaussian laws are dominated by the Gaussian family | Identification roadmap, Layer 4.2 | +| Transfer of events about the first `s` rewards of each arm from runs to the reward-stream model | Identification roadmap, Layer 4.1 | | Sub-Gaussian random variables, Hoeffding and Azuma–Hoeffding, Doob's maximal inequality | Mathlib `Probability/Moments/SubGaussian.lean`, `Probability/Martingale/` | | Bregman divergence and subgradients | LML `ForMathlib/Analysis/Convex/Bregman/`, `ForMathlib/Analysis/Convex/Subgradient/` | | Fenchel conjugate, strong convexity first-order bound | Tau Ceti `Analysis/Convex/Conjugate.lean`, `Analysis/Convex/Strong.lean` | | Positive operators, Loewner order, matrix determinant lemma, Woodbury identity | Mathlib `Analysis/InnerProductSpace/Positive.lean`, `LinearAlgebra/Matrix/SchurComplement.lean`, `LinearAlgebra/Matrix/NonsingularInverse.lean` | +| Moore–Penrose inverse | Tau Ceti `Analysis/InnerProductSpace/MoorePenrose.lean` | +| Finitely supported probability measures | Mathlib `Geometry/Convex/ConvexSpace/Defs.lean` (`Convexity.StdSimplex`) | Build missing material in this roadmap where it is listed as a target, and consume existing implementations directly. @@ -51,7 +59,8 @@ Outside this roadmap: pure exploration and best-arm identification (LML's `Ident sparse linear bandits, combinatorial and semi-bandits, non-stationary bandits, ranking, partial monitoring, Markov decision processes, Bayesian-optimal policies and Gittins indices, Bayesian regret beyond what LML proves, high-probability lower bounds, asymptotic lower bounds for linear bandits, -and online convex optimization with nonlinear losses. Scalar Bernstein, McDiarmid and matrix +and bandit convex optimization (convex losses with bandit feedback). AdaHedge and its regret bounds +belong to the Identification roadmap (Layer 6.1). Scalar Bernstein, McDiarmid and matrix concentration inequalities belong to Tau Ceti's `RandomMatrices` roadmap; nothing here needs them. ## Conventions @@ -73,8 +82,8 @@ they are. **Rewards and losses.** Stochastic bandits, adversarial bandits with finitely many arms and bandits with expert advice use rewards and maximization, as LML's `regret` and [LS, Chapters 4–18] do. -Online linear optimization and adversarial linear bandits use losses and minimization, as [LS, -Chapters 26–28] and convex analysis do. Where the analysis of a reward-based algorithm passes +Online linear and convex optimization and adversarial linear bandits use losses and minimization, +as [LS, Chapters 26–28] and convex analysis do. Where the analysis of a reward-based algorithm passes through a loss-based tool, state the translation $y = 1 - x$ (or $y=-x$) once as a lemma. **Stochastic bandits.** A stochastic bandit is a Markov kernel `ν : Kernel α ℝ` and its environment @@ -85,10 +94,23 @@ bounded rewards are `∀ a, ∀ᵐ x ∂(ν a), x ∈ Set.Icc 0 1`. Where [LS] a state the result for σ²-sub-Gaussian rewards; the constants below include $\sigma^2$. **Regret.** The expected stochastic regret is `P[regret ν A n]` with LML's `regret`, the expectation -of the pseudo-regret $\sum_{t0$ and $\gamma_t\ge0$ used at Lean +round $t$. A rate tuned for the horizon $n$ is a constant sequence; an anytime rate does not depend +on the horizon, for example $\eta_t=c/\sqrt{t+1}$. Bounds after $n$ rounds involve $\eta_{n-1}$, +the rate of the last round played. **Theorem shapes.** Upper bounds quantify over runs: for every `IsAlgEnvSeq O A Y alg env P`, a bound on an expectation or a probability under `P`. Lower bounds quantify over algorithms and @@ -101,8 +123,9 @@ constant when the proof gives one; otherwise state `∃ C > 0, ∀ …` with `C` problem parameter. **Generality.** Each layer lists where its statements generalize [LS]. Do not reintroduce the -book's special cases (`Fin K`, unit variance, $\mathbb R^d$ instead of an inner product space) as -the primary statements; derive them as corollaries when useful. +book's special cases (`Fin K`, unit variance, Gaussian or Bernoulli arms where an exponential family +works, oblivious tables, learning rates tuned to the horizon, $\mathbb R^d$ instead of an inner +product space) as the primary statements; derive them as corollaries when useful. **Namespaces.** Bandit definitions live in `LMLExplore.Bandits`, online-learning definitions in `LMLExplore.OnlineLearning`, general tools in `LMLExplore` or in the namespace of the type they act @@ -117,7 +140,8 @@ dependency versions used to check the interfaces (LML `53be244`, Mathlib `2e318f | Foundation | Existing source | | --- | --- | -| Interaction protocol and law of a run | [LML `Algorithm.lean`][lml-alg] (`Algorithm`, `Environment`, `IsAlgEnvSeq`, `history`, `IsAlgEnvSeq.filtration`), [`IonescuTulceaSpace.lean`][lml-it] (`trajMeasure`, `IT.isAlgEnvSeq_trajMeasure`, `IsAlgEnvSeq.map_trajectory`) | +| Interaction protocol and law of a run | [LML `Algorithm.lean`][lml-alg] (`Algorithm`, `Environment`, `IsAlgEnvSeq`, `history`, `IsAlgEnvSeq.filtration`, `IsAlgEnvSeq.filtrationObs`: the history before round `t` and the observation of round `t`), [`IonescuTulceaSpace.lean`][lml-it] (`trajMeasure`, `IT.isAlgEnvSeq_trajMeasure`, `IsAlgEnvSeq.map_trajectory`) | +| Means of the feedback laws | [LML `Means.lean`][lml-means] (`Environment.means`, `IsAlgEnvSeq.condExp_feedback`, `means_bandit`) | | Stochastic and oblivious environments | [LML `StationaryEnv.lean`][lml-env] (`stationaryEnv`, `obliviousEnv`, `IsObliviousEnv`), [`EvaluationEnv.lean`][lml-eval] (`onlineEvalEnv g hg`, the oblivious adversary with bandit feedback) | | Deterministic algorithms and measurable argmax | [LML `Deterministic.lean`][lml-det] (`detAlgorithm`), [`MeasurableArg.lean`][lml-argmax] (`argmax`, `measurable_argmax`) | | Counts, sums, empirical means, per-arm reward streams | [LML `FiniteActions.lean`][lml-fa] (`pullCount`, `pullCount'`, `rewardByCount`), [`SumRewards.lean`][lml-sum] (`sumRewards`, `empMean`, `empMean'`), [`Online/Bandit/SumRewards.lean`][lml-conc] (`prob_sumRewards_sub_pullCount_mul_ge_le` and the transfer to the i.i.d. stream model) | @@ -127,7 +151,9 @@ dependency versions used to check the interfaces (LML `53be244`, Mathlib `2e318f | Sub-Gaussian concentration and martingales | Mathlib [`SubGaussian.lean`][ml-subg] (`HasSubgaussianMGF`, `HasCondSubgaussianMGF`, `hasSubgaussianMGF_of_mem_Icc`, `measure_sum_ge_le_of_iIndepFun`, `measure_sum_ge_le_of_hasCondSubgaussianMGF`), [`OptionalStopping.lean`][ml-os] (`maximal_ineq`), `Supermartingale` | | Laws | Mathlib `gaussianReal`, `bernoulliMeasure`, `multivariateGaussian`; Tau Ceti [`Gaussian/Cdf.lean`][tc-gauss] (`measureReal_Ioi_gaussianReal`) | | Convex analysis | LML [`Bregman/Basic.lean`][lml-breg] (`bregDiv`, notation `D_[f](x, y, J)`, `bregDiv_three_point`), [`Subgradient/`][lml-subgrad]; Tau Ceti [`Conjugate.lean`][tc-conj] (`fenchelConjugate`, for a bilinear pairing), [`Strong.lean`][tc-strong] (`StrongConvexOn.add_add_le_of_hasFDerivWithinAt`); Mathlib `StrongConvexOn`, `PiLp`; LMLExplore `simplex` (`Analysis/Convex/Simplex.lean`) | -| Linear algebra | Mathlib `ContinuousLinearMap.IsPositive` and its Loewner order, `LinearMap.det`, `Matrix.det_one_add_replicateCol_mul_replicateRow`, `Matrix.add_mul_mul_inv_eq_sub`; Tau Ceti [`Frame.lean`][tc-frame] (`frameOperator`) and [`AffineNormalization.lean`][tc-affine] (`IsCompact.exists_affineBasis_abs_coord_le_one`) | +| Linear algebra | Mathlib `ContinuousLinearMap.IsPositive` and its Loewner order, `LinearMap.det`, `Matrix.det_one_add_replicateCol_mul_replicateRow`, `Matrix.add_mul_mul_inv_eq_sub`; Tau Ceti [`Frame.lean`][tc-frame] (`frameOperator`), [`AffineNormalization.lean`][tc-affine] (`IsCompact.exists_affineBasis_abs_coord_le_one`) and [`MoorePenrose.lean`][tc-mp] (`LinearMap.moorePenroseInverse`, `LinearMap.IsMoorePenroseInverse`, `LinearEquiv.moorePenroseInverse_eq_symm`) | +| Designs | Mathlib `Convexity.StdSimplex` (finitely supported probability weights; `StdSimplex.map`, `StdSimplex.range_toFun_comp_weights`) | +| LMLExplore material that the general forms below extend | exponential families (`Probability/Distributions/ExponentialFamily/`: `Measure.expFamily`, `expFamilyMeans`, `natParam`, `expFamilyDiv`), MGF domination (`MGFDominatedAbove`, `MGFDominatedBelow`, `mgfDominatedAbove_bernoulliMeasure`, `mgfDominatedBelow_bernoulliMeasure`), the Bandits algorithms `ucbF`, `klucb`, `gaussianTS`, `exp3`, `exp3IX`, `exp4` and the lower-bound files, follow-the-perturbed-leader policies (`perturbedLeaderAlgorithm`, `PerturbedLeader.lintegral_pullCount_le`), the FTRL lemma `sum_apply_sub_le_ftrl` (time-varying regularizers), `ConvexOn.exists_mem_segment_apply_sub_sub_bregDiv_div_le` (second-order Bregman bound), `softmax_regret_le`, `IsUnbiasedRound`, `designOp`, `ridgeEstimate` | The [Kiefer–Wolfowitz formalization in `colt-2026-83`][kw] (Apache-2.0, no `sorry`) proves the existence of G-optimal designs for compact spanning subsets of `EuclideanSpace ℝ ι` @@ -146,12 +172,12 @@ dependency sync that brings the rename updates this roadmap and the code togethe | Layer | Content | Prerequisites | | --- | --- | --- | | 0 | Instances, binary relative entropy, policies, regret notions | LML framework | -| 1 | Concentration and maximal inequalities | Layer 0 | +| 1 | Concentration and maximal inequalities | Layer 0; Identification roadmap Layers 1.2, 4.1 and 4.2 | | 2 | UCB-type algorithms for sub-Gaussian rewards | Layers 0–1; LML UCB | -| 3 | KL-UCB for rewards in $[0,1]$ | Layers 0–1 | -| 4 | Lower bounds for finitely many arms | Layer 0; LML divergence decomposition | -| 5 | Thompson sampling | Layers 0–1; Layer 4 for asymptotic optimality | -| 6 | Convex analysis and online linear optimization | Layer 0 | +| 3 | KL-UCB for exponential families | Layers 0–1; Identification roadmap Layer 1.2 | +| 4 | Lower bounds for finitely many arms | Layer 0; LML divergence decomposition; Layers 2–3 for item 5 | +| 5 | Thompson sampling | Layers 0–1; Identification roadmap Layer 1.2; Layer 4 for asymptotic optimality | +| 6 | Convex analysis, online linear and convex optimization | Layer 0 | | 7 | Adversarial bandits with finitely many arms and expert advice | Layers 0, 6; Layer 4.5 for the lower bound | | 8 | Least squares, self-normalized bounds, optimal design | Layer 1 | | 9 | Stochastic linear bandits | Layers 0, 8; Layer 4 tools for lower bounds | @@ -187,17 +213,31 @@ dependency sync that brings the rename updates this roadmap and the code togethe $A_t=a$ then $I_t(a)\ge I_t(b)$ for all $b$; an arm with index $+\infty$ is pulled before any arm with a finite index; under an index that is $+\infty$ exactly on unpulled arms, every arm is pulled once during the first $k$ rounds. -5. **Adversarial and expert regrets.** Define the adversarial regret $R_n(x)$ of the Conventions for - runs against `onlineEvalEnv x _`, and for bandits with expert advice the regret - $R_n=\mathbb E\big[\max_{m}\sum_{t0$: $\frac{x}{x^2+1}\varphi(x)\le P(Z\ge x)\le\min\{\varphi(x)/x,\ \tfrac12e^{-x^2/2}\}$, with $\varphi$ the standard Gaussian density. @@ -244,11 +292,14 @@ unpulled arms are $+\infty$. $\mathbb E[R_n]\le 2\sqrt{8cKn\log(n+1)}+\big(4+\frac{2\sigma^2}{c-2\sigma^2}\big)\sum_a\Delta_a$, by splitting the arms according to whether $\Delta_a$ is below $\sqrt{8cK\log(n+1)/n}$ (the analogue of [LS, Theorem 7.2]). -2. **Asymptotically optimal UCB.** Define the index policy with index +2. **Asymptotically optimal UCB.** Define the index policy `ucbF σ2` with index $\hat\mu_a+\sqrt{2\sigma^2\log f(t)/T_a}$, $f(t)=1+t\log^2 t$ [LS, Algorithm 6]. Prove [LS, Theorem 8.1] for σ²-sub-Gaussian rewards: $$\mathbb E[R_n]\le\sum_{a:\Delta_a>0}\inf_{\varepsilon\in(0,\Delta_a)}\Delta_a\Big(1+\frac{5\sigma^2}{\varepsilon^2}+\frac{2\sigma^2\big(\log f(n)+\sqrt{\pi\log f(n)}+1\big)}{(\Delta_a-\varepsilon)^2}\Big),$$ and, in eventual form, $\limsup_n\mathbb E[R_n]/\log n\le\sum_{a:\Delta_a>0}2\sigma^2/\Delta_a$. + This index is the KL-UCB index of the Gaussian family of variance $\sigma^2$ (Layer 3.3), and the + eventual form is also the Gaussian instance of Layer 3.4; the explicit constants above keep the + proof through [LS, Lemma 8.2]. 3. **MOSS.** Define the horizon-dependent index policy with index $\hat\mu_a+\sqrt{\frac{4\sigma^2}{T_a}\log^+\frac{n}{kT_a}}$ [LS, Algorithm 7] and prove [LS, Theorem 9.1]: $\mathbb E[R_n]\le 39\sqrt{\sigma^2kn}+\sum_a\Delta_a$. @@ -257,18 +308,82 @@ Generalization: arbitrary finite arm types and variance proxies, where [LS] has 1-subgaussian rewards. Completion examples: for two Gaussian arms with gap $\Delta$, the bounds of items 2 and 3 are finite and the asymptotic constant is $2\sigma^2/\Delta$. -## Layer 3: KL-UCB for rewards in [0,1] - -1. **Algorithm.** Define KL-UCB [LS, Algorithm 8]: the index policy with index - $U(\hat\mu_a,\log f(t)/T_a)$ for the level $U$ of Layer 0.2 and $f(t)=1+t\log^2t$. -2. **Regret.** For rewards in $[0,1]$ almost surely, prove [LS, Theorem 10.6]: +## Layer 3: KL-UCB for exponential families + +Throughout, a *family* is an exponential family of the Identification roadmap's Layer 1.2 with the +identity statistic, since rewards are real (a family $(\rho,T)$ enters through the natural family +of `ρ.map T`, which has the same means and divergence): a probability measure $\rho$ on +$\mathbb R$, its members $\rho_\theta=$ `ρ.expFamily id θ` for $\theta$ in the interior +$\Theta_\rho$ of `integrableExpSet id ρ`, its open interval of means $M_\rho=$ +`ρ.expFamilyMeans id`, the member $\rho_{(q)}$ of mean $q\in M_\rho$ (natural parameter +$\eta_\rho(q)=$ `ρ.natParam id q`), the divergence $d_\rho(x,q)=$ `ρ.expFamilyDiv id x q` on +$M_\rho\times M_\rho$, and its extension $\bar d_\rho(x,q)\in[0,\infty]$ to every level +$x\in\mathbb R$, the Cramér–Chernoff rate function of $\rho_{(q)}$ at $x$. Each arm $a$ has its +own family $\rho_a$. Arm $a$ is *dominated by its family* if its mean $\mu_a$ lies in +$M_{\rho_a}$ and its law $\nu_a$ is MGF-dominated above and below by $\rho_{a,(\mu_a)}$ +(LMLExplore's `MGFDominatedAbove`, `MGFDominatedBelow`). Laws on $[0,1]$ with mean in $(0,1)$ are +dominated by the Bernoulli family (`mgfDominatedAbove_bernoulliMeasure`, +`mgfDominatedBelow_bernoulliMeasure`), σ²-sub-Gaussian laws by the Gaussian family of variance +$\sigma^2$ (Identification roadmap, Layer 4.2), and the members of a family by the family itself. + +1. **Upper confidence levels.** For a family $\rho$, $x\in\mathbb R$ and $c\in[0,\infty]$, define + $U_\rho(x,c)=\sup\big(\{x\}\cup\{q\in M_\rho:x\le q,\ \bar d_\rho(x,q)\le c\}\big)$ in `EReal`. + Prove that it is measurable in $(x,c)$, monotone in both arguments and at least $x$, and that + $q\le U_\rho(x,c)$ iff $\bar d_\rho(x,q)\le c$ for $x\le q\in M_\rho$, since + $q\mapsto \bar d_\rho(x,q)$ is continuous and increasing on $M_\rho\cap[x,\infty)$. Prove the + three-point identity + $\bar d_\rho(x,\mu)=\bar d_\rho(x,q)+d_\rho(q,\mu)+(q-x)(\eta_\rho(\mu)-\eta_\rho(q))$ for + $x\in\mathbb R$ and $q,\mu\in M_\rho$, whose last term is nonnegative for $x\le q\le\mu$ (for + Bernoulli laws this gives the inequality $d(p,q-\varepsilon)\le d(p,q)-d(q-\varepsilon,q)$ of + Layer 0.2). Instances: for the Bernoulli family, $\bar d_\rho(x,q)=$ `klBer x q` for + $x\in[0,1]$ (Layer 1.4) and $U_\rho(x,c)$ is the level $U(x,c)$ of Layer 0.2 for $x\in[0,1]$; for the Gaussian family of + variance $\sigma^2\ne0$, $\bar d_\rho(x,q)=(x-q)^2/(2\sigma^2)$ and + $U_\rho(x,c)=x+\sqrt{2\sigma^2c}$ for finite $c$. +2. **Concentration lemmas.** Let $X_1,X_2,\dots$ be independent and dominated by the member + $\rho_{(\mu)}$ of a family, with empirical mean $\hat\mu_s$ after $s$ samples. Prove the + generalization of [LS, Lemma 10.8]: for $\varepsilon>0$ and $\mu+\varepsilon0$ with $\mu-\varepsilon\in M_\rho$ and + $s\ge1$, $P\big(U_\rho(\hat\mu_s,L/s)\le\mu-\varepsilon\big)\le e^{-L}e^{-s\,d_\rho(\mu-\varepsilon,\mu)}$, + by the three-point identity and the Chernoff bound of Layer 1.4; and in a run of any algorithm + against `stationaryEnv ν`, with the exploration level $\log f(t+1)$ at Lean round $t$, the + expected number of rounds at which an arm with law $\nu_a$ dominated by $\rho_{(\mu)}$ has been + pulled and has index $U_\rho(\hat\mu_a,\log f(t+1)/T_a)\le\mu-\varepsilon$ is at most + $3/(2\,d_\rho(\mu-\varepsilon,\mu))$. For rewards in $[0,1]$ with mean in $(0,1)$, Pinsker's + inequality $d(p,q)\ge2(p-q)^2$ (Layer 0.2) turns these into [LS, Lemmas 10.7 and 10.8], with the + constants $3/(4\varepsilon^2)$ and $1/(2\varepsilon^2)$. +3. **Algorithm.** Define KL-UCB for families $(\rho_a)_a$ [LS, Algorithm 8; GC11, Section 4]: the + index policy with index $U_{\rho_a}(\hat\mu_a,\log f(t)/T_a)$, $f(t)=1+t\log^2t$, and $+\infty$ + for unpulled arms. Define `klucb`, KL-UCB for rewards in $[0,1]$, as the instance with the + Bernoulli family on every arm, and prove that its index is the index + $U(\hat\mu_a,\log f(t)/T_a)$ of [LS, Algorithm 8] (with $U$ of Layer 0.2) at empirical means in + $[0,1]$. Prove that `ucbF σ2` (Layer 2.2) is the instance with the Gaussian family of variance + $\sigma^2$ on every arm. +4. **Regret.** Let every arm be dominated by its family, let $a^*$ be an optimal arm and $a$ an + arm with $\Delta_a>0$. For $\varepsilon_1,\varepsilon_2>0$ with + $\varepsilon_1+\varepsilon_2<\Delta_a$, $\mu_a+\varepsilon_1,\mu^*-\varepsilon_2\in M_{\rho_a}$ + and $\mu^*-\varepsilon_2\in M_{\rho_{a^*}}$, prove + $$\mathbb E[T_a(n)]\le1+\frac{\log f(n)}{d_{\rho_a}(\mu_a+\varepsilon_1,\mu^*-\varepsilon_2)}+\frac1{d_{\rho_a}(\mu_a+\varepsilon_1,\mu_a)}+\frac3{2\,d_{\rho_{a^*}}(\mu^*-\varepsilon_2,\mu^*)},$$ + the resulting bound on $\mathbb E[R_n]$, and, when $\mu^*\in M_{\rho_a}$ for every arm $a$ with + $\Delta_a>0$, the eventual form + $\limsup_n\mathbb E[R_n]/\log n\le\sum_{a:\Delta_a>0}\Delta_a/d_{\rho_a}(\mu_a,\mu^*)$ + [GC11; CGMMS13]. Deduce, as the Bernoulli instance, [LS, Theorem 10.6] for rewards in $[0,1]$ + almost surely: $$\mathbb E[R_n]\le\sum_{a:\Delta_a>0}\inf_{\substack{\varepsilon_1,\varepsilon_2>0\\\varepsilon_1+\varepsilon_2<\Delta_a}}\Delta_a\Big(\frac{\log f(n)}{d(\mu_a+\varepsilon_1,\mu^*-\varepsilon_2)}+\frac1{2\varepsilon_1^2}+\frac2{\varepsilon_2^2}\Big),$$ - and, in eventual form, $\limsup_n\mathbb E[R_n]/\log n\le\sum_{a:\Delta_a>0}\Delta_a/d(\mu_a,\mu^*)$ - (the book leaves this limit to its Exercise 10.2; its proof writes $f(n)$ for $\log f(n)$ in the - last line). - -Generalization: rewards with any law on $[0,1]$, where [LS] states Bernoulli rewards. Completion -examples: arms with means $0$ or $1$ (the singular values of $d$), and a two-armed Bernoulli bandit. + and $\limsup_n\mathbb E[R_n]/\log n\le\sum_{a:\Delta_a>0}\Delta_a/d(\mu_a,\mu^*)$, arms with + mean $0$ or $1$ (Dirac laws, outside the open Bernoulli family) being treated directly (the book + leaves this limit to its Exercise 10.2; its proof writes $f(n)$ for $\log f(n)$ in the last + line). Deduce, as the Gaussian instance, the eventual form of Layer 2.2 for σ²-sub-Gaussian + rewards. + +Generalization: one exponential family per arm and reward laws dominated by their family members, +where [LS] states Bernoulli rewards and [GC11, CGMMS13] one family whose members are the reward +laws. Completion examples: arms with means $0$ or $1$ in the $[0,1]$ instance; a two-armed Bernoulli +bandit; the boundary empirical means of the Bernoulli family, $U(0,c)=1-e^{-c}$ and $U(1,c)=1$; +exponential rewards (`expMeasure`, $d(x,q)=x/q-1-\log(x/q)$); Gaussian arms with different known +variances. ## Layer 4: Lower bounds for finitely many arms @@ -291,42 +406,69 @@ examples: arms with means $0$ or $1$ (the singular values of $d$), and a two-arm $d_{\inf}(P,\mu^*,\mathcal M)=\inf\{D(P,P'):P'\in\mathcal M,\ \mu(P')>\mu^*\}$ in `ℝ≥0∞`. Prove [LS, Theorem 16.2] for the unstructured class $\prod_a\mathcal M_a$: $\liminf_n\mathbb E[R_n]/\log n\ge\sum_{a:\Delta_a>0}\Delta_a/d_{\inf}(\nu_a,\mu^*,\mathcal M_a)$, - with the sum in `ℝ≥0∞`. Compute $d_{\inf}$ for Gaussian laws with known variance and for - Bernoulli laws [LS, Table 16.1]. Prove [LS, Lemma 16.3] and the finite-time bound + with the sum in `ℝ≥0∞`. Compute $d_{\inf}$ for exponential families [BK96]: for a family + $\rho$ of Layer 3 with members $\mathcal M_\rho=\{\rho_\theta:\theta\in\Theta_\rho\}$, + $\mu\in M_\rho$ and $m\ge\mu$, $d_{\inf}(\rho_{(\mu)},m,\mathcal M_\rho)=d_\rho(\mu,m)$ if + $m\in M_\rho$ and $\infty$ if $m\ge\sup M_\rho$. The Gaussian (known variance) and Bernoulli + entries of [LS, Table 16.1] are instances. Prove [LS, Lemma 16.3] and the finite-time bound [LS, Theorem 16.4], for Gaussian bandits with variance $\sigma^2$. -5. **Asymptotic optimality and the adversarial lower bound.** Prove that the algorithms of Layers 2.2 - and 3 are consistent and attain the Lai–Robbins constant (Gaussian arms and Bernoulli arms - respectively): their expected regret is $c^*\log n+o(\log n)$. Prove the adversarial minimax lower - bound: for every algorithm and $n\ge 3(k-1)/8$ there is a table $x\in\{0,1\}^{n\times\alpha}$ with +5. **Asymptotic optimality and the adversarial lower bound.** For families $(\rho_a)_a$ with a + common set of means $M$ (one family for all arms, or Gaussian families with different + variances), prove that KL-UCB (Layer 3) is consistent over the bandits whose arm $a$ has a law in + $\mathcal M_{\rho_a}$ and attains the Lai–Robbins constant there: its expected regret is + $c^*\log n+o(\log n)$ with $c^*=\sum_{a:\Delta_a>0}\Delta_a/d_{\rho_a}(\mu_a,\mu^*)$. The + algorithms of Layers 2.2 and 3 on Gaussian arms and on Bernoulli arms are instances, Bernoulli + arms with mean $0$ or $1$ being treated directly. Prove the adversarial minimax lower bound: for + every algorithm and $n\ge 3(k-1)/8$ there is a table $x\in\{0,1\}^{n\times\alpha}$ with $R_n(x)\ge\frac1{27}\sqrt{3(k-1)n/32}$, by averaging the Bernoulli case of item 3 over i.i.d. tables (Layer 0.5). -Generalization: the minimax bound for a family of laws rather than unit-variance Gaussians. +Generalization: the minimax bound for a family of laws rather than unit-variance Gaussians; +$d_{\inf}$ and asymptotic optimality for every exponential family rather than Gaussian and +Bernoulli arms. Completion checks: the divergence decomposition is zero for identical environments; the Lai–Robbins constant is $+\infty$ when some $d_{\inf}$ vanishes, and the theorem then states that the regret of every consistent policy eventually exceeds every multiple of $\log n$. ## Layer 5: Thompson sampling -1. **Algorithm.** Define Gaussian Thompson sampling with variance proxy $\sigma^2$ and flat prior: - at each round, sample independently $\theta_a\sim\mathcal N(\hat\mu_a,\sigma^2/T_a)$ (and - $\theta_a=+\infty$ for unpulled arms) and play `argmax θ`. The book's update writes the variance - $1/t$; the intended variance after $s$ samples of the arm is $1/s$ [LS, Theorem 36.3]. +1. **Algorithm.** For families $(\rho_a)_a$ of Layer 3 with log-partition functions + $\psi_a=$ `cgf id (ρ a)` and priors $\pi_a$, σ-finite measures on $\Theta_{\rho_a}$, define + Thompson sampling. At each round, for each arm $a$ pulled $s\ge1$ times with reward sum $S$, + draw independently a natural parameter $\theta_a$ from the posterior, the probability measure + proportional to $e^{\theta S-s\psi_a(\theta)}\,\pi_a(d\theta)$, and take its mean + $\psi_a'(\theta_a)$ as the perturbation of $a$ (the perturbation is $+\infty$ where the + normalizing constant is $0$ or infinite, and for unpulled arms); play `argmax`. This is a + follow-the-perturbed-leader policy whose laws depend on the history only through the number of + pulls and the reward sum of each arm (LMLExplore's `perturbedLeaderAlgorithm`). The Jeffreys + prior is $\pi_J(d\theta)=\sqrt{\psi''(\theta)}\,d\theta$ on $\Theta_\rho$ [KKM13, Section 2]. + Gaussian Thompson sampling with variance proxy $\sigma^2$ and flat prior (LMLExplore's + `gaussianTS`: $\theta_a\sim\mathcal N(\hat\mu_a,\sigma^2/T_a)$) is the instance with the + Gaussian family of variance $\sigma^2$ and its Jeffreys prior, a constant multiple of Lebesgue + measure; define it as that instance. The book's update writes the variance $1/t$; the intended + variance after $s$ samples of the arm is $1/s$ [LS, Theorem 36.3]. 2. **Generic bound.** Prove [LS, Theorem 36.2] for the follow-the-perturbed-leader scheme of [LS, Algorithm 24]: with arm $a^*$ optimal, $a\ne a^*$, $\varepsilon\in\mathbb R$ and $G_{as}=1-F_{as}(\mu^*-\varepsilon)$, $\mathbb E[T_a(n)]\le1+\mathbb E\big[\sum_{s1/n\}\big]$. -3. **Frequentist regret.** For Gaussian bandits with variance $\sigma^2$, prove - [LS, Theorem 36.3]: $\mathbb E[R_n]/\log n\to\sum_{a:\Delta_a>0}2\sigma^2/\Delta_a$ (upper bound - in eventual form, matched by Layer 4.4), and +3. **Frequentist regret.** Let one family $\rho$ serve all arms, with Jeffreys posteriors that are + finite measures after every number $s\ge1$ of pulls, for almost every sum of $s$ independent + draws from $\rho$. For bandits whose arm laws are members of $\rho$, prove that Thompson sampling + with the Jeffreys prior satisfies + $\mathbb E[R_n]/\log n\to\sum_{a:\Delta_a>0}\Delta_a/d_\rho(\mu_a,\mu^*)$ [KKM13, Theorem 1] + (upper bound in eventual form, matched by Layer 4.4). For Gaussian bandits with variance + $\sigma^2$ this is the asymptotic part of [LS, Theorem 36.3]; prove its minimax part $\mathbb E[R_n]\le C\sqrt{\sigma^2kn\log n}+\sum_a\Delta_a$ for an absolute constant $C$, through the steps of [LS, Exercise 36.6] and the Gaussian tails of Layer 1.6. -Generalization: arbitrary variance proxy and finite arm type. LML's Bayesian Thompson sampling +Generalization: exponential families and priors on the natural parameter, arbitrary variance proxy +and finite arm type, where [LS] treats Gaussian arms. LML's Bayesian Thompson sampling (`tsAlgorithm`, `TS.integral_regret_le`) is a different algorithm (it samples from the posterior of -a prior over environments); do not restate its results. +a prior over environments); do not restate its results. Completion example: for Bernoulli arms the +Jeffreys prior on the mean is $\mathrm{Beta}(1/2,1/2)$, with posterior +$\mathrm{Beta}(1/2+S,1/2+s-S)$ [KKM13, Figure 1]. -## Layer 6: Convex analysis and online linear optimization +## Layer 6: Convex analysis, online linear and convex optimization Work in a finite-dimensional real normed space `E`, paired with its dual `E →L[ℝ] ℝ` by `(x, y) ↦ y x`; this is the bilinear pairing that Tau Ceti's `fenchelConjugate` takes. Losses and @@ -335,7 +477,8 @@ against `u` after `n` rounds is $\sum_{t0$ this is the + anytime form of [LS, Theorem 28.5]; for $F$ $m$-strongly convex deduce + $\sum_{t0$, $R_n(x)\le\frac{\log k}{\eta}+\frac{\eta nk}{2}$, and - [LS, Theorem 11.2]: with $\eta=\sqrt{2\log(k)/(nk)}$, $R_n(x)\le\sqrt{2nk\log k}$. -3. **Exp3-IX.** Define Exp3-IX [LS, Algorithm 10] and prove [LS, Lemmas 12.2–12.4] and both - high-probability bounds of [LS, Theorem 12.1] for the random regret - $\hat R_n=\max_a\sum_{t0$ and implicit-exploration parameters +$\gamma_t\ge0$ are nonincreasing sequences (Conventions). + +1. **Importance-weighted estimators.** For a weight-based policy (Layer 0.3) with weights $P_t$, + define the standard and loss-based estimators [LS, (11.3), (11.6)] and the implicit-exploration + estimator $\hat Y_t(a)=\mathbb 1\{A_t=a\}(1-Y_t)/(P_t(a)+\gamma_t)$ [LS, (12.4); Neu15, (3)]. + Conditionally on the history before round $t$ and the observation of round $t$ (LML's + `IsAlgEnvSeq.filtrationObs`), prove unbiasedness for $\gamma_t=0$ and positive weights, + $\mathbb E[\hat Y_t(a)\mid\cdot]=1-m_t(a)$, the bias bound + $\mathbb E[\hat Y_t(a)\mid\cdot]\le1-m_t(a)$ for $\gamma_t\ge0$, and the conditional variance + formulas [LS, (11.4), (11.5)]. +2. **Exp4-IX.** For a finite set of $M$ experts and a measurable advice map from observations to + advice $E_t\in\Delta(\alpha)^M$, define Exp4-IX [Neu15, Section 3.2] with learning rates $\eta_t$ + and implicit exploration $\gamma_t$: expert weights + $Q_t=\mathrm{softmax}\big(-\eta_t\sum_{s0$, the rank-one update of the inverse (Sherman–Morrison) and of the determinant +`E →L[ℝ] E`; give matrix corollaries on `EuclideanSpace ℝ ι`. Weighted norms use the inverse +$V^{-1}$ (`Ring.inverse`) of operators that are invertible ($\lambda>0$, positive definite $V_0$) +and the Moore–Penrose inverse $V^+$ (Tau Ceti's `LinearMap.moorePenroseInverse`) of operators that +may be singular (unregularized least squares, designs). + +1. **Design operators.** For a positive operator $V_0$ and $x_0,x_1,\ldots\in E$, define + $V_t(V_0)=V_0+\sum_{s0$), the rank-one update of the inverse + (Sherman–Morrison) and of the determinant $\det V_{t+1}=\det V_t\,(1+\|x_t\|^2_{V_t^{-1}})$ [LS, (19.9)], and $\det V\le(\operatorname{trace}V/d)^d$ for positive $V$. 2. **Elliptical potential.** Prove [LS, Lemma 19.4]: for positive definite $V_0$ and $\|x_t\|\le L$, $\sum_{t0$ it is the ridge estimator $V_t(\lambda)^{-1}\sum_{s0$ for +every nonzero $x$ in it. ## Layer 9: Stochastic linear bandits @@ -448,7 +691,8 @@ sphere the uniform distribution on an orthonormal basis is G-optimal. 3. **Phased elimination.** For a finite action set $\mathcal A\subseteq E$ and gaps at most $1$, define phased elimination with G-optimal designs [LS, Algorithm 12] and prove [LS, Theorem 22.1] via [LS, Exercise 22.1], with an explicit constant. Do not assume that the surviving sets span - $E$: use the non-spanning design of Layer 8.6 on their span. + $E$: use the non-spanning design of Layer 8.6 on their span, and the least-squares estimator of + Layer 8.3 with $\lambda=0$ and its fixed-design bound (Layer 8.5). 4. **Lower bounds.** With Gaussian noise, prove [LS, Theorem 24.1] (hypercube $[-1,1]^d$: some $\theta\in\{\pm n^{-1/2}\}^d$ gives $R_n\ge\frac{e^{-2}}8d\sqrt n$) and [LS, Theorem 24.2] (unit ball, $d\le2n$: some $\theta$ with $\|\theta\|^2=d^2/(48n)$ gives @@ -461,15 +705,19 @@ OFUL bound applies to them. ## Layer 10: Adversarial linear bandits -Losses $y_t\in E$ are chosen obliviously; the learner observes $\langle A_t,y_t\rangle$. - -1. **Exp3 with exploration.** For a finite spanning action set with - $\sup_a|\langle a,y_t\rangle|\le1$, define [LS, Algorithm 15] and prove [LS, Theorem 27.1]: - $R_n\le2\sqrt{(2g(\pi)+d)\,n\log k}$ for every exploration design $\pi$, hence - $R_n\le2\sqrt{3dn\log k}$ with the Kiefer–Wolfowitz design of Layer 8.6. -2. **Mirror descent with bandit feedback.** Prove [LS, Theorem 28.10] for the scheme of - [LS, Algorithm 16] with unbiased estimates, and [LS, Theorem 28.11] for the unit ball: - with $\|y_t\|\le1$, $r=1-2\eta d$ and $\eta=\sqrt{\log(n)/(3dn)}$, $R_n\le2\sqrt{3nd\log n}$. +Losses $y_t\in E$ are chosen by an adaptive adversary: $y_t$ is a measurable function of the +history before round $t$ and of the observation of round $t$, and the learner observes +$\langle A_t,y_t\rangle$; oblivious losses are the deterministic case. The regret is the +pseudo-regret $R_n=\max_{u\in\mathcal A}\mathbb E\big[\sum_{t 0` [LS, Definition 16.1]. -/ def IsConsistentGaussian (alg : Algorithm Unit α ℝ) (σ2 : ℝ≥0) : Prop := @@ -233,6 +347,20 @@ theorem lai_robbins_gaussian {alg : Algorithm Unit α ℝ} {σ2 : ℝ≥0} ∂(trajMeasure alg (stationaryEnv (gaussianBandit μ σ2))) := sorry +/-! ## Layer 5: Thompson sampling -/ + +/-- The Jeffreys prior `√ψ''(θ) dθ` of the natural exponential family of `ρ`, on the interior of +its natural-parameter set [KKM13, Section 2]. -/ +def jeffreysPrior (ρ : Measure ℝ) : Measure ℝ := + (volume.restrict (interior (integrableExpSet id ρ))).withDensity + fun θ ↦ ENNReal.ofReal √(iteratedDeriv 2 (cgf id ρ) θ) + +/-- Thompson sampling for the natural exponential families `ρ a` with priors `prior a` on the +natural parameters (README Layer 5.1): a follow-the-perturbed-leader policy that samples the mean +of a natural parameter drawn from the posterior of each pulled arm, `+∞` for unpulled arms. -/ +def expFamilyTS (ρ prior : α → Measure ℝ) : Algorithm Unit α ℝ := + sorry + /-! ## Layer 6: online linear optimization -/ section OnlineLinear @@ -252,21 +380,47 @@ theorem ftrl_regret_le {F : E → ℝ} {K : Set E} (hK : Convex ℝ K) {η : ℝ (∑ t ∈ range n, bregDiv F (a (t + 1)) (a t) (F' t)) / η := sorry +/-- The regret bound of follow-the-regularized-leader with regularizers `ψ t` nondecreasing in `t` +on `K` (README Layer 6.3); each play `a t ∈ K` minimizes `b ↦ ∑_{s