@@ -3,12 +3,16 @@ Copyright (c) 2026 Rémy Degenne. All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Rémy Degenne, Paulo Rauber
55-/
6- import LeanBandits.Bandit.SumRewards
7- import LeanBandits.BanditAlgorithms.Uniform
8- import LeanBandits.SequentialLearning.AlgorithmDensity
6+ module
7+
8+ public import LeanMachineLearning.Bandit.SumRewards
9+ public import LeanMachineLearning.BanditAlgorithms.Uniform
10+ public import LeanMachineLearning.SequentialLearning.AlgorithmDensity
911
1012/-! # The Thompson Sampling Algorithm -/
1113
14+ @[expose] public section
15+
1216open MeasureTheory ProbabilityTheory Finset Learning
1317
1418open scoped NNReal
@@ -309,7 +313,7 @@ private lemma abs_sumRewards_sub_pullCount_mul_ge {a : Fin K} {n : ℕ} {ω : Ω
309313 2 * σ2 * Real.log (1 / δ) / pullCount A a n ω * pullCount A a n ω ^ 2 := by
310314 field_simp
311315 rw [this, Real.sqrt_mul (div_nonneg hc hk.le), Real.sqrt_sq hk.le]
312- · rw [Real.sqrt_eq_zero_of_nonpos (by push_neg at hc; nlinarith)]
316+ · rw [Real.sqrt_eq_zero_of_nonpos (by push Not at hc; nlinarith)]
313317 exact mul_nonneg (Real.sqrt_nonneg _) hk.le
314318 _ ≤ |sumRewards A R' a n ω / pullCount A a n ω - μ| * pullCount A a n ω :=
315319 mul_le_mul_of_nonneg_right h hk.le
@@ -561,7 +565,7 @@ lemma bayesRegret_le_of_delta [Nonempty (Fin K)] [StandardBorelSpace Ω] [Nonemp
561565 have : Eδᶜ = {ω | ∃ s < n, ∃ a, pullCount A a s ω ≠ 0 ∧
562566 √(2 * ↑σ2 * Real.log (1 / δ) / (pullCount A a s ω : ℝ)) ≤
563567 |empMean A R' a s ω - armMean a ω|} := by
564- ext ω; simp only [Eδ, Set.mem_compl_iff, Set.mem_setOf_eq]; push_neg ; rfl
568+ ext ω; simp only [Eδ, Set.mem_compl_iff, Set.mem_setOf_eq]; push Not ; rfl
565569 rw [this]
566570 exact (h.prob_abs_empMean_sub_actionMean_ge_le hσ2 hs hδ n).trans
567571 (ENNReal.ofReal_le_ofReal (by nlinarith [hδ.le, Nat.cast_nonneg (α := ℝ) K]))
@@ -598,7 +602,7 @@ lemma bayesRegret_le_of_delta [Nonempty (Fin K)] [StandardBorelSpace Ω] [Nonemp
598602 have : Fδᶜ = {ω | ∃ s < n, pullCount A (bestArm ω) s ω ≠ 0 ∧
599603 √(2 * ↑σ2 * Real.log (1 / δ) / (pullCount A (bestArm ω) s ω : ℝ)) ≤
600604 |empMean A R' (bestArm ω) s ω - armMean (bestArm ω) ω|} := by
601- ext ω; simp only [Fδ, Set.mem_compl_iff, Set.mem_setOf_eq]; push_neg ; rfl
605+ ext ω; simp only [Fδ, Set.mem_compl_iff, Set.mem_setOf_eq]; push Not ; rfl
602606 rw [this]
603607 exact (h.prob_abs_empMean_bestAction_sub_actionMean_ge_le hσ2 hs hδ n).trans
604608 (ENNReal.ofReal_le_ofReal (by nlinarith [hδ.le]))
0 commit comments