Adaptive Threshold Estimation

A population of coins has hidden biases. How many flips does it take to
estimate the fraction of coins that favour heads? This repository answers the
question up to constant factors. It holds a research paper, proofs checked in
Lean 4 with Mathlib, and a Python toolkit.
Start here
The problem and the main result
Estimate the fraction of a population of coins whose probability of heads
exceeds one half. Each fresh coin has an independent hidden gap $D\sim\mu$
in $(0,1/2]$ and a hidden sign. An algorithm sees only its randomness and
coin flips; it may create, revisit, and interleave coins. Every flip counts
toward the expected-work budget.
Let $R_\mu(B)$ be the minimax root-mean-square error over all measurable sign
laws at uniform expected budget $B\ge1$, and define
$\omega_\mu(h)=\mathbb E_\mu[\min(1,h/D)]$ for $h>0$. Then
\frac{1}{6}\,\omega_\mu(B^{-1/2})
\;\le\; R_\mu(B)
\;\le\; 12\,\omega_\mu(B^{-1/2}).
Both bounds are proved in Lean for the observable adaptive experiment.
The lower constant $1/6$ is sharp: no larger constant holds for every gap
law and budget. The upper constant $12$ is not optimized: a
numerical study puts the
actual worst ratio of the algorithm behind it near $5.4$. One upper algorithm works
for every gap law without knowing $\mu$. The v6 paper states $12$ and
proves it in Appendix AB; the frozen upper target states $512$. The
lower theorem,
upper theorem, and
model and scope give the
precise statements. The original lower theorem, with the constant $1/64$,
is kept as a frozen target.
Results at a glance
Each row is a summary. docs/RESULTS.md states the exact
assumptions, constants and Lean theorem behind it.
For every sign law. The worst case is over every way the sign can depend
on the gap, at a fixed gap law $\mu$.
| Result |
Status |
Details |
| For $B\ge1$, the sharp universal minimax RMS lower bound is $\omega_\mu(B^{-1/2})/6$ in the ordinary model and both magnitude oracles. Four fresh flips attain equality at $B=4$ and $\mu=\delta_{1/2}$. |
Lean-checked |
Scope · written proof in Appendix AA of the paper |
| For $B\ge25$ the best universal lower constant lies between $0.175198$ and $0.186752$; its exact value is open. |
Lean-checked |
Scope · outline in Appendix AA of the paper |
| One algorithm that knows only the budget attains RMS error at most $12,\omega_\mu(B^{-1/2})$ ($512$ in the frozen target). |
Lean-checked |
Scope · written proof in Appendix AB of the paper |
| Confidence radius of order $\omega_\mu\bigl(\sqrt{\log(1/\delta)/B}\bigr)$ |
Lean-checked |
Scope |
| An unbiased estimator with finite variance and expected work exists exactly when $I=\mathbb E_\mu[D^{-1}]$ is finite; the best variance–work product lies between $I^2/16$ and $713I^2$ |
Lean-checked |
Scope · 713 |
| Extensions to unknown gap laws under a stochastic envelope, smooth densities and observed outer states, and lower bounds when magnitudes are revealed |
Lean-checked |
Envelope · Densities · States · Oracles |
When positives are rare. The fraction is known to be at most $\rho$, and
the gap law is known unless a row says otherwise.
| Result |
Status |
Details |
| For every gap law, every rarity $0<\rho\le1/4$ and every budget $B>0$, the risk $R$ satisfies $10^{-17}\mathcal K\le R\le28000,\mathcal K$, where $\mathcal K$ is an entropy–tail selection functional |
Lean-checked |
Scope |
| A closed formula $Q$ with $\mathcal K\le Q\le\frac{31}{20}\mathcal K$; the least possible factor is the unique root of a scalar equation, which Lean places in $(\sqrt2,\frac{31}{20})$ and an exact-rational check puts at about $1.4626$ |
Lean-checked; lower decimal end Lean-checked, upper by rational certificate |
Scope · Factor |
| Critical quadratic law $F(d)=(4d)^2$: the rate is $\min(\rho,\sqrt{\rho L(1+\log L)/B})$ with $L=1+\log(1/\rho)$, which refutes a proposed characterization by a simpler modulus $\Psi$ |
Lean-checked |
Scope |
| Power-law gaps: the rates for exponents below and above two |
Lean-checked |
Above two · One to two · Below one |
$\Psi$ still bounds the risk from below for every gap law, $0<\rho\le1/4$ and $B>0$, with coefficient $1/8192$ (Proposition prop:psi-null), and the confidence radius with coefficient $10^{-17}$ |
Lean-checked |
Scope |
| $\Psi$ in closed form within a factor $\sqrt2$, and one power-law rate with constants independent of the exponent |
Lean-checked |
Scope |
| A stopping program with an exact dual, and certificates within a factor sixteen of the minimax risk |
Lean-checked |
Scope |
| Hard caps on the number of flips; fixed-confidence radius of order $\mathcal K(B/\log(1/\delta))$; a time-uniform rate for a known law and a lower bound of the same order, not composed in Lean |
Lean-checked |
Caps · Confidence |
| Unknown gap law: the same time-uniform rate within a supplied finite family of laws |
Lean-checked |
Scope |
| Unknown gap law: the same rate for arbitrary laws, after an onset that depends on the law |
Lean-checked |
Theorem and construction · Publication evidence |
Scope and review
The v6 paper tracks 33 results. Lean checks 32 of them; 1 has a paper proof only: the critical-window simplification and its asymptotic interpretation. The results guide lists every result with its status and evidence. Both are generated from the status source.
What the verification does and does not cover:
- Lean checks the linked statements and the definitions they are stated with.
Whether those definitions model the paper’s experiment is a separate question;
the model-fidelity brief sets the two side by side.
- AI agents carried out the research and formalization under David Iach’s
direction. The work has had AI review and no independent external specialist
review.
- The constants are explicit but conservative. A coefficient such as $10^{-17}$
proves a rate; it is not a practical guarantee.
- Numerical experiments are supporting evidence, not proofs. The Python
toolkit is tested and is not formally verified.
Lean also checks the
finite-law selection approximation.
It is not counted above, because the paper does not describe it.
The opt-in numerical certificate path
lets the Lean kernel check individual outputs of the toolkit. It covers
finite-law objectives and oracles,
zero-residual envelopes, rounding and conditional transfer,
and bounded global-selection outputs.
Solver transcripts, other selection entry points and concrete planners
remain open in
#85;
stochastic execution is
#86.
Repository map
Current material:
Historical and locked material, kept unchanged. It explains how the project
started and is not a starting point:
| Path |
What it is |
| BRIEF.md |
The original overnight assignment for the AI agents |
FROZEN.sha256, TIER3_FROZEN.sha256 to TIER6_FROZEN.sha256, FREEZE_LOG.md |
Hash locks on frozen statements and tools, and the log of changes to them |
| inputs/ |
The imported starting material, preserved byte for byte |
constants/ |
The constant-scoring harness of the original assignment |
| proposals/ |
Proposals to change frozen items |
| docs/process/ |
The process record: method, provenance and run logs |
Project files at the top level:
| Path |
What it is |
| CONTRIBUTING.md, AGENTS.md |
Setup, where to edit and how to check a change; the second is the working guide for AI agents |
| CITATION.cff, LICENSE, LICENSE-CC-BY-4.0, LICENSES.md |
How to cite the work, the two licenses and which files each covers |
requirements.txt |
Pinned Python packages for the tools and the numerical checks |
.github/ |
The CI workflows, such as checks.yml, and lean_ci.py, which selects the Lean audits a change needs |
.gitattributes, .gitignore |
Byte-exact storage of tracked files, which the hash locks rely on, and ignored build output |
Check the proofs
Install Python 3.12 and Lean’s elan tool manager. The repository pins its
Lean toolchain and Mathlib revision.
To check both directions of the main RMS law:
git clone https://github.com/davidiach/adaptive-threshold-estimation.git
cd adaptive-threshold-estimation
python -m pip install -r requirements.txt
cd lean
lake exe cache get
cd ..
python tools/verify_sharp_rms.py
python tools/verify_upper_scale.py
python tools/verify_blind_upper_components.py --sequential
python tools/verify_tier6.py --sequential --require-complete
The first command checks the sharp lower bound with the constant $1/6$,
the second the upper bound with $12$, the third the frozen upper target
with $512$, and the fourth the original frozen lower target with $1/64$. Each one builds what it needs, restates the
target types exactly and reports the axioms the proofs use.
The verification guide covers the other theorems, exact target
types, transitive-axiom audits, source hashes, and numerical checks.
GitHub Actions runs the research and numerical
checks on pull requests and pushes to main. It selects Lean audits from the
files changed by the entire PR or push. Changes to project proofs or the pinned
toolchain run all four Lean jobs. On pull requests these jobs reuse compiled
modules from earlier runs and rebuild only what changed; pushes to main
build from scratch. To run the full CI audit suite on any branch, with a
build from scratch, start Reproducible checks manually from the Actions tab.
VERIFY.md also lists two intermediate entropy-tail audits
available for local reproduction.
Use a disposable checkout for reproduction: some checks write diagnostic files.
Open work
- Paper proof only, now Lean-checked. The one tracked result with a
paper proof only, the critical-window simplification that closes
v6 §14.8 with its
asymptotic interpretation, is Lean-checked since 20 November 2026
(record). The v6 status table
still lists it as a paper proof until the next manuscript update.
- Smaller paper and guide claims. Twelve claims that the paper or the
guides stated with only a written proof, a numerical check or an existential
constant are Lean-checked since 20 November 2026, among them the critical
theorem with explicit constants, the sharpness of the unbiased coefficient
$1/16$ and the lower end of the bracket for the sharp quantile factor
(record); the upper end, and
with it the whole sharp-factor theorem, is Lean-checked since 21 November
(record). Three of the four
pilot-feedback separations, Lean-proved inside their research packages, are
in the audited library too: the precommitted and one-update classes
(record) and, since 21 November,
one update at a stopping time
(record). The fourth, with two
such updates, needs its integer certificate split before CI can check it.
Since 21 November 2026 Lean also checks the impossibility half of
Proposition
prop:bounded, states the explicit constants $15/(256\sqrt2)$,
$1/256$ and $28\rho$ as exact targets, and checks both corollaries of the
finite-gap manuscript, the stopped time-uniform remark, the threshold form
of the target for every law, the zero-atom split, the explicit fixed-cap
estimate, the bias-subtraction remark of Appendix H, the common-pair RMS
bound at the critical law, the restricted-class coefficient $1/6$, the
strictness of the sharp bound for $B\ne4$, the global-cut bound, and
Proposition prop:psi-null with its corollary $R\ge\Psi(B^{-1/2})/8192$,
which proves the obstruction premise of the transfer theorems for every
gap law, its confidence form and the exact-power-law confidence rate above
two, the three-piece form and ordered constants of the entropy-tail
law, the paper’s noninterval optimal assignment, the stopping-program
factor $3\sqrt7/2$, the fixed-plan majority bound, the exact
magnitude-oracle coefficient $1/2$ (both halves), the clipping boundary,
the remark that clipping the output to $[0,1]$ can only help, and the
Hoeffding replication count of the finite-cell observable-state bound
(records).
- Constants of the main law. The lower constant $1/6$ is sharp and the
upper constant is $12$, so the two sides are a factor $72$ apart. For
budgets of at least 25 the best lower constant is known only to lie in
$[0.175198,,0.186752]$.
- Toolkit verification. The Python toolkit is tested and not formally
verified; #85 and #86 track the connection to the Lean statements.
docs/WORKPLAN.md gives the current priorities, and the
tracking issue
lists every open task with its dependencies.
Attribution and license
AI agents carried out the research and formalization under David Iach’s
direction. The process note and
provenance record document the workflow and review limits.
Use CITATION.cff to cite this work. Code and Lean files are
licensed under Apache-2.0; the paper and documentation are licensed
under CC BY 4.0. See license scope.
评论