From e8ef62e3895c0d0dc95e26c28ed2c21960361088 Mon Sep 17 00:00:00 2001 From: Remy Degenne Date: Fri, 20 Nov 2026 12:50:42 +0100 Subject: [PATCH] Bump LMLExplore to 05afda8, which brings Statlib and Lean v4.36.0-rc2 Moves the LMLExplore pin from a316f5d to 05afda8, with the dependencies at its versions: LML e0a6fb9, Statlib 60dd66a (new: it comes through LML), Tau Ceti 4d91513, Mathlib 2ddf59c, Lean v4.36.0-rc2. Repairs the roadmap files for LML's renames of the sequential-learning framework, in the Lean prototypes and in the README citations, and repoints the source links to the new pins. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0196ftMVbgjSJzPQEwdek3kM --- Completed/Refactors/README.md | 2 +- Completed/Refactors/Suggested.lean | 2 +- LMLRoadmaps/Bandits/README.md | 146 ++++++++++---------- LMLRoadmaps/Bandits/Suggested.lean | 38 ++--- LMLRoadmaps/Generalization/README.md | 4 +- LMLRoadmaps/Generalization/Suggested.lean | 11 +- LMLRoadmaps/Identification/README.md | 24 ++-- LMLRoadmaps/Identification/Suggested.lean | 29 ++-- LMLRoadmaps/ReinforcementLearning/README.md | 34 ++--- lake-manifest.json | 76 +++++----- lean-toolchain | 2 +- 11 files changed, 186 insertions(+), 182 deletions(-) diff --git a/Completed/Refactors/README.md b/Completed/Refactors/README.md index 33c9431..f15cba4 100644 --- a/Completed/Refactors/README.md +++ b/Completed/Refactors/README.md @@ -127,7 +127,7 @@ generality and moves it where its users are. It adds no target of those roadmaps 4. **The transfer from runs to the reward stream, shared and joint over the arms.** - Move `LMLExplore/Bandits/SumRewards.lean` to `LMLExplore/SequentialLearning/SumRewards.lean`, in namespace `LMLExplore`, with unchanged statements: it holds for every algorithm against - `stationaryEnv ν`, including the sampling rules of identification algorithms. + `Environment.bandit ν`, including the sampling rules of identification algorithms. - For finitely many arms and a measurable predicate `p` on `(α → ℕ) × (α → ℝ)`, prove the joint event transfer `P {ω | ∃ t, p (fun a ↦ pullCount A a t ω) (fun a ↦ sumRewards A R a t ω)} ≤ diff --git a/Completed/Refactors/Suggested.lean b/Completed/Refactors/Suggested.lean index 6e491c9..46520ee 100644 --- a/Completed/Refactors/Suggested.lean +++ b/Completed/Refactors/Suggested.lean @@ -116,7 +116,7 @@ variable {α Ω : Type*} [Fintype α] [DecidableEq α] {mα : MeasurableSpace α all arms holds at some round is at most the probability that it holds, for the i.i.d. rewards of the stream model, at some vector of counts. -/ theorem measure_exists_pullCount_sumRewards_le_joint - (h : IsAlgEnvSeq O A R alg (stationaryEnv ν) P) {p : (α → ℕ) → (α → ℝ) → Prop} + (h : IsAlgEnvSeq O A R alg (Environment.bandit ν) P) {p : (α → ℕ) → (α → ℝ) → Prop} (hp : Measurable fun q : (α → ℕ) × (α → ℝ) ↦ p q.1 q.2) : P {ω | ∃ t, p (fun a ↦ pullCount A a t ω) (fun a ↦ sumRewards A R a t ω)} ≤ streamMeasure ν {ω | ∃ s : α → ℕ, p s (fun a ↦ ∑ i ∈ range (s a), ω i a)} := diff --git a/LMLRoadmaps/Bandits/README.md b/LMLRoadmaps/Bandits/README.md index 596739a..256a5f9 100644 --- a/LMLRoadmaps/Bandits/README.md +++ b/LMLRoadmaps/Bandits/README.md @@ -37,7 +37,7 @@ 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` | +| Interaction protocol, runs, trajectory measure, stochastic and oblivious environments | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `Environment.bandit`, `Environment.banditSeq`, `Environment.evalSeq`, `Algorithm.deterministic` | | 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`) | @@ -91,8 +91,8 @@ as [LS, Chapters 26–28] and convex analysis do. Where the analysis of a reward 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 -is LML's `stationaryEnv ν`. The mean of arm $a$ is `(ν a)[id]`. Noise assumptions are stated per -arm, as in LML: σ²-sub-Gaussian rewards are +is LML's `Environment.bandit ν`. The mean of arm $a$ is `(ν a)[id]`. Noise assumptions are stated +per arm, as in LML: σ²-sub-Gaussian rewards are `∀ a, HasSubgaussianMGF (fun x ↦ x - (ν a)[id]) σ2 (ν a)` with `σ2 : ℝ≥0` the variance proxy, and bounded rewards are `∀ a, ∀ᵐ x ∂(ν a), x ∈ Set.Icc 0 1`. Where [LS] assumes 1-subgaussian rewards, state the result for σ²-sub-Gaussian rewards; the constants below include $\sigma^2$. @@ -104,11 +104,11 @@ reward law of round $t$ may depend on the history and on the observation of roun table* $m_t(a)$ is LML's `env.means O A Y a t`, the mean reward of arm $a$ at round $t$ given the past. The *pseudo-regret* is $\bar R_n=\max_a\mathbb E\big[\sum_{t0$ and $\gamma_t\ge0$ used at Lean @@ -133,25 +133,25 @@ 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 -on (dot notation). LML's definitions keep their names (`Learning.stationaryEnv`, `Bandits.regret`, -…). +on (dot notation). LML's definitions keep their names (`Learning.Environment.bandit`, +`Bandits.regret`, …). ## Existing library and design guidance Consume these modules and extend their APIs rather than restating them. The links pin the -dependency versions used to check the interfaces (LML `53be244`, Mathlib `2e318fae`, Tau Ceti -`v4.36.0-rc1`). +dependency versions used to check the interfaces (LML `e0a6fb9`, Mathlib `2ddf59c8`, Tau Ceti +`4d91513`). | Foundation | Existing source | | --- | --- | | 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) | -| Stochastic regret and existing regret bounds | [LML `Regret.lean`][lml-regret] (`regret`, `gap`, `integral_regret_le_of_forall_integral_pullCount_le`), [`Regret/UCB.lean`][lml-ucb] (`UCB.expectation_pullCount_le`, `UCB.regret_le_of_gt_two'`), [`Regret/ETC.lean`][lml-etc], [`Regret/BayesRegretTS.lean`][lml-ts] | -| KL divergence of histories | [LML `DivergenceDecomposition.lean`][lml-div] (`IsAlgEnvSeq.klDiv_map_history`: the time-sum $\sum_{t2\sigma^2$: $\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$, @@ -352,7 +346,7 @@ $\sigma^2$ (Identification roadmap, Layer 4.2), and the members of a family by t generalization of [LS, Lemma 10.7]: for $\varepsilon>0$ 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 + against `Environment.bandit ν`, 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 @@ -395,7 +389,7 @@ variances. on a finite arm type, prove [LS, Lemma 15.1] in `ℝ≥0∞`: $D(P_{\nu}^{(n)},P_{\nu'}^{(n)})=\sum_a\mathbb E_\nu[T_a(n)]\,D(\nu_a,\nu'_a)$, where $P^{(n)}$ is the law of the history of length $n$, by regrouping LML's - `IsAlgEnvSeq.klDiv_map_history` along the pulled arm. + `IsAlgEnvSeq.klDiv_map_history_bandit` along the pulled arm. 2. **Bretagnolle–Huber.** For probability measures $P,Q$ and every measurable $A$: $P(A)+Q(A^c)\ge\tfrac12\exp(-D(P,Q))$ [LS, Theorem 14.2], through the stronger $\int\min(p,q)\ge\tfrac12\exp(-D(P,Q))$ for densities with respect to $P+Q$ [LS, (14.8)]. @@ -557,11 +551,11 @@ pairing, a fixed learning rate and linear losses; the instances are corollaries. ## Layer 7: Adversarial bandits with finitely many arms and expert advice Runs against an environment `env : Environment 𝓞 α ℝ` whose feedback laws are supported in -$[0,1]$: an adaptive adversary (Conventions), which includes oblivious tables `onlineEvalEnv x _` -with $x_t(a)\in[0,1]$ and stochastic bandits `stationaryEnv ν` with rewards in $[0,1]$. -Expectation bounds are on the pseudo-regret $\bar R_n$, high-probability bounds on the random -regret $\hat R_n$ (Layer 0.5). Learning rates $\eta_t>0$ and implicit-exploration parameters -$\gamma_t\ge0$ are nonincreasing sequences (Conventions). +$[0,1]$: an adaptive adversary (Conventions), which includes oblivious tables +`Environment.evalSeq x _` with $x_t(a)\in[0,1]$ and stochastic bandits `Environment.bandit ν` with +rewards in $[0,1]$. Expectation bounds are on the pseudo-regret $\bar R_n$, high-probability bounds +on the random regret $\hat R_n$ (Layer 0.5). Learning rates $\eta_t>0$ 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 @@ -615,7 +609,7 @@ $\gamma_t\ge0$ are nonincreasing sequences (Conventions). - Self-bounding regime: if an arm $a^\star$ and gaps $\Delta_a$ satisfy $\bar R_n\ge\sum_{t0}(1+\log n)/\Delta_a$. Against `stationaryEnv ν` with + $\bar R_n\le256\sum_{a:\Delta_a>0}(1+\log n)/\Delta_a$. Against `Environment.bandit ν` with rewards in $[0,1]$ and a unique optimal arm the constraint holds with equality, so this bounds the expected stochastic regret. - The mirror-descent form with the $\frac12$-Tsallis potential and a constant rate $\eta$ @@ -627,8 +621,8 @@ known horizon and three algorithms; and, for Tsallis-INF, adaptive adversaries a regime, where [Ora] fixes an oblivious table and independent losses. Completion checks: for $k=1$ every bound is $0$; the lower bound of Layer 4.5 shows the order $\sqrt{nk}$ of item 3 is attained up to $\sqrt{\log k}$; with a single expert the expert pseudo-regret of Exp4 is nonpositive; against -`stationaryEnv ν` with rewards in $[0,1]$, item 3 bounds the expected stochastic regret of Exp3 with -anytime rates by $2\sqrt{nk\log k}$. +`Environment.bandit ν` with rewards in $[0,1]$, item 3 bounds the expected stochastic regret of Exp3 +with anytime rates by $2\sqrt{nk\log k}$. ## Layer 8: Least squares, self-normalized bounds and optimal design @@ -805,31 +799,31 @@ T. L. Lai and H. Robbins, *Asymptotically efficient adaptive allocation rules* ( [ls]: https://tor-lattimore.com/downloads/book/book.pdf [kw]: https://github.com/RemyDegenne/colt-2026-83/blob/3f6c0f296a3b7e4aa8fe333225505f5b2f61f9e0/Maiti2026Power/MXJ2026/OptimalDesign.lean -[lml-alg]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/Algorithm.lean -[lml-it]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/IonescuTulceaSpace.lean -[lml-env]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/StationaryEnv.lean -[lml-eval]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/EvaluationEnv.lean -[lml-det]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/Deterministic.lean -[lml-argmax]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableArg.lean -[lml-fa]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/FiniteActions.lean -[lml-sum]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/SumRewards.lean -[lml-conc]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/Online/Bandit/SumRewards.lean -[lml-regret]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/Online/Bandit/Regret.lean -[lml-ucb]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/Online/Bandit/Algorithms/Regret/UCB.lean -[lml-etc]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/Online/Bandit/Algorithms/Regret/ETC.lean -[lml-ts]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/Online/Bandit/Algorithms/Regret/BayesRegretTS.lean -[lml-div]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/DivergenceDecomposition.lean -[lml-means]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/SequentialLearning/Means.lean -[lml-chain]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/ForMathlib/InformationTheory/KullbackLeibler/ChainRule.lean -[lml-breg]: https://github.com/LeanMachineLearning/LML/blob/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/ForMathlib/Analysis/Convex/Bregman/Basic.lean -[lml-subgrad]: https://github.com/LeanMachineLearning/LML/tree/53be244591a865c51ea10fa09403189ee060f116/LeanMachineLearning/ForMathlib/Analysis/Convex/Subgradient -[ml-subg]: https://github.com/leanprover-community/mathlib4/blob/2e318faecff7d70d4e0cf8cc875104424a737355/Mathlib/Probability/Moments/SubGaussian.lean -[ml-os]: https://github.com/leanprover-community/mathlib4/blob/2e318faecff7d70d4e0cf8cc875104424a737355/Mathlib/Probability/Martingale/OptionalStopping.lean -[tc-pinsker]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/InformationTheory/KullbackLeibler/Pinsker.lean -[tc-dv]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/InformationTheory/KullbackLeibler/Variational.lean -[tc-gauss]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Probability/Distributions/Gaussian/Cdf.lean -[tc-conj]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Analysis/Convex/Conjugate.lean -[tc-strong]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Analysis/Convex/Strong.lean -[tc-frame]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Analysis/InnerProductSpace/Frame.lean -[tc-affine]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Analysis/Convex/AffineNormalization.lean -[tc-mp]: https://github.com/TauCetiProject/TauCeti/blob/cebc9b6046b14d2bd8d1c1088707109cdbac3a77/TauCeti/Analysis/InnerProductSpace/MoorePenrose.lean +[lml-alg]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/Algorithm.lean +[lml-it]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/IonescuTulceaSpace.lean +[lml-env]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/StationaryEnv.lean +[lml-eval]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/EvaluationEnv.lean +[lml-det]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/Deterministic.lean +[lml-argmax]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableArg.lean +[lml-fa]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/FiniteActions.lean +[lml-sum]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/SumRewards.lean +[lml-conc]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/Online/Bandit/Concentration.lean +[lml-regret]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/Online/Bandit/Regret.lean +[lml-ucb]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/Online/Bandit/Algorithms/Regret/UCB.lean +[lml-etc]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/Online/Bandit/Algorithms/Regret/ETC.lean +[lml-ts]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/Online/Bandit/Algorithms/Regret/BayesRegretTS.lean +[lml-div]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/DivergenceDecomposition.lean +[lml-means]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/SequentialLearning/Means.lean +[lml-breg]: https://github.com/LeanMachineLearning/LML/blob/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/ForMathlib/Analysis/Convex/Bregman/Basic.lean +[lml-subgrad]: https://github.com/LeanMachineLearning/LML/tree/e0a6fb927495bfeb8fe7d4247092cab9b61f5e51/LeanMachineLearning/ForMathlib/Analysis/Convex/Subgradient +[ml-subg]: https://github.com/leanprover-community/mathlib4/blob/2ddf59c8f14245864e6c0ed227a2dab76b9efea2/Mathlib/Probability/Moments/SubGaussian.lean +[ml-os]: https://github.com/leanprover-community/mathlib4/blob/2ddf59c8f14245864e6c0ed227a2dab76b9efea2/Mathlib/Probability/Martingale/OptionalStopping.lean +[tc-chain]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/InformationTheory/KullbackLeibler/ChainRule.lean +[tc-pinsker]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/InformationTheory/KullbackLeibler/Pinsker.lean +[tc-dv]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/InformationTheory/KullbackLeibler/Variational.lean +[tc-gauss]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Probability/Distributions/Gaussian/Cdf.lean +[tc-conj]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Analysis/Convex/Conjugate.lean +[tc-strong]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Analysis/Convex/Strong.lean +[tc-frame]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Analysis/InnerProductSpace/Frame.lean +[tc-affine]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Analysis/Convex/AffineNormalization.lean +[tc-mp]: https://github.com/TauCetiProject/TauCeti/blob/4d91513e4d30746eb1fa96658c18e051c772e55e/TauCeti/Analysis/InnerProductSpace/MoorePenrose.lean diff --git a/LMLRoadmaps/Bandits/Suggested.lean b/LMLRoadmaps/Bandits/Suggested.lean index 5aba8d6..d3d9fb6 100644 --- a/LMLRoadmaps/Bandits/Suggested.lean +++ b/LMLRoadmaps/Bandits/Suggested.lean @@ -31,8 +31,8 @@ nor the roadmap. The admitted proofs are targets, not claimed implementations. T admitted definitions: constructing them, with their run lemmas, is a target, and their docstrings and the README specify them. -The names of the LML framework (`stationaryEnv`, `onlineEvalEnv`, `detAlgorithm`, ...) are those -of the LML version pinned by LMLExplore. Exponential families are written here through their +The names of the LML framework (`Environment.bandit`, `Environment.evalSeq`, +`Algorithm.deterministic`, ...) are those of the LML version pinned by LMLExplore. Exponential families are written here through their natural parameters with Mathlib's `Measure.tilted` and `cgf`; the mean parametrization and the rate function are the Identification roadmap's (Layer 1.2). -/ @@ -101,7 +101,7 @@ def weightAlgorithm {𝓞 𝓨 : Type*} [MeasurableSpace 𝓞] [MeasurableSpace def indexAlgorithm {𝓞 𝓨 : Type*} [MeasurableSpace 𝓞] [MeasurableSpace 𝓨] (I : (n : ℕ) → Hist 𝓞 α 𝓨 n × 𝓞 → α → EReal) (hI : ∀ n, Measurable (I n)) : Algorithm 𝓞 α 𝓨 := - detAlgorithm (fun n x ↦ argmax (I n x)) (fun n ↦ sorry) + Algorithm.deterministic (fun n x ↦ argmax (I n x)) (fun n ↦ sorry) /-- The regret against the best fixed arm of a run against the oblivious reward table `x` [LS, (11.1)]. -/ @@ -122,20 +122,20 @@ def randomRegret {𝓞 : Type*} [MeasurableSpace 𝓞] (env : Environment 𝓞 ⨆ a, ∑ t ∈ range n, (env.means O A Y a t ω - Y t ω) /-- Against an oblivious reward table, the pseudo-regret is the adversarial regret `R_n(x)`. -/ -theorem pseudoRegret_onlineEvalEnv (x : ℕ → α → ℝ) {alg : Algorithm Unit α ℝ} +theorem pseudoRegret_evalSeq (x : ℕ → α → ℝ) {alg : Algorithm Unit α ℝ} {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {Y : ℕ → Ω → ℝ} - (h : IsAlgEnvSeq O A Y alg (onlineEvalEnv x fun t ↦ measurable_of_countable (x t)) P) + (h : IsAlgEnvSeq O A Y alg (Environment.evalSeq x fun t ↦ measurable_of_countable (x t)) P) (n : ℕ) : - pseudoRegret (onlineEvalEnv x fun t ↦ measurable_of_countable (x t)) O A Y P n = + pseudoRegret (Environment.evalSeq x fun t ↦ measurable_of_countable (x t)) O A Y P n = advRegret x A P n := sorry /-- Against a stochastic bandit, the pseudo-regret is the expected stochastic regret. -/ -theorem pseudoRegret_stationaryEnv {ν : Kernel α ℝ} [IsMarkovKernel ν] +theorem pseudoRegret_bandit {ν : Kernel α ℝ} [IsMarkovKernel ν] (hν : ∀ a, Integrable id (ν a)) {alg : Algorithm Unit α ℝ} {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {Y : ℕ → Ω → ℝ} - (h : IsAlgEnvSeq O A Y alg (stationaryEnv ν) P) (n : ℕ) : - pseudoRegret (stationaryEnv ν) O A Y P n = P[Bandits.regret ν A n] := + (h : IsAlgEnvSeq O A Y alg (Environment.bandit ν) P) (n : ℕ) : + pseudoRegret (Environment.bandit ν) O A Y P n = P[Bandits.regret ν A n] := sorry /-! ## Layer 1: concentration and maximal inequalities -/ @@ -156,7 +156,7 @@ variable {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {R : ℕ → Ω → /-- Minimax bound for LML's UCB (README Layer 2.1, the analogue of [LS, Theorem 7.2]). -/ theorem ucb_regret_le_sqrt {K : ℕ} [NeZero K] {A : ℕ → Ω → Fin K} {ν : Kernel (Fin K) ℝ} [IsMarkovKernel ν] {c : ℝ} - (h : IsAlgEnvSeq O A R (Bandits.ucbAlgorithm K c) (stationaryEnv ν) P) + (h : IsAlgEnvSeq O A R (Bandits.ucbAlgorithm K c) (Environment.bandit ν) P) (hν : ∀ a, HasSubgaussianMGF (fun x ↦ x - (ν a)[id]) σ2 (ν a)) (hσ2 : σ2 ≠ 0) (hc : 2 * σ2 < c) (n : ℕ) : P[Bandits.regret ν A n] ≤ @@ -177,7 +177,7 @@ def ucbF (σ2 : ℝ≥0) : Algorithm Unit α ℝ := indexAlgorithm (fun n x ↦ ucbFIndex σ2 n x.1) (fun n ↦ sorry) /-- [LS, (8.2)] for σ²-sub-Gaussian rewards, in eventual form. -/ -theorem ucbF_regret_eventually_le (h : IsAlgEnvSeq O A R (ucbF σ2) (stationaryEnv ν) P) +theorem ucbF_regret_eventually_le (h : IsAlgEnvSeq O A R (ucbF σ2) (Environment.bandit ν) P) (hν : ∀ a, HasSubgaussianMGF (fun x ↦ x - (ν a)[id]) σ2 (ν a)) (hσ2 : σ2 ≠ 0) {c : ℝ} (hc : ∑ a ∈ univ.filter (fun a ↦ 0 < Bandits.gap ν a), 2 * σ2 / Bandits.gap ν a < c) : ∀ᶠ n : ℕ in atTop, P[Bandits.regret ν A n] ≤ c * log n := @@ -194,7 +194,7 @@ def moss (σ2 : ℝ≥0) (horizon : ℕ) : Algorithm Unit α ℝ := indexAlgorithm (fun n x ↦ mossIndex σ2 horizon n x.1) (fun n ↦ sorry) /-- [LS, Theorem 9.1] for σ²-sub-Gaussian rewards. -/ -theorem moss_regret_le (n : ℕ) (h : IsAlgEnvSeq O A R (moss σ2 n) (stationaryEnv ν) P) +theorem moss_regret_le (n : ℕ) (h : IsAlgEnvSeq O A R (moss σ2 n) (Environment.bandit ν) P) (hν : ∀ a, HasSubgaussianMGF (fun x ↦ x - (ν a)[id]) σ2 (ν a)) : P[Bandits.regret ν A n] ≤ 39 * √(σ2 * Fintype.card α * n) + ∑ a, Bandits.gap ν a := sorry @@ -237,7 +237,7 @@ theorem klucbFam_gaussianReal {σ2 : ℝ≥0} (hσ2 : σ2 ≠ 0) : parameter `θ a`, and `θ' a` is the natural parameter of the largest mean in the family of `a`. -/ theorem klucbFam_regret_eventually_le (ρ : α → Measure ℝ) [∀ a, IsProbabilityMeasure (ρ a)] {ν : Kernel α ℝ} [IsMarkovKernel ν] {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {R : ℕ → Ω → ℝ} - (h : IsAlgEnvSeq O A R (klucbFam ρ) (stationaryEnv ν) P) + (h : IsAlgEnvSeq O A R (klucbFam ρ) (Environment.bandit ν) P) (θ : α → ℝ) (hθ : ∀ a, θ a ∈ interior (integrableExpSet id (ρ a))) (hdom : ∀ a, ∀ t ∈ integrableExpSet id ((ρ a).tilted fun x ↦ θ a * x), t ∈ integrableExpSet id (ν a) ∧ mgf id (ν a) t ≤ mgf id ((ρ a).tilted fun x ↦ θ a * x) t) @@ -273,7 +273,7 @@ def klucb : Algorithm Unit α ℝ := klucbFam fun _ ↦ bernoulliMeasure (1 : ℝ) 0 ⟨2⁻¹, by norm_num, by norm_num⟩ /-- The asymptotic part of [LS, Theorem 10.6], for rewards in `[0, 1]`. -/ -theorem klucb_regret_eventually_le (h : IsAlgEnvSeq O A R klucb (stationaryEnv ν) P) +theorem klucb_regret_eventually_le (h : IsAlgEnvSeq O A R klucb (Environment.bandit ν) P) (hν : ∀ a, ∀ᵐ x ∂(ν a), x ∈ Set.Icc (0 : ℝ) 1) {c : ℝ} (hc : ∑ a ∈ univ.filter (fun a ↦ 0 < Bandits.gap ν a), Bandits.gap ν a / (klBer (ν a)[id] (⨆ b, (ν b)[id])).toReal < c) : @@ -292,8 +292,8 @@ theorem klDiv_map_history_eq_sum_pullCount [StandardBorelSpace α] {alg : Algorithm Unit α ℝ} {ν ν' : Kernel α ℝ} [IsMarkovKernel ν] [IsMarkovKernel ν'] {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {R : ℕ → Ω → ℝ} {O' : ℕ → Ω' → Unit} {A' : ℕ → Ω' → α} {R' : ℕ → Ω' → ℝ} - (h : IsAlgEnvSeq O A R alg (stationaryEnv ν) P) - (h' : IsAlgEnvSeq O' A' R' alg (stationaryEnv ν') P') (n : ℕ) : + (h : IsAlgEnvSeq O A R alg (Environment.bandit ν) P) + (h' : IsAlgEnvSeq O' A' R' alg (Environment.bandit ν') P') (n : ℕ) : klDiv (P.map (history O A R n)) (P'.map (history O' A' R' n)) = ∑ a, (∫⁻ ω, (pullCount A a n ω : ℝ≥0∞) ∂P) * klDiv (ν a) (ν' a) := sorry @@ -311,7 +311,7 @@ theorem exists_sqrt_le_integral_regret_gaussianBandit (alg : Algorithm Unit α ∃ μ : α → ℝ, (∀ a, μ a ∈ Set.Icc 0 1) ∧ √(σ2 * (Fintype.card α - 1) * n) / 27 ≤ ∫ ω, Bandits.regret (gaussianBandit μ σ2) IT.action n ω - ∂(trajMeasure alg (stationaryEnv (gaussianBandit μ σ2))) := + ∂(trajMeasure alg (Environment.bandit (gaussianBandit μ σ2))) := sorry /-- `d_inf(P, m, M)`: the smallest relative entropy from `P` to a law of `M` with mean above `m` @@ -335,7 +335,7 @@ theorem dInf_range_tilted (ρ : Measure ℝ) [IsProbabilityMeasure ρ] (hρ : def IsConsistentGaussian (alg : Algorithm Unit α ℝ) (σ2 : ℝ≥0) : Prop := ∀ μ : α → ℝ, ∀ p : ℝ, 0 < p → Tendsto (fun n : ℕ ↦ (∫ ω, Bandits.regret (gaussianBandit μ σ2) IT.action n ω - ∂(trajMeasure alg (stationaryEnv (gaussianBandit μ σ2)))) / (n : ℝ) ^ p) atTop (𝓝 0) + ∂(trajMeasure alg (Environment.bandit (gaussianBandit μ σ2)))) / (n : ℝ) ^ p) atTop (𝓝 0) /-- The Lai–Robbins lower bound for Gaussian bandits ([LS, Theorem 16.2] with [LS, Table 16.1]), in eventual form. -/ @@ -344,7 +344,7 @@ theorem lai_robbins_gaussian {alg : Algorithm Unit α ℝ} {σ2 : ℝ≥0} (hc : c < ∑ a ∈ univ.filter (fun a ↦ 0 < Bandits.gap (gaussianBandit μ σ2) a), 2 * σ2 / Bandits.gap (gaussianBandit μ σ2) a) : ∀ᶠ n : ℕ in atTop, c * log n ≤ ∫ ω, Bandits.regret (gaussianBandit μ σ2) IT.action n ω - ∂(trajMeasure alg (stationaryEnv (gaussianBandit μ σ2))) := + ∂(trajMeasure alg (Environment.bandit (gaussianBandit μ σ2))) := sorry /-! ## Layer 5: Thompson sampling -/ diff --git a/LMLRoadmaps/Generalization/README.md b/LMLRoadmaps/Generalization/README.md index 0b8605f..022fc25 100644 --- a/LMLRoadmaps/Generalization/README.md +++ b/LMLRoadmaps/Generalization/README.md @@ -191,8 +191,8 @@ targets here: `Algorithm.piecewise` beside LMLExplore's `Environment.piecewise` (`SequentialLearning/Algorithm.lean`), with its step-kernel lemma. The per-round divergences with a restricted first marginal need no countably generated observation space (LML's - `klDiv_restrict_add_restrict_compl`); the integral form needs it (LML's - `klDiv_compProd_right_eq_lintegral`). + `klDiv_restrict_add_restrict_compl`); the integral form needs it (Tau Ceti's + `TauCeti.klDiv_compProd_right`). - Derive `klDiv_stoppedHistMeasure_le` (one algorithm against `Environment.bandit κ` and `Environment.bandit κ'`) as its corollary, and delete the private `swapEnv`, `klDiv_compProd_stepKernel_swapEnv` and `klDiv_trajMeasure_swapEnv`. diff --git a/LMLRoadmaps/Generalization/Suggested.lean b/LMLRoadmaps/Generalization/Suggested.lean index b067cc5..ba94ad7 100644 --- a/LMLRoadmaps/Generalization/Suggested.lean +++ b/LMLRoadmaps/Generalization/Suggested.lean @@ -28,8 +28,7 @@ files of the roadmaps that specify them, and are not repeated here: This file imports only Mathlib, Tau Ceti and LML, at the versions pinned by LMLRoadmaps, so it restates the LMLExplore structures it needs (`IdentTask`, `IsBlackwell`, `IsPolicyIteration`, -`simplex`) and uses the LML names of that pin: `stationaryEnv` is `Environment.bandit` at the pin -of LMLExplore. +`simplex`) and uses the LML names of that pin. -/ noncomputable section @@ -121,14 +120,14 @@ variable (task : IdentTask α Θ ℐ 𝓨) /-- `A` is `δ`-correct on the task: on every admissible model, with probability at least `1 - δ`, it stops and outputs a correct answer. -/ def IsDeltaCorrect (A : IdentAlg Unit α 𝓨 ℐ) (δ : ℝ) : Prop := - ∀ θ ∈ task.M, (histOutputMeasure A (stationaryEnv (task.ν θ))).real + ∀ θ ∈ task.M, (histOutputMeasure A (Environment.bandit (task.ν θ))).real {p | p.1 ∉ A.stopSet ∨ p.2 ∉ task.correct θ} ≤ δ /-- `A` is `δ`-PAC on the task: it is `δ`-correct and stops almost surely on every admissible model. -/ def IsDeltaPAC (A : IdentAlg Unit α 𝓨 ℐ) (δ : ℝ) : Prop := task.IsDeltaCorrect A δ ∧ ∀ θ ∈ task.M, - ∀ᵐ ω ∂(trajMeasure A.alg (stationaryEnv (task.ν θ))), + ∀ᵐ ω ∂(trajMeasure A.alg (Environment.bandit (task.ν θ))), A.stoppingTime IT.obs IT.action IT.feedback ω ≠ ⊤ /-- LMLExplore's GLR statistic `inf_{λ ∈ ¬i} Z n h λ` of the evidence function `Z` @@ -157,10 +156,10 @@ theorem isDeltaPAC_glrt (Z : (n : ℕ) → Hist Unit α 𝓨 n → Θ → ℝ≥ (rec : (n : ℕ) → Hist Unit α 𝓨 n → ℐ) (hrec : ∀ n, Measurable (rec n)) (hstop : ∀ n, MeasurableSet {h | β n h < task.glr Z n h (rec n h)}) {δ : ℝ} (hc : ∀ θ ∈ task.M, MeasurableSet (task.correct θ)) - (hdev : ∀ θ ∈ task.M, (trajMeasure alg (stationaryEnv (task.ν θ))).real + (hdev : ∀ θ ∈ task.M, (trajMeasure alg (Environment.bandit (task.ν θ))).real {ω | ∃ n, β n (history IT.obs IT.action IT.feedback n ω) < Z n (history IT.obs IT.action IT.feedback n ω) θ} ≤ δ) - (h_stops : ∀ θ ∈ task.M, ∀ᵐ ω ∂(trajMeasure alg (stationaryEnv (task.ν θ))), + (h_stops : ∀ θ ∈ task.M, ∀ᵐ ω ∂(trajMeasure alg (Environment.bandit (task.ν θ))), (task.glrt Z alg β rec hrec hstop).stoppingTime IT.obs IT.action IT.feedback ω ≠ ⊤) : task.IsDeltaPAC (task.glrt Z alg β rec hrec hstop) δ := sorry diff --git a/LMLRoadmaps/Identification/README.md b/LMLRoadmaps/Identification/README.md index 37ab630..95a42ec 100644 --- a/LMLRoadmaps/Identification/README.md +++ b/LMLRoadmaps/Identification/README.md @@ -58,7 +58,7 @@ generating functions with its exponential supermartingales (Layer 4.2). | Material | Owner and interface consumed here | | --- | --- | -| Interaction protocol, runs, trajectory measure, stationary environments | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `stationaryEnv`, `stepKernel`, `IsAlgEnvSeq.filtrationAction` | +| Interaction protocol, runs, trajectory measure, stationary environments | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `Environment.bandit`, `stepKernel`, `IsAlgEnvSeq.filtrationAction` | | Identification algorithms: sampling, stopping and output rules, stopping time, stopped history, law of the output, PAC property | LML `SequentialLearning/IdentificationAlg.lean` (`IdentAlg`, `IdentAlg.stoppingTime`, `IdentAlg.stoppedHist`, `IdentAlg.outputMeasure`, `IdentAlg.IsRun`, `IdentAlg.IsPAC`), `SequentialLearning/StoppedHistory.lean` (`sigmaHistory`, `stoppedHistMeasure`); LMLExplore `SequentialLearning/StoppedHistory.lean` (`Learning.notStoppedSet`, `Learning.stoppedHistMeasure_congr`) | | Pull counts, reward sums, empirical means, per-arm reward streams | LML `SequentialLearning/FiniteActions.lean` (`pullCount`, `rewardByCount`), `SumRewards.lean`, `Online/Bandit/ArrayProbSpace.lean` (`streamMeasure`); LMLExplore `SequentialLearning/SumRewards.lean` | | Conditional means of the feedback and their martingale | LML `SequentialLearning/Means.lean` (`Environment.means`, `IsAlgEnvSeq.condExp_feedback`), `FeedbackMartingale.lean` (`noiseSum`, `IsAlgEnvSeq.martingale_noiseSum`) | @@ -111,7 +111,7 @@ bounds, the pure exploration game and the run-to-stream transfer (Layers 0–3 a for general `𝓨`. Exponential families live on any measurable space, with a real or vector statistic; the algorithms built on empirical means use `𝓨 = ℝ`, or the statistic of an exponential family on `𝓨`. The observation type of the sampling rule is `Unit`, as for LML's -`stationaryEnv`. +`Environment.bandit`. **Models and tasks.** An identification task (Layer 1.1) has a type `Θ` of models with a Markov kernel `ν θ : Kernel α 𝓨` for each model, a set `M : Set Θ` of admissible models, a type `ℐ` of @@ -152,7 +152,7 @@ Cramér rate function (Layer 1.2), also `ℝ≥0∞`-valued. determine: the joint law of the stopped history and the output, built from LML's `stoppedHistMeasure` and the output kernel, and the law `IdentAlg.outputMeasure`. - The sample complexity is $\mathbb E_\theta[\tau]$, the `ℝ≥0∞`-valued lower integral of the - stopping time under `trajMeasure A.alg (stationaryEnv (ν θ))`. + stopping time under `trajMeasure A.alg (Environment.bandit (ν θ))`. - A fixed-budget algorithm with budget $T$ stops after exactly $T$ rounds; its probability of error on $\theta$ is the `outputMeasure`-mass of the incorrect answers. @@ -178,7 +178,7 @@ the primary statements; derive them as corollaries. **Namespaces.** Identification definitions live in `LMLExplore.Identification`, exponential families in `LMLExplore` (or the namespace of the type they act on), and LML's definitions keep -their names (`Learning.IdentAlg`, `Learning.stationaryEnv`, …). +their names (`Learning.IdentAlg`, `Learning.Environment.bandit`, …). ## Existing formalizations @@ -285,7 +285,7 @@ forms above, and that development may be adapted to them. 1. **Tasks.** - Define identification tasks (Conventions): alternatives $\neg i$, answer sets $\{\theta\in M: i\in i^*(\theta)\}$, single-answer tasks, and the bandit environment - `stationaryEnv (ν θ)` of a model. + `Environment.bandit (ν θ)` of a model. - Define $\delta$-correct and $\delta$-PAC algorithms for a task. - For a task on `Θ'` and a map `f : Θ → Θ'`, define the pullback `task.comap f`, with bandits `task.ν ∘ f`, admissible models `f ⁻¹' task.M` and correct answers `task.correct ∘ f`. Prove @@ -488,14 +488,14 @@ product models with $\mathrm K_{\inf}$ costs [AJG20, JDK23a]. with $\mu_t$ the law of the $t$-round history under the first pair restricted to LMLExplore's `notStoppedSet S t`, that is, $\mathbb E\big[\sum_{t<\tau}\mathrm{KL}(\text{step}_t(H_t)\,\|\,\text{step}'_t(H_t))\big]$ when the - spaces are countably generated (LML's `klDiv_compProd_right_eq_lintegral`), with equality + spaces are countably generated (Tau Ceti's `TauCeti.klDiv_compProd_right`), with equality when $\tau$ is also almost surely finite under the second pair. The fixed-horizon case is LML's `IsAlgEnvSeq.klDiv_map_history_stepKernel`; the proof changes both pairs after the stopping time (LMLExplore's `stoppedHistMeasure_congr`). - Prove the same bound for the joint law of the stopped history and the output when the output kernel is common (Mathlib's `klDiv_compProd_left`). - - For one algorithm run in `stationaryEnv ν` and `stationaryEnv ν'` on finite arms, deduce - $\mathrm{KL}(\text{law of the stopped history under }\nu,\text{ under }\nu') + - For one algorithm run in `Environment.bandit ν` and `Environment.bandit ν'` on finite arms, + deduce $\mathrm{KL}(\text{law of the stopped history under }\nu,\text{ under }\nu') \le\sum_a\mathbb E_\nu[N_a(\tau)]\,\mathrm{KL}(\nu_a,\nu'_a)$, with equality when $\tau$ is also almost surely finite under $\nu'$. LMLExplore's `klDiv_stoppedHistMeasure_le` becomes this corollary; the fixed-horizon case is LML's `IsAlgEnvSeq.klDiv_map_history_stepKernel`. @@ -661,10 +661,10 @@ alternatives, and Gaussian costs with arm-dependent variances in design-operator 1. **Empirical statistics along a run and the per-arm streams.** - Define the per-arm sums, counts and empirical means of a run (from LML's `SumRewards`), and the sum-count statistic of a history. - - For a run of any algorithm against `stationaryEnv ν`, with `ν : Kernel α 𝓨` on any measurable - space `𝓨`, and a predicate $q$ on the numbers of pulls `s : α → ℕ` and the first $s_a$ - observations of each arm (an element of `(a : α) → Fin (s a) → 𝓨`), prove the event transfer - to LML's per-arm stream model `streamMeasure ν` (the stack-of-rewards model + - For a run of any algorithm against `Environment.bandit ν`, with `ν : Kernel α 𝓨` on any + measurable space `𝓨`, and a predicate $q$ on the numbers of pulls `s : α → ℕ` and the first + $s_a$ observations of each arm (an element of `(a : α) → Fin (s a) → 𝓨`), prove the event + transfer to LML's per-arm stream model `streamMeasure ν` (the stack-of-rewards model [LS, Section 4.6]): the probability that $q$ holds at some round for the pull counts and the observations of each arm so far is at most the `streamMeasure ν`-probability that $q$ holds for some `s` and the first $s_a$ stream observations of each arm. Prove its form up to a diff --git a/LMLRoadmaps/Identification/Suggested.lean b/LMLRoadmaps/Identification/Suggested.lean index edcb551..8201159 100644 --- a/LMLRoadmaps/Identification/Suggested.lean +++ b/LMLRoadmaps/Identification/Suggested.lean @@ -27,8 +27,8 @@ nor the roadmap. The admitted proofs are targets, not claimed implementations. T the helper `armObs` are admitted definitions: constructing them, with their run lemmas, is a target, and their docstrings and the README specify them. -The names of the LML framework (`IdentAlg`, `stationaryEnv`, `stoppedHistMeasure`, ...) are those -of the LML version pinned by LMLExplore. +The names of the LML framework (`IdentAlg`, `Environment.bandit`, `stoppedHistMeasure`, ...) are +those of the LML version pinned by LMLExplore. -/ noncomputable section @@ -54,7 +54,7 @@ def histOutputMeasure (A : IdentAlg Unit α 𝓨 ℐ) (env : Environment Unit α /-- The expected number of rounds played by `A` in `env` (README Layer 0.3). -/ def expectedStoppingTime (A : IdentAlg Unit α 𝓨 ℐ) (env : Environment Unit α 𝓨) : ℝ≥0∞ := - ∫⁻ ω, (A.stoppingTime IT.obs IT.action IT.feedback ω : ℝ≥0∞) ∂(trajMeasure A.alg env) + ∫⁻ ω, ENat.toENNReal (A.stoppingTime IT.obs IT.action IT.feedback ω) ∂(trajMeasure A.alg env) /-- **Wald's identity for the feedback**, for every environment (README Layer 0.3): for a stopping time `τ` of the filtration of the actions with `E[τ] < ∞`, and conditional absolute means of the @@ -65,7 +65,7 @@ theorem integral_sum_feedback_eq_integral_sum_means {Ω 𝓞 𝓐 : Type*} [Meas {O : ℕ → Ω → 𝓞} {A : ℕ → Ω → 𝓐} {Y : ℕ → Ω → ℝ} {alg : Algorithm 𝓞 𝓐 ℝ} {env : Environment 𝓞 𝓐 ℝ} (h : IsAlgEnvSeq O A Y alg env P) {τ : Ω → ℕ∞} (hτ : IsStoppingTime h.filtrationAction τ) (hτ_int : ∫⁻ ω, (τ ω : ℝ≥0∞) ∂P ≠ ∞) {C : ℝ} - (hC : ∀ n, ∀ᵐ ω ∂P, ∫ y, |y| ∂(env.measure O A Y n ω (A n ω)) ≤ C) : + (hC : ∀ n, ∀ᵐ ω ∂P, ∫ y, |y| ∂(env.feedbackKernel O A Y n ω (A n ω)) ≤ C) : ∫ ω, ∑ t ∈ range (τ ω).toNat, Y t ω ∂P = ∫ ω, ∑ t ∈ range (τ ω).toNat, env.means O A Y (A t ω) t ω ∂P := sorry @@ -96,14 +96,14 @@ def alt (i : ℐ) : Set Θ := {θ' | θ' ∈ task.M ∧ i ∉ task.correct θ'} /-- `A` is `δ`-correct on the task [DK19]: on every admissible model, with probability at least `1 - δ`, it stops and outputs a correct answer. -/ def IsDeltaCorrect (A : IdentAlg Unit α 𝓨 ℐ) (δ : ℝ) : Prop := - ∀ θ ∈ task.M, (histOutputMeasure A (stationaryEnv (task.ν θ))).real + ∀ θ ∈ task.M, (histOutputMeasure A (Environment.bandit (task.ν θ))).real {p | p.1 ∉ A.stopSet ∨ p.2 ∉ task.correct θ} ≤ δ /-- `A` is `δ`-PAC on the task: it is `δ`-correct and stops almost surely on every admissible model. -/ def IsDeltaPAC (A : IdentAlg Unit α 𝓨 ℐ) (δ : ℝ) : Prop := task.IsDeltaCorrect A δ ∧ ∀ θ ∈ task.M, - ∀ᵐ ω ∂(trajMeasure A.alg (stationaryEnv (task.ν θ))), + ∀ᵐ ω ∂(trajMeasure A.alg (Environment.bandit (task.ν θ))), A.stoppingTime IT.obs IT.action IT.feedback ω ≠ ⊤ /-- The pullback of a task along `f : Θ' → Θ` (README Layer 1.1): the bandit, the admissibility @@ -303,13 +303,14 @@ transportation cost bounds the binary relative entropy of the probabilities of ` relative entropy is written in `ℝ≥0∞` through `klDiv` of two Bernoulli laws. -/ theorem klDiv_bernoulli_le_sum_lintegral_pullCount [MeasurableSpace.CountablyGenerated 𝓨] (A : IdentAlg Unit α 𝓨 ℐ) (ν ν' : Kernel α 𝓨) [IsMarkovKernel ν] [IsMarkovKernel ν'] - (hτ : ∀ᵐ ω ∂(trajMeasure A.alg (stationaryEnv ν)), + (hτ : ∀ᵐ ω ∂(trajMeasure A.alg (Environment.bandit ν)), A.stoppingTime IT.obs IT.action IT.feedback ω ≠ ⊤) {E : Set ((Σ n : ℕ, Hist Unit α 𝓨 n) × ℐ)} (hE : MeasurableSet E) : - klDiv ((histOutputMeasure A (stationaryEnv ν)).map (· ∈ E)) - ((histOutputMeasure A (stationaryEnv ν')).map (· ∈ E)) ≤ - ∑ a, (∫⁻ ω, (pullCount IT.action a ((A.stoppingTime IT.obs IT.action IT.feedback ω).toNat) - ω : ℝ≥0∞) ∂(trajMeasure A.alg (stationaryEnv ν))) * klDiv (ν a) (ν' a) := + klDiv ((histOutputMeasure A (Environment.bandit ν)).map (· ∈ E)) + ((histOutputMeasure A (Environment.bandit ν')).map (· ∈ E)) ≤ + ∑ a, (∫⁻ ω, (pullCount IT.action a + (ENat.toNat (A.stoppingTime IT.obs IT.action IT.feedback ω)) ω : ℝ≥0∞) + ∂(trajMeasure A.alg (Environment.bandit ν))) * klDiv (ν a) (ν' a) := sorry /-- **Lower bound on the sample complexity** [GK16, Theorem 1]: for a `δ`-correct algorithm with @@ -320,7 +321,7 @@ theorem charTime_mul_le_expectedStoppingTime [MeasurableSpace.CountablyGenerated (hδ : δ ∈ Set.Ioc 0 (1 / 2)) (hA : task.IsDeltaCorrect A δ) {θ : Θ} (hθ : θ ∈ task.M) {i : ℐ} (hi : task.correct θ = {i}) : task.charTime θ * ENNReal.ofReal ((1 - 2 * δ) * log ((1 - δ) / δ)) ≤ - expectedStoppingTime A (stationaryEnv (task.ν θ)) := + expectedStoppingTime A (Environment.bandit (task.ν θ)) := sorry /-! ## Layer 3: continuity on product models -/ @@ -356,7 +357,7 @@ at most the probability that it holds for some numbers of pulls in the stream mo theorem measure_exists_armObs_le_streamMeasure {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P] {O : ℕ → Ω → Unit} {A : ℕ → Ω → α} {Y : ℕ → Ω → 𝓨} {alg : Algorithm Unit α 𝓨} {ν : Kernel α 𝓨} [IsMarkovKernel ν] - (h : IsAlgEnvSeq O A Y alg (stationaryEnv ν) P) + (h : IsAlgEnvSeq O A Y alg (Environment.bandit ν) P) (q : (s : α → ℕ) → ((a : α) → Fin (s a) → 𝓨) → Prop) : P {ω | ∃ t, q (fun a ↦ pullCount A a t ω) (fun a ↦ armObs A Y a t ω)} ≤ Bandits.streamMeasure ν {x | ∃ s : α → ℕ, q s (fun a i ↦ x i a)} := @@ -463,7 +464,7 @@ theorem trackAndStop_asymptotic (task : IdentTask α (α → ℝ) ℐ 𝓨) (ρ {μ : α → ℝ} (hμ : μ ∈ task.M) {c : ℝ≥0} (hc : task.charTime μ < c) : ∀ᶠ δ in 𝓝[>] 0, expectedStoppingTime (trackAndStop task (empMeanStat T) w rec (expFamilyEvidence κ T) β δ) - (stationaryEnv (task.ν μ)) ≤ c * ENNReal.ofReal (log (1 / δ)) := + (Environment.bandit (task.ν μ)) ≤ c * ENNReal.ofReal (log (1 / δ)) := sorry end LMLRoadmaps.Identification diff --git a/LMLRoadmaps/ReinforcementLearning/README.md b/LMLRoadmaps/ReinforcementLearning/README.md index 747063a..18ca4de 100644 --- a/LMLRoadmaps/ReinforcementLearning/README.md +++ b/LMLRoadmaps/ReinforcementLearning/README.md @@ -58,7 +58,7 @@ This roadmap owns Markov decision processes and reinforcement learning: | Material | Owner and interface consumed here | | --- | --- | -| Interaction protocol, runs, trajectory measure, environments, identification algorithms | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `stationaryEnv`, `obliviousEnv`, `IdentAlg`, `pullCount`, `streamMeasure` | +| Interaction protocol, runs, trajectory measure, environments, identification algorithms | LML `SequentialLearning/`: `Algorithm`, `Environment`, `IsAlgEnvSeq`, `trajMeasure`, `Environment.bandit`, `Environment.banditSeq`, `IdentAlg`, `pullCount`, `streamMeasure` | | MDPs and their environment | LML's `mdp` branch, not at the pinned version: `MDP 𝓢 𝓐 𝓡` with fields `P : Kernel (𝓢 × 𝓐) 𝓢` and `R : Kernel (𝓢 × 𝓐) 𝓡`, `MDP.env`, `MDP.policyAlg`, `MDP.meanReward`. Follow its names and shapes (Layer 7.1) | | Episodic MDPs, episodes as rounds | entropy-mdp (Existing formalizations): `EpisodicMDP`, `augmented`, `Policy`, `statesEnv`, `BPIAlg` | | Kernels, Ionescu–Tulcea, invariant measures, total variation | Mathlib `Probability/Kernel/`, `Kernel.traj`, `condExp_traj`, `Kernel.Invariant`, `tvDist` | @@ -228,7 +228,7 @@ statement and says so. ## Existing library and design guidance Consume these modules and extend their APIs rather than restating them. The pinned versions are LML -`53be244`, Mathlib `2e318fae` and Tau Ceti `cebc9b6`. +`e0a6fb9`, Mathlib `2ddf59c8` and Tau Ceti `4d91513`. | Foundation | Existing source | | --- | --- | @@ -750,7 +750,7 @@ Suggested home: `SequentialLearning/`. - an independent uniform randomization stream for the algorithm; - an independent array $Z_{k,j}\sim$ `ηY k ⊗ ηO k`, read at the $j$-th occurrence of key $k$. - This generalizes LML's `Bandits.arrayMeasure` and `probSpace`. + This generalizes LML's `Bandits.arrayMeasure` and `ProbSpace`. - Deduce the keyed transfer: for every event $E_j$ about the first $j$ draws of key $k$, the probability that $E_j$ holds for the draws seen at some $j\le$ the count of $k$ before round $n$ is at most the probability that $E_j$ holds for some $j\le n$ under the i.i.d. stream. @@ -784,7 +784,7 @@ Suggested home: `SequentialLearning/`. MDP runs. Completion checks: for the action key, item 1 is LML's per-arm stream model and item 2 is LML's -`IsAlgEnvSeq.klDiv_map_history`. +`IsAlgEnvSeq.klDiv_map_history_bandit`. ## Layer 7: Markov decision processes, policies and values 1. **Models and environments.** @@ -881,21 +881,21 @@ Completion checks: for the action key, item 1 is LML's per-arm stream model and `Policy.extend`. 7. **Episodes as rounds.** - For finite `𝓢` and countable `𝓐`, define the episode-level environment `statesEnv M H μ`. It - is LML's `stationaryEnv` of the kernel from $H$-step policies to the law of the state sequence of - an episode started from μ. It generalizes entropy-mdp's `statesEnv M H s₁`, which is the case - $\mu=\delta_{s_1}$. + is LML's `Environment.bandit` of the kernel from $H$-step policies to the law of the state + sequence of an episode started from μ. It generalizes entropy-mdp's `statesEnv M H s₁`, which + is the case $\mu=\delta_{s_1}$. - A learner in it chooses an $H$-step policy at the start of every episode from the previous episodes, and observes the state sequence. Rewards are known when they are deterministic. - - Define likewise `episodeEnv M H μ`, the `stationaryEnv` of the kernel from $H$-step policies - to the joint law of the state sequence and the reward sequence of an episode. A learner in it - also observes the rewards, and so learns unknown stochastic rewards. Prove that forgetting - the rewards maps its episode laws to those of `statesEnv M H μ`. + - Define likewise `episodeEnv M H μ`, the `Environment.bandit` of the kernel from $H$-step + policies to the joint law of the state sequence and the reward sequence of an episode. A + learner in it also observes the rewards, and so learns unknown stochastic rewards. Prove that + forgetting the rewards maps its episode laws to those of `statesEnv M H μ`. - For finite `𝓐`, prove that a stochastic Markov policy has the episode law (in either environment) of the random $H$-step policy drawn from the product over $(h,s)$ of its action laws. Algorithms in `statesEnv` and `episodeEnv` thereby play stochastic Markov policies. Completion checks: a one-state MDP is a bandit, and `M.env μ` then has the law of LML's -`stationaryEnv M.R` up to the constant observation; the value of a deterministic policy in a +`Environment.bandit M.R` up to the constant observation; the value of a deterministic policy in a deterministic MDP is a geometric sum along its orbit. ## Layer 8: Bellman operators and the finite horizon @@ -1316,7 +1316,7 @@ an item says otherwise. `Fin H × 𝓢 × 𝓐`. - Prove that the coordinates of disjoint sets of keys are independent. - Define the empirical kernel and the empirical MDP `M.empirical N ω`, with the same rewards. - - Adaptive sampling is a run of an algorithm against `stationaryEnv M.P`. + - Adaptive sampling is a run of an algorithm against `Environment.bandit M.P`. 4. **Pigeonhole sums.** Here $N_k(x)=\#\{i0$ such that, for $\gamma\ge2/5$, $\varepsilon\in(0,\varepsilon_0]$ and $\delta\in(0,\delta_0/(KA))$, every algorithm querying - `stationaryEnv M.P` adaptively for $T$ rounds whose estimate of $Q^*$ is ε-accurate with + `Environment.bandit M.P` adaptively for $T$ rounds whose estimate of $Q^*$ is ε-accurate with probability at least $1-\delta$ on every MDP of the family has $T\ge KA\log(KA/(C\delta))/(C(1-\gamma)^3\varepsilon^2)$. - Use the change of measure of Layer 6.2 at the fixed budget $T$. @@ -1689,9 +1689,9 @@ Episodic MDPs with known horizon and unknown fixed stage-dependent transitions. losses $\ell_k:\mathrm{Fin}\,H\to\mathcal S\times\mathcal A\to[0,1]$, chosen as an oblivious sequence, as in the Bandits roadmap. -- The environment is LML's `obliviousEnv` whose round-$k$ kernel maps an $H$-step policy to the law - of the state sequence together with $\ell_k$ (full information), or together with the losses - $\ell_{k,h}(S_h,A_h)$ along the trajectory (bandit feedback). +- The environment is LML's `Environment.banditSeq` whose round-$k$ kernel maps an $H$-step policy to + the law of the state sequence together with $\ell_k$ (full information), or together with the + losses $\ell_{k,h}(S_h,A_h)$ along the trajectory (bandit feedback). - The regret against the best Markov policy is $\max_\pi\sum_{k