Proposition 5 — UCB regret (goal)
ProvedFoundationsRL.Bandits.ucb_regret_bound(Proposition 5, p. 28 — GOAL.) Assume for every , and fix a horizon and failure probability . The UCB algorithm follows the book's rule: at each round , if some action has never been sampled it plays one such action (the book's confidence radius is there, so any unsampled action is trivially "most optimistic"); once every action has been sampled at least once, it plays the optimistic action using the confidence radius of Eq. (2.19). Conditional on the event of Eq. (2.18) — that with probability at least the empirical mean concentrates around within this same radius, at every round and every sampled decision (the event is vacuous, per the book, at ) — UCB's regret satisfies
This is the chapter's central result: UCB attains the minimax-optimal rate (up to the factor), a quadratic improvement in over ε-Greedy's rate (Proposition 4), by adaptively narrowing exploration to actions whose confidence intervals remain wide, rather than exploring uniformly.
Formalization Note. As with Proposition 4, the "probability at least
" clause is formalized as the deterministic consequence of the
concentration event of Eq. (2.18) holding, following the book's own proof
("Let us condition on the event in (2.18) ... Whenever this occurs, we have that
... so the confidence
intervals are valid."); this event (an application of Hoeffding's inequality for
adaptive stopping times, Lemma 33) lies in the book's technical appendix, outside
this chapter. The UCB decision rule is stated in the book's own two clauses, not
collapsed into a single "maximize the upper confidence bound" rule: an unsampled
action's confidence radius is by Eq. (2.19), so the book always plays
an unsampled action first, and only compares finite upper confidence bounds once
every action has been sampled at least once. Correspondingly, Eq. (2.18) is only
assumed at sampled actions (), since the book's own bound is
vacuous (an inequality against ) otherwise. The proof route the book
takes — Lemma 7 (optimism) + Lemma 8 (potential) + the radius of Eq. (2.19) — is
available as the two milestone lemmas optimism_lemma and
confidence_width_potential_bound in this same mission.
import Mathlib import Definitions.Def_FoundationsRL_Bandits_regret import Definitions.Def_FoundationsRL_Bandits_pullCount import Definitions.Def_FoundationsRL_Bandits_confidenceRadius
namespace FoundationsRL.Bandits
/-- Proposition 5 (UCB regret, GOAL), Foster–Rakhlin p. 28. Assume `fStar π ∈ [0,1]`
for every decision `π`. Suppose `pi` is a realized UCB decision sequence following
the book's rule: at every round `t`, if some action is still unsampled then `pi t`
is one such unsampled action; once every action has been sampled at least once,
`pi t` maximizes the upper confidence bound `fhat t a + confidenceRadius` of
Eq. (2.19) among all actions `a`. Conditional on the event of Eq. (2.18) — that
this holds with probability at least `1 - δ`, restricted to rounds/actions where
the radius is meaningful (`n_t(π) ≠ 0`) since (2.18) is otherwise vacuous — the
UCB algorithm's regret satisfies `Reg ≲ √(AT log(AT/δ))`. The constant `C` is
universal: fixed once, before every instance parameter, matching the book's `≲`. -/
theorem ucb_regret_bound :
∃ C : ℝ, 0 < C ∧
∀ (A : ℕ), 0 < A → ∀ (fStar : Fin A → ℝ),
(∀ a : Fin A, fStar a ∈ Set.Icc (0 : ℝ) 1) →
∀ (piStar : Fin A), (∀ a : Fin A, fStar a ≤ fStar piStar) →
∀ (T : ℕ), 0 < T → ∀ (δ : ℝ), 0 < δ → δ < 1 →
∀ (pi : ℕ → Fin A) (fhat : ℕ → Fin A → ℝ),
-- if some action is still unsampled, UCB plays an unsampled action
-- (its upper confidence bound is `+∞` in the book).
(∀ t : ℕ, (∃ a : Fin A, pullCount pi t a = 0) → pullCount pi t (pi t) = 0) →
-- once every action has been sampled, `pi t` maximizes the upper confidence bound.
(∀ t : ℕ, (∀ a : Fin A, pullCount pi t a ≠ 0) → ∀ a : Fin A,
fhat t a + confidenceRadius T A δ (pullCount pi t a) ≤
fhat t (pi t) + confidenceRadius T A δ (pullCount pi t (pi t))) →
-- Eq. (2.18): the good event, holding with probability at least `1 - δ`,
-- restricted to sampled actions (vacuous otherwise in the book).
(∀ t ∈ Finset.range T, ∀ a : Fin A, pullCount pi t a ≠ 0 →
|fhat t a - fStar a| ≤ confidenceRadius T A δ (pullCount pi t a)) →
regret fStar piStar T (fun t a => if a = pi t then (1 : ℝ) else 0) ≤
C * Real.sqrt ((A : ℝ) * T * Real.log ((A : ℝ) * T / δ)) := by sorry
end FoundationsRL.Bandits
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
The declaration asserts the existence of a real constant such that the following holds for every choice of the data below. The constant is chosen first, uniformly, before any of the parameters , , , , , , are fixed.
Data and hypotheses.
- is a natural number with ; actions are elements of (the type ).
- is a function with (closed interval) for every action .
- is an action such that for every action (a maximizer of ; it need not be unique).
- is a natural number with .
- is a real number with .
- is an arbitrary sequence of actions indexed by all natural numbers (not only ).
- is an arbitrary family of real-valued functions on actions, one for each ; nothing ties to , to , or to any random rewards.
Three imported notions are used and are not unfolded here, since their defining code is not part of this declaration; they are used with the following signatures:
- , a natural number depending on the sequence , the round , and the action ;
- , a real number depending on , , and a natural number (it is evaluated below at , including possibly in the second hypothesis' right-hand side only when that action is sampled, but note it is also a total function so any value of is admissible);
- , a real number depending on , the action , the horizon , and a function .
The three hypotheses on are:
-
(Unsampled actions are played first.) For every (all rounds, not just ): if there exists an action with , then , i.e. the action played at round itself has pull count zero at round .
-
(UCB maximization once all actions are sampled.) For every : if for every action , then for every action ,
Ties are allowed; need only be a maximizer of .
- (Confidence event.) For every and every action with ,
No condition is imposed for actions with , nor for rounds . This is a deterministic hypothesis on the particular pair ; no probability space, no "with probability at least " statement, and no randomness appear anywhere in the declaration.
Conclusion. Under these hypotheses,
where the fourth argument of is the function assigning, at round , mass to the action and to every other action (a point mass at the played action, presented as a real-valued weight function), and , are cast from naturals to reals. The square root and logarithm are the real-valued total functions; since and , the argument exceeds , so the logarithm is positive and the radicand is positive.
Remarks on what is and is not asserted. The statement is a single inequality on one real number, for every instance satisfying the hypotheses; the order of quantifiers is . Nothing constrains on unsampled actions, nothing relates at different rounds, and nothing relates to any reward model except through the imported . Hypotheses 1 and 2 are required for all , while hypothesis 3 is required only for . Whether the hypotheses can be jointly satisfied, and what , and compute, depends entirely on the three imported definitions, which this declaration does not display.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.