Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Appendix E — OLS Bandit with geometric forced-sample schedule

Definition
MostlyExplorationFree_GreedyBandit_Supplement_OLSBandit

by mikedeng1 · Nov 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

contextual-banditgreedy-algorithmleast-squaresp2o-batch-supp500p2o-gran-per-chapterp2o-plan-paperp2o-v1

For an integer q≥1q\ge1q≥1, paper arm i+1i+1i+1 has forced-sample times

Ti+1={(2n−1)Kq+j:n≥0, qi+1≤j≤q(i+1)}.\mathcal T_{i+1}=\{(2^n-1)Kq+j:n\ge0,\ qi+1\le j\le q(i+1)\}.Ti+1​={(2n−1)Kq+j:n≥0, qi+1≤j≤q(i+1)}.

At a forced time the designated arm is played. Otherwise, OLS estimates from forced samples retain the arms whose predicted reward is within h/2h/2h/2 of the highest forced-sample prediction. The arm with the largest all-sample OLS prediction among those retained is played. Both estimator families start at zero. Define ROB(n)R_{\rm OB}(n)ROB​(n) as the cumulative expected regret of this run from empty data, and specify a coefficient by

ROB(n)≤COBlog⁡n(n≥2).R_{\rm OB}(n)\le C_{\rm OB}\log n\qquad(n\ge2).ROB​(n)≤COB​logn(n≥2).

This makes the fallback algorithm in Theorem 3 concrete and ties its coefficient to its own regret, without importing constants from another paper.

Formalization Note The exponent is 2n2^n2n. OLS uses zero while its matrix is singular. At nonforced times a uniform permutation resolves ties; the forced sets are disjoint. The bound on the coefficient excludes n=1n=1n=1, where log⁡1=0\log1=0log1=0. Theorem 3 uses the explicitly stronger UniformOLSCoefficient: the same COBC_{\rm OB}COB​ must bound every fresh run on the shifted observation sequences, for every deterministic absolute start r≥0r\ge0r≥0 and horizon n≥2n\ge2n≥2. Since the source permits time-dependent noise laws, an unshifted-run bound alone does not control a restart. DISPROOF.md supplies a counterexample to that weaker reading; the uniform premise is the one required by p. 24's fresh-run argument.

Definition code
import Mathlib
import Definitions.Def_MostlyExplorationFree_GreedyBandit_Supplement_GreedyRun

namespace MostlyExplorationFree.GreedyBandit.Supplement

open Matrix MeasureTheory

/-- Equation (26), with paper arm i+1 represented by i. -/
def IsForced {K : ℕ} (q : ℕ) (i : Fin K) (t : ℕ) : Prop :=
  ∃ n j : ℕ, q * i.val + 1 ≤ j ∧ j ≤ q * (i.val + 1) ∧
    t = (2 ^ n - 1) * K * q + j

noncomputable def forcedTimes {K : ℕ} (q : ℕ) (i : Fin K) (t : ℕ) : Finset ℕ := by
  classical
  exact (Finset.Icc 1 t).filter (IsForced q i)

/-- Algorithm 4's two-stage decision: forced sampling, then screening on forced estimates,
then maximisation on all-sample estimates. Both estimator families start at zero. -/
noncomputable def olsChoice {Ω : Type*} {d K : ℕ} [NeZero K]
    (E : Environment Ω d K) (q : ℕ) (h : ℝ) (a : ℕ → Fin K) (t : ℕ) (ω : Ω) : Fin K := by
  classical
  let forced : Finset (Fin K) := Finset.univ.filter (fun i => IsForced q i t)
  let forcedScores := fun i => E.X t ω ⬝ᵥ olsOn E ω 0 i (forcedTimes q i (t - 1))
  let maxForced := Finset.univ.sup' Finset.univ_nonempty forcedScores
  let candidates := Finset.univ.filter (fun i => maxForced - h / 2 ≤ forcedScores i)
  exact if hf : forced.Nonempty then forced.min' hf else
    selectArm candidates
      (fun i => E.X t ω ⬝ᵥ olsOn E ω 0 i (playedOf a i (t - 1))) (E.W t ω)

noncomputable def olsArm {Ω : Type*} {d K : ℕ} [NeZero K]
    (E : Environment Ω d K) (q : ℕ) (h : ℝ) (t : ℕ) (ω : Ω) : Fin K :=
  Nat.strongRec (fun t ih => if t = 0 then 0 else
    olsChoice E q h (fun s => if hs : s < t then ih s hs else 0) t ω) t

/-- The property specifying the coefficient C_OB on a fresh Algorithm 4 run. -/
def OLSCoefficient {Ω : Type*} [MeasurableSpace Ω] {d K : ℕ} [NeZero K]
    (P : Measure Ω) (E : Environment Ω d K) (q : ℕ) (h COB : ℝ) : Prop :=
  ∀ n : ℕ, 2 ≤ n → regretOn P E (olsArm E q h) Set.univ n ≤ COB * Real.log n

/-- The same fresh-run coefficient at every absolute start time. The noises in the model
are independent but need not be identically distributed. A coefficient for start time zero
alone does not control the restarted run of Algorithm 3. -/
def UniformOLSCoefficient {Ω : Type*} [MeasurableSpace Ω] {d K : ℕ} [NeZero K]
    (P : Measure Ω) (E : Environment Ω d K) (q : ℕ) (h COB : ℝ) : Prop :=
  ∀ r : ℕ, OLSCoefficient P (E.shift r) q h COB

end MostlyExplorationFree.GreedyBandit.Supplement
Source
Bastani, Bayati & Khosravi, arXiv:1704.09011v8, pp. 48–49, equation (26), Algorithm 4; p. 24, definition of the OLS regret coefficient

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me