Bandit Algorithms
Tor Lattimore and Csaba Szepesvári
- Location
- Ch. 1 and Ch. 4, especially §4.5
- Pages
- online pp. 8–16 and 56–69; regret decomposition pp. 62–63
Teaching chapter · canonical scope Compiled
The deterministic language shared by the entire project: finite models, action and reward traces, pull counts, gaps, reward sums, pseudo-regret, and count-to-regret decompositions.
Who should read this. Start here if you know basic probability or machine learning but are new to this Lean library.
Textbook crosswalk
The Book Map is a curated formalization curriculum anchored in Bandit Algorithms, not a chapter-for-chapter reproduction of one book. Page numbers below use its free online edition; companion papers cover algorithm-specific results.
Tor Lattimore and Csaba Szepesvári
Tor Lattimore and Csaba Szepesvári
Write the selected arm A_t at every round t.
N_a(T) counts how often arm a appears before horizon T.
Every occurrence of arm a contributes the same model gap Δ_a.
Replace the sum over time by one gap-times-count term per arm.
The standard stochastic-bandit decomposition converts control of suboptimal pull counts into expected regret.
BanditRLlib relationship. BanditRLlib first proves the pathwise finite-trace identity. Algorithm chapters then integrate that bookkeeping identity under their own generated trajectory laws.
The mathematical content is restated in this site's notation; wording is ours. See online pp. 62–63 in the linked source for the original statement and full assumptions.
The mathematical readings are explanatory summaries. The exact generated Lean statement and its source link remain authoritative for hypotheses, types, constants, and indexing.
Plain-English statement. A finite bandit model packages a rational mean for every arm together with a distinguished best arm and a proof that this arm really has maximal mean.
structure FiniteBanditModel (K : Nat) where
Plain-English statement. The pull count of arm a before time n is the number of indices t<n at which the action trace selected a.
def pullCount [DecidableEq Action] (action : ActionTrace Action) (a : Action) : Nat → Nat | 0 => 0 | t + 1 => pullCount action a t + if action t = a then 1 else 0 @[simp] theorem pullCount_zero [DecidableEq Action] (action : ActionTrace Action) (a : Action) : pullCount action a 0 = 0
Plain-English statement. Cumulative pseudo-regret can be regrouped by arm: every pull of arm a contributes exactly its fixed gap.
BanditRLProof.pullCount, BanditRLProof.pseudoRegret, BanditRLProof.FiniteBanditModeltheorem pseudoRegret_eq_finset_sum_gap_mul_pullCount : pseudoRegret model action t = (Finset.univ : Finset (Fin K)).sum (fun a : Fin K => model.gap a * (pullCount action a t : Rat))
Plain-English statement. Minimax expected regret is the infimum, over an explicit policy class, of each policy's supremum expected regret over an explicit environment class.
BanditRLProof.LowerBounds.worstCaseExpectedRegretnoncomputable def minimaxExpectedRegret {Policy : Type u} {Environment : Type v} (regret : Policy -> Environment -> ENNReal) (policyClass : Set Policy) (environmentClass : Set Environment) : ENNReal
Plain-English statement. In an m-plus-one-arm problem with arm zero distinguished, nonnegative expected pulls summing exactly to the horizon imply that some alternative arm is pulled no more than the alternative average n divided by m.
BanditRLProof.LowerBounds.exists_alternative_le_average, BanditRLProof.LowerBounds.alternativeExpectedPullBudget_letheorem exists_leastExploredAlternative {m : Nat} (hm : 0 < m) (expectedPulls : Fin (m + 1) -> Real) (horizon : Nat) (hnonneg : ∀ arm, 0 ≤ expectedPulls arm) (htotal : ∑ arm : Fin (m + 1), expectedPulls arm = (horizon : Real)) : ∃ i : Fin m, expectedPulls i.succ ≤ (horizon : Real) / (m : Real)
Plain-English statement. If the base-environment expected base-arm pulls exceed the changed-environment expectation by at most an explicit error, then one of the two Chapter 13 regret expressions is at least Delta times n minus that error, divided by two.
BanditRLProof.LowerBounds.baseEnvironmentRegret, BanditRLProof.LowerBounds.changedEnvironmentRegretLowerBoundtheorem max_base_changed_regretLowerBound_ge_half_sub_error (horizon : Nat) (gap baseFirstExpectedPulls changedFirstExpectedPulls error : Real) (hgap : 0 ≤ gap) (hpullDifference : baseFirstExpectedPulls - changedFirstExpectedPulls ≤ error) : gap * ((horizon : Real) - error) / 2 ≤ max (baseEnvironmentRegret horizon gap baseFirstExpectedPulls) (changedEnvironmentRegretLowerBound gap changedFirstExpectedPulls)
Plain-English statement. If the changed-environment expected base-arm pulls are at least the base-environment expectation, then one Chapter 13 regret expression is at least Delta times n over two.
BanditRLProof.LowerBounds.max_base_changed_regretLowerBound_ge_half_sub_errortheorem max_base_changed_regretLowerBound_ge_half (horizon : Nat) (gap baseFirstExpectedPulls changedFirstExpectedPulls : Real) (hgap : 0 ≤ gap) (htransport : baseFirstExpectedPulls ≤ changedFirstExpectedPulls) : gap * (horizon : Real) / 2 ≤ max (baseEnvironmentRegret horizon gap baseFirstExpectedPulls) (changedEnvironmentRegretLowerBound gap changedFirstExpectedPulls)
Plain-English statement. Measure relative entropy is finite exactly when P is absolutely continuous with respect to Q and the P-log-likelihood ratio is integrable.
BanditRLProof.LowerBounds.relativeEntropytheorem relativeEntropy_ne_top_iff {α : Type*} [MeasurableSpace α] {P Q : Measure α} : relativeEntropy P Q ≠ ∞ ↔ P ≪ Q ∧ Integrable (llr P Q) P
Plain-English statement. Replacing a full observation by the one-bit answer to whether it lies in a measurable event cannot increase relative entropy.
BanditRLProof.LowerBounds.relativeEntropy_ne_top_iff, BanditRLProof.LowerBounds.relativeEntropy_restrict_add_compl, BanditRLProof.LowerBounds.bernoulliKLCore_event_letheorem bernoulliRelativeEntropy_event_le {α : Type*} [MeasurableSpace α] {P Q : Measure α} [IsProbabilityMeasure P] [IsProbabilityMeasure Q] {A : Set α} (hA : MeasurableSet A) : bernoulliRelativeEntropy (P.real A) (Q.real A) ≤ relativeEntropy P Q
Plain-English statement. For Bernoulli probabilities p and q, the sum p plus one minus q dominates the extended-real Bretagnolle–Huber testing scale.
BanditRLProof.LowerBounds.binaryBretagnolleHuberCore, BanditRLProof.LowerBounds.bretagnolleHuberScaletheorem binaryBretagnolleHuber {p q : Real} (hp : KLUCB.IsBernoulliParameter p) (hq : KLUCB.IsBernoulliParameter q) : bretagnolleHuberScale (bernoulliRelativeEntropy p q) ≤ p + (1 - q)
Plain-English statement. The real testing scale one-half exponential negative KL decreases as its extended-real information argument increases.
BanditRLProof.LowerBounds.bretagnolleHuberScale, BanditRLProof.LowerBounds.bretagnolleHuberScale_nonnegtheorem bretagnolleHuberScale_antitone {d D : ENNReal} (h : d ≤ D) : bretagnolleHuberScale D ≤ bretagnolleHuberScale d
Plain-English statement. For probability measures P and Q and a measurable event A, the P probability of A plus the Q probability of its complement is bounded below by one half exponential negative D(P,Q), with zero on the infinite-KL branch.
BanditRLProof.LowerBounds.bernoulliRelativeEntropy_event_le, BanditRLProof.LowerBounds.bretagnolleHuberScale_antitone, BanditRLProof.LowerBounds.binaryBretagnolleHubertheorem bretagnolleHuber {α : Type*} [MeasurableSpace α] {P Q : Measure α} [IsProbabilityMeasure P] [IsProbabilityMeasure Q] {A : Set α} (hA : MeasurableSet A) : bretagnolleHuberScale (relativeEntropy P Q) ≤ P.real A + Q.real Aᶜ
Plain-English statement. When two one-step joint laws share the same first marginal, their relative entropy is the first-law integral of the pointwise relative entropy between their conditional kernels.
theorem klDiv_compProd_same_left_eq_lintegral_klDiv_of_measurable {Base Target : Type*} [MeasurableSpace Base] [MeasurableSpace Target] [MeasurableSpace.CountablyGenerated Target] (mu : Measure Base) [IsFiniteMeasure mu] (kappa eta : Kernel Base Target) [IsMarkovKernel kappa] [IsMarkovKernel eta] (hmeasurable : Measurable (fun base => InformationTheory.klDiv (kappa base) (eta base))) : InformationTheory.klDiv (mu ⊗ₘ kappa) (mu ⊗ₘ eta) = ∫⁻ base, InformationTheory.klDiv (kappa base) (eta base) ∂mu
Plain-English statement. For one common randomized policy in two finite-arm environments, the directed KL between their canonical finite history laws equals the sum of first-environment expected pull counts times the directed KL of each arm law.
BanditRLProof.LowerBounds.klDiv_compProd_same_left_eq_lintegral_klDiv_of_measurable, BanditRLProof.LowerBounds.klDiv_historyStep_samePolicy_eq_iterated_lintegral_armKL_general, BanditRLProof.LowerBounds.canonicalRealizedExpectedPullCountThrough_eq_expectedPullCountThroughtheorem banditHistoryRelativeEntropy_eq_expectedPulls_sum {K : Nat} {Reward : Type v} [MeasurableSpace Reward] [MeasurableSpace.CountablyGenerated Reward] (algorithm : Thompson.HistoryAlgorithm (Fin K) Reward) (armLaw referenceArmLaw : Kernel (Fin K) Reward) [IsMarkovKernel armLaw] [IsMarkovKernel referenceArmLaw] (lastRound : Nat) : InformationTheory.klDiv (canonicalBanditHistoryMeasure algorithm armLaw lastRound) (canonicalBanditHistoryMeasure algorithm referenceArmLaw lastRound) = ∑ arm : Fin K, canonicalRealizedExpectedPullCountThrough algorithm armLaw lastRound arm * InformationTheory.klDiv (armLaw arm) (referenceArmLaw arm)
Plain-English statement. Under the first unit-variance Gaussian law, the log Radon–Nikodym derivative toward a second unit-variance Gaussian is an affine function of the observation.
BanditRLProof.LowerBounds.log_gaussianPDFReal_div_gaussianPDFReal_onetheorem llr_gaussianReal_one_ae (mu nu : Real) : llr (unitGaussianArm mu) (unitGaussianArm nu) =ᵐ[unitGaussianArm mu] fun x => (mu - nu) * x + (nu ^ 2 - mu ^ 2) / 2
Plain-English statement. The relative entropy from a unit-variance Gaussian with mean mu to one with mean nu is one half the squared mean difference.
BanditRLProof.LowerBounds.llr_gaussianReal_one_ae, BanditRLProof.LowerBounds.integrable_llr_gaussianReal_onetheorem klDiv_gaussianReal_one (mu nu : Real) : InformationTheory.klDiv (unitGaussianArm mu) (unitGaussianArm nu) = ENNReal.ofReal ((mu - nu) ^ 2 / 2)
Plain-English statement. The Chapter 15 gap choice makes the Gaussian information exponent exactly one half.
BanditRLProof.LowerBounds.gaussianMinimaxGap_sqtheorem gaussianMinimaxGap_informationExponent_eq_half {alternativeCount horizon : Real} (halternatives : 0 < alternativeCount) (hhorizon : 0 < horizon) : 2 * horizon * gaussianMinimaxGap alternativeCount horizon ^ 2 / alternativeCount = 1 / 2
Plain-English statement. A regret sequence is consistent when it divided by n to the p converges to zero for every positive real exponent p.
def IsConsistentRegret (regret : Nat -> Real) : Prop
Plain-English statement. The logarithmic growth ratio of a positive sum of two consistent regret sequences is eventually at most every positive exponent.
BanditRLProof.LowerBounds.IsConsistentRegret.add, BanditRLProof.LowerBounds.IsConsistentRegret.eventually_add_le_rpowtheorem IsConsistentRegret.eventually_log_add_div_log_le {first second : Nat -> Real} (hfirst : IsConsistentRegret first) (hsecond : IsConsistentRegret second) (hpositive : ∀ᶠ n : Nat in atTop, 0 < first n + second n) {p : Real} (hp : 0 < p) : ∀ᶠ n : Nat in atTop, Real.log (first n + second n) / Real.log n <= p
Plain-English statement. The Chapter 16 information cost is the extended-real infimum of original-to-alternative KL over laws in the class whose mean is strictly above the target mean.
BanditRLProof.LowerBounds.relativeEntropydef divergenceInfimum {Reward : Type*} [MeasurableSpace Reward] (P : Measure Reward) (muStar : Real) (distributionClass : Set (Measure Reward)) (mean : Measure Reward -> Real) : ENNReal
Plain-English statement. For a unit-variance Gaussian arm, changing the mean to mu-star plus a positive epsilon gives an admissible d_inf candidate with its exact squared-distance KL cost.
BanditRLProof.LowerBounds.parametricDivergenceInfimum_le, BanditRLProof.LowerBounds.klDiv_gaussianReal_onetheorem unitGaussianDivergenceInfimum_le_perturbed (mu muStar epsilon : Real) (hepsilon : 0 < epsilon) : unitGaussianDivergenceInfimum mu muStar <= ENNReal.ofReal (((muStar - mu) + epsilon) ^ 2 / 2)
Plain-English statement. If the average random-regret tail over a probability law on instances is at least delta, then one deterministic instance has tail probability at least delta.
theorem exists_cdfTail_ge_of_integral_ge {Instance : Type*} [MeasurableSpace Instance] (Q : Measure Instance) [IsProbabilityMeasure Q] (cdf : Instance -> Real -> Real) (threshold delta : Real) (hIntegrable : Integrable (fun x => 1 - cdf x threshold) Q) (hAverage : delta <= ∫ x, 1 - cdf x threshold ∂Q) : exists x, delta <= 1 - cdf x threshold
Plain-English statement. An event with probability at least twice delta still has probability at least delta after removing a bad event of probability at most delta.
theorem measureReal_diff_ge_delta {Omega : Type*} [MeasurableSpace Omega] (P : Measure Omega) [IsFiniteMeasure P] (pullSmall clippingBad : Set Omega) (delta : Real) (hPullSmall : 2 * delta <= P.real pullSmall) (hClippingBad : P.real clippingBad <= delta) : delta <= P.real (pullSmall \ clippingBad)
Plain-English statement. If Eq. (17.8) holds, pulling the hard arm at most half the time and clipping at most a quarter of rounds forces random regret at least gap times horizon over four.
BanditRLProof.LowerBounds.adversarialRegretLowerExpression_ge_quartertheorem randomRegret_ge_quarter_of_clippingDecomposition (horizon pullCount clippingCount : Nat) (gap randomRegret : Real) (hGap : 0 <= gap) (hPull : (pullCount : Real) <= (horizon : Real) / 2) (hClipping : (clippingCount : Real) <= (horizon : Real) / 4) (hSource : adversarialRegretLowerExpression horizon pullCount clippingCount gap <= randomRegret) : gap * ((horizon : Real) / 4) <= randomRegret
Complete when the deterministic finite-bandit vocabulary, traces, counts, reward sums, gap facts, and regret decompositions compile through the public root and external tests. Probabilistic algorithm laws belong to downstream chapters.