BanditRLlib
Lean gate passed before this site build; local proof declarations are shown as compiled.

Verified bandit and reinforcement-learning theory in Lean

BanditRLlib

Learn bandit and reinforcement-learning theory beside its compiled Lean interfaces, search exact declarations, and contribute one reviewable lemma at a time.

Paper. ABRL: A Target-Faithful Autoformalization Harness and Lean 4 Library for Bandit and Reinforcement Learning Theory

Powered by two connected systems

One engine produces verified mathematics; one library makes it reusable.

Research system

ABRL Hierarchical Harness

Fixed mathematical target → route planning → source grounding → formal proof-DAG decomposition → one-leaf proving → Lean compiler → reviewer-gated memory.

Inspect the ABRL harness →
User-facing library

BanditRLlib

Compiled Lean declarations → searchable reusable library → textbook-aligned learning → LaTeX↔Lean formalization → community lemma intake.

Browse BanditRLlib →
flowchart LR
    Target["Mathematical target<br/>paper, textbook, or proposal"] --> Upper["ABRL upper layer<br/>planning and target fence"]
    subgraph Harness["ABRL · hierarchical autoformalization harness"]
        Upper --> Middle["middle layer<br/>route and obligation design"]
        Middle --> Lower["lower layer<br/>Lean proof construction"]
        Lower --> Compiler["Lean 4 compiler<br/>lake + Mathlib"]
        Compiler --> Reviewer["reviewer and full gate<br/>statement + evidence audit"]
        Reviewer -. "diagnostics and refinement" .-> Middle
    end
    Reviewer -->|accepted declarations| Library["BanditRLlib<br/>verified Lean library"]
    Library --> Learn["Learn<br/>ten-chapter book map"]
    Library --> Reuse["Reuse<br/>declaration catalogue"]
    Library --> Formalize["Formalize<br/>retrieval-grounded candidates"]
    Library --> Contribute["Contribute<br/>reviewed lemma packets"]
    Formalize -. "candidate packet" .-> Upper
    Contribute -. "proposal packet" .-> Upper
A research target enters ABRL and returns as reusable, reviewer-gated BanditRLlib mathematics · editable Mermaid source

BanditRLlib, three ways to use it

01

For students

Learn from a Lean-aligned textbook

Follow ten chapters from finite bandit bookkeeping through concentration, stochastic and adversarial algorithms, stopping times, and finite-horizon RL. Read intuition and mathematics before opening the exact type.

Follow the teaching path →
02

For library users

Find the exact lemma you need

Search all 7,581 indexed declarations, filter by chapter and kind, inspect module imports, and distinguish compiled endpoints from broader routes that remain partial or blocked.

Search the declaration catalog →
03

For contributors

Add knowledge from another field

Submit a structured lemma packet with the source theorem, natural-language statement, LaTeX, Lean draft, dependencies, and honest verification status. Live Formalization already exports the same machine-readable format for ABRL review.

Read the contribution guide →

Live source inventory

The numbers below are generated from the current internal BanditRLProof/ namespace at build time. BanditRLlib is the public library name; the mature namespace is intentionally unchanged.

576Lean source modules, including the root aggregator
7,581Indexed definitions, structures, theorems, and lemmas
5,513Theorems and lemmas
0Declarations containing sorry or admit
Two levels of completion. A local declaration can compile while a broader textbook or upstream-compatible route remains partial. The site reports both levels separately; theorem cards and paper references are never counted as local proofs.

What this project is building

Bandit and reinforcement-learning proofs mix finite combinatorics, probability kernels, conditional expectation, concentration, optimization, and algorithm-specific bookkeeping. ABRL organizes that work into small Lean-checkable leaves. An automated hierarchy proposes and proves leaves; reinforcement-learning ideas help select promising proof routes; bandit objectives allocate effort among those routes; and Lean is the final certificate.

The current tree is no longer only a finite-bandit foundation. It contains concrete ETC, ordinary UCB, a conservative bounded generated KL-UCB route, stationary Thompson, EXP3, and Tsallis endpoints; an OFUL chain reaching self-normalized confidence and one horizon-free policy with all-time, all-horizon, and stopping consumers, plus a separately labeled horizon-indexed expected-consistency family; and a finite-horizon RL development that now reaches a canonical known-reward Hoeffding UCBVI-CH high-probability cumulative episode pseudo-regret theorem and its failure-aware expected consumer on one generated adaptive process. Natural-causal consistency and stopping-time RL remain independent compiled extensions. Bernstein/minimax and stochastic-reward UCBVI, sharp KL-Chernoff and asymptotically optimal KL-UCB refinements, full BwK, preference, federated, and several modern routes remain partial, planned, or blocked at named interfaces.

Identity boundary. ABRL is the proving system and research project. BanditRLlib is the verified Lean library, website, formalization workspace, and contribution interface produced by that system.

Formalized textbook map

Book map: ten routes through bandits and RL

The curriculum is anchored in Lattimore and Szepesvári's Bandit Algorithms, with algorithm-specific papers for OFUL, Tsallis-INF, and UCBVI. It is a source-mapped learning path, not a chapter-for-chapter reproduction of one book. Each card reports online-edition pages and the chapter's canonical compiled boundary.

Compiled 1. Finite bandits, traces, and regret Canonical scope compiled · 7 compiled · 3 blocked Ch. 1 and Ch. 4, especially §4.5 · online pp. 8–16 and 56–69; regret decomposition pp. 62–63 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.
Compiled 2. Probability, kernels, filtrations, and concentration Canonical scope compiled · 6 compiled Ch. 2, Ch. 3, and Ch. 5 · online pp. 18–42, 46–54, and 74–81 Measure-theoretic infrastructure for generated histories, conditional reward laws, martingale differences, posterior kernels, stopping times, and concentration.
Compiled 3. Explore-Then-Commit Canonical scope compiled · 3 compiled Ch. 6 · online pp. 91–96 Round-robin exploration, empirical means, measurable commit choices, wrong-commit tails, and expected-regret assemblies under bounded or sub-Gaussian arm laws.
Compiled 4. UCB: confidence events to regret Canonical scope compiled · 5 compiled · 1 partial Ch. 7; KL-UCB extension in Ch. 10 · online pp. 102–111; KL-UCB pp. 133–141 History-based ordinary-UCB and KL-UCB scores, count thresholds, generated policies, arm streams, same-trajectory confidence, finite-arm reward kernels, and expected regret.
Compiled 5. OFUL, self-normalized confidence, and stopping times Canonical scope compiled · 8 compiled Ch. 19–20; stopping times in §3.3 · online pp. 238–262; stopping-time basics pp. 50–54 The scoped canonical finite-action linear-bandit route compiles from elliptical potential and self-normalized ridge confidence through one horizon-free generated OFUL policy with all-horizon regret and stopping consumers, plus a separately identified horizon-indexed expected-consistency family.
Compiled 6. Thompson sampling and Bayesian regret Canonical scope compiled · 6 compiled · 1 partial Ch. 34 and Ch. 36 · online pp. 421–436 and 460–475 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.
Compiled 7. EXP3 and adversarial concentration Canonical scope compiled · 7 compiled Ch. 11–12 · online pp. 148–172 The scoped canonical generated EXP3 route compiles from exponential-weight potentials and importance-weighted conditional moments through horizon-tuned expected and best-arm high-probability endpoints, plus a distinct fixed-process all-positive-prefix realized-regret event and a sparse-loss extension.
Compiled 8. Tsallis-FTRL, corruption, and nonstationarity Canonical scope compiled · 4 compiled Ch. 28 (FTRL and mirror-descent foundation) · online pp. 327–344 The scoped canonical half-Tsallis FTRL route compiles from finite-simplex minimizers and one-step stability through a measurable scheduled generated trajectory, score alignment, expected self-bounding, and a finite-arm IID bounded reward-law logarithmic regret terminal; corruption and nonstationary routes remain labelled extensions.
Compiled 9. Finite-horizon reinforcement learning Canonical scope compiled · 7 compiled Ch. 38 · online pp. 512–538 Finite MDPs, Bellman optimality, generated trajectories and occupancy regret, plus a canonical known-reward Hoeffding UCBVI-CH route whose recurrent planner, same-source confidence, optimism, raw cumulative episode pseudo-regret, high-probability terminal, and failure-aware expectation consumer share one adaptive generated process.
Planned 10. Automation, resources, and open routes Canonical scope planned · 2 blocked · 7 compiled · 2 partial · 1 planned Parts VII–VIII as a background index · online pp. 358–538 The proof harness, task vocabulary, resource stopping leaves, literature registry, a partial source-frozen delayed-feedback audit, and planned BwK, preference, robust, federated, neural-bandit, and sharp KL-asymptotic work.

Chapter-by-chapter source spine

Part IV: Lower Bounds

This separate layer follows Chapters 13–17 of Bandit Algorithms in order. It does not change the ten-chapter Book Map or imply that the whole textbook is complete.

Chapter 13 Partial Lower Bounds: Basic Ideas 155–159 print · 189–194 PDF

The Chapter 13 semantic and deterministic slice and Chapter 15 same-policy history KL bridge are compiled. Theorem 13.1 remains blocked on the Gaussian regret/event and caller-free minimax terminal.

Chapter 14 Partial Foundations of Information Theory 160–169 print · 195–206 PDF

The source-faithful §14.2 relative-entropy and Bretagnolle–Huber spine is compiled. Entropy/source coding in §14.1 and full sub-sigma-algebra data processing remain outside this scoped gate.

Chapter 15 Partial Minimax Lower Bounds 170–176 print · 207–214 PDF

Lemma 15.1 now compiles for finite arms, a countably generated reward space, arbitrary Markov arm laws, and one common randomized history policy. The unit-Gaussian dependency slice also compiles; Theorem 15.2 and the 1/27 minimax terminal remain blocked.

Chapter 16 Partial Instance-Dependent Lower Bounds 177–184 print · 215–223 PDF

Definition 16.1, Theorem 16.2, Lemma 16.3, and Theorem 16.4 are source-frozen. Generic consistency, d_inf, Gaussian-candidate, eventual power, and eventual log-growth leaves compile; the bandit information, liminf, and finite-time terminals remain blocked.

Chapter 17 Partial High-Probability Lower Bounds 185–190 print · 224–230 PDF

Claim 17.5's first-moment witness and reusable threshold, event-subtraction, and deterministic Eq. (17.8) algebra compile. The stochastic tail terminals and clipped-normal adversarial construction remain blocked.

Open the Part IV spine

People behind the project

Authors

The project authors are listed separately from future community contributors. Roles are intentionally neutral unless contribution metadata is explicitly recorded.

Dake Bu

@DakeBU · Project author

Project author.

Ji Cheng

@jicheng9617 · Project author

Project author.

Bo Xue

Project author

Project author.

Atsushi Nitanda

Project author

Project author.

Hau-San Wong

Project author

Project author.

Qingfu Zhang

Project author

Project author.

Meet the contributors

Reproduce the formalization

Installation

01

Install Lean

Install Git, Python 3, and Lean through Elan. The repository pins leanprover/lean4:v4.29.1.

02

Clone the repository

git clone https://github.com/DakeBU/Auto-Bandit-RL-Proof-In-Sleep.git
cd Auto-Bandit-RL-Proof-In-Sleep
03

Run the proof gate

lake update
python3 tools/bandit.py check

Full installation guide

A reviewable path into the library

How to contribute

  1. Choose one claim.Start from a book, paper, proof gap, or existing chapter and record the exact source and assumptions.
  2. Agree on the statement.Open a lemma proposal before a large formalization so scope, namespace, and dependencies can be reviewed.
  3. Compile and explain.Add the Lean declaration, tests, plain-English statement, proof idea, and an honest status.
  4. Submit for integration.The project gate and maintainer review decide when a result becomes indexed as compiled.

Progress without invented percentages

This chart counts the explicit milestones in the website's implementation map. It does not estimate what percentage of all bandit or RL mathematics has been formalized.

pie showData
  title Implementation-map milestones (not a percentage of all mathematics)
  "Compiled local endpoint" : 60
  "Partial route" : 4
  "Planned" : 1
  "Blocked" : 5
  "Stated, proof incomplete" : 0
Status of the explicitly mapped theorem-route milestones · editable Mermaid source

Recommended reading order

Students can take a short stochastic route through Foundations → Probability → ETC → UCB, a linear route through UCB → OFUL, an adversarial route through EXP3 → Tsallis-FTRL, or continue from Probability and OFUL stopping-time ideas into finite-horizon RL. Thompson sampling branches from posterior kernels.

flowchart LR
  Start["New to Lean or bandit/RL proofs"] --> F["1. Foundations"]
  F --> P["2. Probability layer"]
  F --> ETC["3. ETC"]
  ETC --> UCB["4. UCB"]
  P --> UCB
  UCB --> OFUL["5. OFUL + stopping times"]
  P --> TS["6. Thompson sampling"]
  F --> E["7. EXP3"]
  P --> E
  E --> T["8. Tsallis-FTRL"]
  P --> T
  P --> RL["9. Finite-horizon RL"]
  OFUL --> RL
  UCB --> RL
  RL --> Frontier["10. Frontier + contribution workflow"]
  T --> Frontier
  TS --> Frontier

  IDE["Research IDE: LaTeX ↔ Lean ↔ tree"] -. "use beside every chapter" .-> F
  IDE -.-> RL
Recommended learning path through the formalization · editable Mermaid source

BanditRLlib and Live Formalization share one contribution language

The workspace renders editable LaTeX, loads reviewed LaTeX-to-Lean mappings, visualizes declaration dependencies, and can call the pinned Lean compiler through a loopback-only companion server. It can now export a versioned lemma packet for community review; a future authenticated compiler can submit that same packet directly as a proposed contribution.

Static-site boundary. GitHub Pages does not compile Lean or send source to a hosted proving service. Compilation and provider-backed formalization require the explicitly started loopback-only local companion server.