Lean gate passed before this site build; local proof declarations are shown as compiled.Lean-verified build · exact declarations linked.
Teaching chapter 06 of 10 · Canonical route compiled
6. Thompson sampling and Bayesian regret
The scoped stationary finite-arm Thompson route compiles from posterior kernels and probability matching on the actual recursive generated history through clipped-UCB decomposition, latent-stream confidence, and an explicit Bayesian regret terminal.
How to read the status. It describes this page's canonical local Lean route, not completion of the cited textbook chapter or every extension listed below.
Orientation
Who should read this. Best read after the Probability layer.
Learning goals
Read a posterior as a kernel from histories to environments.
Transport conditional action-law equality onto the generated trajectory.
Understand why one compiled stationary theorem is not a universal posterior-sampling result.
Textbook crosswalk
Read the mathematics before the Lean interface
The Book Map is a curated formalization curriculum anchored in Bandit Algorithms, not a chapter-for-chapter reproduction of one book. Visible page labels use the numbered pages of its free online edition; source buttons use the PDF viewer's physical page index, which includes front matter and can therefore be larger. Companion papers cover algorithm-specific results.
Probability matching turns posterior uncertainty about the best arm into an exploration policy.
Model
A k-armed Bayesian bandit environment with prior Q and arm laws indexed by the latent environment.
Assumptions
For every environment and arm, the centered reward law is 1-sub-Gaussian and its mean lies in [0,1]; optimal-arm ties use the algorithm's fixed rule.
Algorithm parameters
Prior Q, arm count k, and horizon n.
Regret notion
Bayesian regret BR_n, averaged over the prior, observations, and policy randomization.
Guarantee
BR_n is at most C√(kn log n) for a universal constant C.
Source mathematical statement.Formula renderer unavailable; readable fallback: In the stated Bayesian finite-armed setting, Thompson sampling has square-root-horizon Bayesian regret up to a logarithmic factor.\[BR_n\le C\sqrt{kn\log n}\quad\text{for the theorem's Bayesian finite-armed model and universal }C.\]Swipe to read the full formula →
BanditRLlib relationship. BanditRLlib constructs a canonical posterior/kernel and generated stationary latent-arm-stream process. Its compiled terminal has explicit bounded-reward and variance terms and is not a blanket frequentist guarantee for all Thompson variants.
The mathematical content is restated in this site's notation; wording is ours. See online p. 461 (Chapter 36, §36.1) in the linked source for the original statement and full assumptions.
Natural-language and Lean side by side
The mathematical readings are explanatory summaries. The exact generated Lean statement and its source link remain authoritative for hypotheses, types, constants, and indexing.
A curated route through definitions, key bridges, and canonical terminals stays visible. 3 additional dependency, extension, or research-frontier notes are grouped below.
Mathematics ↔ Lean
The canonical posterior is the conditional environment law
Plain-English statement. If an environment and observed history have the canonical prior-likelihood joint law, then the canonical posterior kernel equals the conditional law of the environment given that history almost everywhere.
Mathematical reading.Formula renderer unavailable; readable fallback: If an environment and observed history have the canonical prior-likelihood joint law, then the canonical posterior kernel equals the conditional law of the environment given that history almost everywhere.\(\Pi(\cdot\mid H)=\mathcal L(E\mid H)\quad\text{a.e.}\)Swipe to read the full formula →
Intuition
A posterior is a measurable kernel from histories to environments; the theorem identifies that constructed kernel with the measure-theoretic conditional distribution.
Why it is needed
Probability matching is valid only after the algorithmic posterior is tied to the actual environment-history law.
Place in the proof
It is the posterior-law root of the Chapter 6 proof DAG.
Proof and Lean reading notes
Proof idea
Use uniqueness of regular conditional distributions under the equality of the observed pair pushforward and the canonical prior-likelihood joint measure.
Lean reading notes
The theorem requires Standard Borel and nonempty environment, measurable environment/history maps, a probability prior, a Markov likelihood kernel, and exact pair-law equality. It does not accept an arbitrary posterior kernel.
Plain-English statement. On the actual globally recursive Thompson trajectory, the action at round n+1 conditioned on the trajectory's own finite history through n probability-matches the posterior best action.
Mathematical reading.Formula renderer unavailable; readable fallback: On the actual globally recursive Thompson trajectory, the action at round n+1 conditioned on the trajectory's own finite history through n probability-matches the posterior best action.\(\mathcal L(A_{n+1}\mid H_n)=\mathcal L(a^\star(E)\mid H_n).\)Swipe to read the full formula →
Intuition
The uniform reference policy supplies full support, so the posterior sampler can be recursively coupled without assuming a second unrelated action process.
Why it is needed
Bayesian regret decomposition needs matching for the actions that the generated algorithm actually takes.
Place in the proof
It is the bridge from the canonical one-step sampler to the generated finite-history score identities.
Proof and Lean reading notes
Proof idea
Build the recursive history algorithm and canonical environment trajectory kernel, extract the actual finite history, apply density and conditional-law invariance, and identify the successor coordinate.
Lean reading notes
The canary restates the complete algorithm, trajectoryKernel, actualMeasure, actualHistory, and nextAction let chain. It is not an adjoined sampler theorem.
Plain-English statement. Choosing the measurable bounded clipped-UCB history score specializes the comparator-relative decomposition to confidence terms suitable for stationary reward tails; optimality is imposed at the final Bayesian-regret terminal.
Mathematical reading.Formula renderer unavailable; readable fallback: Choosing the measurable bounded clipped-UCB history score specializes the comparator-relative decomposition to confidence terms suitable for stationary reward tails; optimality is imposed at the final Bayesian-regret terminal.\(\mathbb E R_n^{\mathrm{Bayes}}=\mathbb E\sum_{t<n}(\mu_{a^\star}-\mathrm{clip}(U_t(a^\star)))+\mathbb E\sum_{t<n}(\mathrm{clip}(U_t(A_t))-\mu_{A_t}).\)Swipe to read the full formula →
Intuition
Clipping keeps scores inside the known mean range while empirical means plus widths retain optimism with high probability.
Why it is needed
This is the exact bridge from probability matching to concentration and the final finite regret bound.
Place in the proof
It consumes the history-score decomposition and feeds the two stationary clipped-score expectation inequalities.
Proof and Lean reading notes
Proof idea
Prove the clipped score is measurable and uniformly bounded, automatically obtain the needed integrability, and instantiate the general history-score equality.
Lean reading notes
The mean surface must be measurable and contained in [l,u]. The theorem is comparator-relative algebra and does not itself assert selector optimality or provide the stationary concentration bounds.
Plain-English statement. For the canonical stationary latent-arm-stream Thompson process, expected Bayesian mean regret is at most (2K+1)(u-l) plus 8 times the square root of sigma-squared K n log n.
Mathematical reading.Formula renderer unavailable; readable fallback: For the canonical stationary latent-arm-stream Thompson process, expected Bayesian mean regret is at most (2K+1)(u-l) plus 8 times the square root of sigma-squared K n log n.\(\mathbb E[R_n^{\mathrm{Bayes}}]\le(2K+1)(u-l)+8\sqrt{\sigma^2Kn\log n}.\)Swipe to read the full formula →
Intuition
Posterior sampling matches the law of the optimal action, so a carefully chosen confidence decomposition can compare the sampled and optimal actions in expectation.
Why it is needed
It is the final stationary theorem of the local Thompson route and demonstrates that posterior-law construction reaches an actual regret endpoint.
Place in the proof
It closes the scoped stationary canonical Chapter 6 route while BRL-TS-BAYES-001 and direct upstream identity remain separate.
Proof and Lean reading notes
Proof idea
Construct actual and reference trajectories, prove posterior-action conditional-law equality, integrate the Bayesian regret decomposition, apply clipped-UCB bounds, and discharge stationary reward tails.
Lean reading notes
The exact statement requires a probability prior, Standard Borel nonempty environment, finite nonempty arms, stationary Markov reward kernel, measurable bestAction, pointwise `IsOptimalMeanSelector mean bestAction`, a measurable mean surface, means in [l,u], centered sub-Gaussian MGF, nonzero variance proxy, and the canonical augmented latent stream. It is not a universal or sharp-asymptotic Thompson theorem.
Plain-English statement. For the canonical one-step sampler, the sampled action conditioned on history has the same law as the best action of the latent environment conditioned on that history.
Mathematical reading.Formula renderer unavailable; readable fallback: For the canonical one-step sampler, the sampled action conditioned on history has the same law as the best action of the latent environment conditioned on that history.\(\mathcal L(A\mid H)=\mathcal L(a^\star(E)\mid H).\)Swipe to read the full formula →
Intuition
Draw an environment from the posterior and act optimally for that draw; pushing the posterior through bestAction is exactly the posterior optimal-action law.
Why it is needed
This is the local probability-matching identity later transported to every successor action of the recursive algorithm.
Place in the proof
It consumes posterior-kernel correctness and feeds the recursive trajectory sampler.
Proof and Lean reading notes
Proof idea
Construct the canonical sampler measure, apply posterior equals conditional environment law, and map both sides through the measurable best-action selector.
Lean reading notes
Standard Borel/nonempty environment and action spaces, a probability prior, Markov likelihood, and measurable bestAction are explicit. This is one-step matching, not yet a generated multi-round regret theorem.
Plain-English statement. Expected comparator-relative mean regret on the generated trajectory splits exactly into a selector-score gap and a selected-action score gap for any integrable finite-history score; the Bayesian-regret reading additionally requires a mean-optimal selector.
Mathematical reading.Formula renderer unavailable; readable fallback: Expected comparator-relative mean regret on the generated trajectory splits exactly into a selector-score gap and a selected-action score gap for any integrable finite-history score; the Bayesian-regret reading additionally requires a mean-optimal selector.\(\mathbb E R_n^{\mathrm{Bayes}}=\mathbb E\sum_{t<n}(\mu_{a^\star}-U_t(a^\star))+\mathbb E\sum_{t<n}(U_t(A_t)-\mu_{A_t}).\)Swipe to read the full formula →
Intuition
Add and subtract the same score; probability matching makes the expected score of the sampled action equal the expected score of the latent best action.
Why it is needed
It turns posterior-law equality into the two error terms that concentration can control.
Place in the proof
It follows recursive probability matching and precedes the concrete clipped-UCB specialization.
Proof and Lean reading notes
Proof idea
Apply the finite-history conditional-distribution equality to each score, integrate the score identity, sum over the finite horizon, and regroup the mean differences.
Lean reading notes
The theorem retains separate integrability hypotheses for selector means, selected means, selected scores, and selector scores. The decomposition is valid for any measurable selector; `trajectoryBayesMeanRegret` is genuinely Bayesian pseudo-regret only when `IsOptimalMeanSelector mean bestAction` is available.
Plain-English statement. For the canonical latent-stream environment, every generated reward coordinate agrees almost everywhere with the next unused reward coordinate of the selected arm's stationary stream.
Mathematical reading.Formula renderer unavailable; readable fallback: For the canonical latent-stream environment, every generated reward coordinate agrees almost everywhere with the next unused reward coordinate of the selected arm's stationary stream.\(Y_t=Z_{A_t,N_{A_t}(t)}\quad\text{for all }t\text{ a.e.}\)Swipe to read the full formula →
Intuition
A latent infinite reward stream for each arm turns adaptive sampling into coordinate selection without changing the actual recursive policy.
Why it is needed
Stationary empirical-mean tails must apply to the rewards actually observed by Thompson sampling, not to an independent offline sample.
Place in the proof
It connects the recursive generated trajectory to arm-stream concentration and clipped-score expectation bounds.
Proof and Lean reading notes
Proof idea
Use the canonical step-kernel construction and induction over finite trajectory prefixes to identify each feedback draw with rewardFromArmStream at the selected pull count.
Lean reading notes
The equality is almost everywhere under the canonical generated trajectory kernel for each latent environment/stream input. It is a support/alignment theorem, not independence stated by fiat.
Open the canonical completion definition and blockers
Complete in the stationary canonical textbook scope when a probability prior and likelihood construct the posterior kernel, a measurable selector with the explicit pointwise IsOptimalMeanSelector contract gives posterior best-action pushforward and actual-recursive-trajectory probability matching, score transport yields Bayesian and clipped-UCB decompositions, a stationary Markov reward kernel constructs the augmented latent arm stream with a.e. generated-reward support, upper/lower confidence consumers compile, and the generated trajectory satisfies E[R_n^Bayes] <= (2K+1)(u-l)+8 sqrt(sigma^2 K n log n) under the exact optimality, measurable bounded-mean, and centered sub-Gaussian assumptions.
Remaining blockers
No remaining blocker inside this stationary canonical scope: the public canary types probability matching on the actual recursive history and concretely instantiates the final theorem with a one-arm stationary Gaussian Markov source while explicitly proving its mean-optimal selector contract. The items below remain separate extensions.
Chapter implementation status
The compact summary keeps the reading route visible. Open it for source-linked declarations and exact remaining gaps.
Add posterior-law producers for broader models. Close the exact upstream compatibility gate.
Open boundaries
Arbitrary nonstationary posterior models, contextual or linear Thompson sampling, posterior-sampling RL, and user-supplied posteriors without a law producer remain extensions.
Sharp problem-dependent or asymptotically optimal constants are not claimed by the compiled stationary terminal.
Exact LeanMachineLearning declaration/toolchain identity remains independently blocked; LML cards are retrieval evidence, not imported proof terms.