Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Completed/Refactors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ω)} ≤
Expand Down
2 changes: 1 addition & 1 deletion Completed/Refactors/Suggested.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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)} :=
Expand Down
146 changes: 70 additions & 76 deletions LMLRoadmaps/Bandits/README.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions LMLRoadmaps/Bandits/Suggested.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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).
-/
Expand Down Expand Up @@ -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)]. -/
Expand All @@ -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 -/
Expand All @@ -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] ≤
Expand All @@ -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 :=
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) :
Expand All @@ -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
Expand All @@ -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`
Expand All @@ -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. -/
Expand All @@ -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 -/
Expand Down
4 changes: 2 additions & 2 deletions LMLRoadmaps/Generalization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
11 changes: 5 additions & 6 deletions LMLRoadmaps/Generalization/Suggested.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading