Thank you for your interest in contributing! This project formalizes
statistical theory in Lean 4 / Mathlib, organized into per-area sublibraries
under StatLean/ — asymptotic (parametric & semiparametric) statistics,
Bayesian statistics, concentration inequalities, high-dimensional statistics,
minimaxity, multiple testing, and optimization. Contributions of new theorems,
improved proofs, website content, and documentation are all welcome.
Contributors should be responsible for the code they submit, including its definitions, assumptions, theorem statements, and proofs. They should be prepared to explain relevant mathematical and implementation choices and address review feedback. These expectations apply equally to AI-assisted contributions.
- Fork the repository and clone your fork.
- Follow the Installation Guide to set up Lean and fetch the Mathlib cache.
- Run
lake buildto verify that everything compiles before making changes.
If you want to add a new theorem or definition:
- Place Lean source files under
StatLean/in the appropriate area (e.g.,StatLean/Bayesian/,StatLean/ConcentrationInequalities/,StatLean/AsymptoticStatistics/). Pure-math prerequisites that could live in Mathlib go in that area'sForMathlib/subdirectory; concept files should stay theorem-agnostic, with theorem-specific wiring in assembly files. - Ensure the new module is imported in its area umbrella
(
StatLean/<Area>.lean), whichStatLean.leanimports. - Every user-facing result should have a corresponding entry in
website/src/data/results.jsonwith:informal— the natural-language statement with LaTeX math ($…$)leanSignature— the verbatim Leantheorem/defheaderhypotheses— the list mapping Lean hypothesis names to their informal descriptions (used for hover-highlighting)citation— the required website citation field; for a sourced result, identify the theorem/lemma in the source text. See the website contribution guide for the data format. If no published source applies, identify the contributor-provided statement or project documentation.
- Shorter or more readable proofs are always welcome.
- If a proof currently uses
sorry, replacing it with a complete proof is a high-priority contribution. - Lean proofs should be self-contained: avoid introducing new
sorrys.
The interactive atlas lives in website/. See
website/README.md for the development workflow.
- Informal statement improvements: edit the
informalfield inwebsite/src/data/results.json. Statements should be in natural language with LaTeX math — no Lean-style identifiers. - Adding a result to the site: add a full entry to
results.jsonand a corresponding line inwebsite/targets.txt(<id>\t<fullName>).
Open a GitHub issue describing the problem or suggestion.
- Branch from
main— create a feature branch (git checkout -b my-feature). - One logical change per PR — keep related Lean code, result pages, and documentation together; separate unrelated refactors or website edits.
- All files must compile — run
lake build(and for website changes,npm run buildinsidewebsite/) before opening a PR. - Commit messages — use a short imperative subject line, e.g.:
Add Donsker theorem for VC classesorFix: remove sorry in LANExpansion. - Describe the mathematical content — provide or link to a clear natural-language statement, including relevant definitions, assumptions, and conclusions, and explain its intended use. For existing results, highlight changes to definitions, assumptions, conclusions, or public interfaces. Include references where applicable; claims of correspondence with a particular published result should identify its source and location.
Contributions are reviewed for mathematical accuracy, clarity, and maintainability, including whether the Lean formalization matches the stated mathematical content. Reviewers consider the documented validation results alongside the code and mathematical statement. Maintainers make the final acceptance decision. See Reviewing contributions for the review guidelines.
StatLean follows Mathlib's style,
naming and
documentation conventions. The
Mathlib linters enabled in lakefile.lean check many of them during lake build; new code should
not add linter warnings.
Naming:
- Theorems and lemmas are named in
snake_case. Prop-valued definitions, types, structures and classes are named inUpperCamelCase, for exampleIsPDonsker.- Other definitions are named in
lowerCamelCase, for exampleefficientInformationMatrix. - Inside a
snake_casename, anUpperCamelCasename is written inlowerCamelCase, as inisPDonsker_of_finite_bracketing_entropy_integral. - Names describe the statement. Equation numbers and other source labels belong in the docstring.
- Hypothesis names are short and descriptive (
h_qmd,hJ, etc.).
Formatting:
- Lines have at most 100 characters.
- Continuation lines of a statement are indented by 4 spaces and proofs by 2 spaces;
byends the line before the first tactic. ·focuses on a goal.:,:=and infix operators have a space on each side:(x : ℝ),a / b,x ^ 2.- Functions are written with
fun;λand$are not used (<|replaces$). - Declarations contain no empty lines.
Linters and options:
- An intentional exception to a linter is written as
set_option linter.<name> false in(or@[nolint <name>]for environment linters) on the declaration, with a comment giving the reason. set_option maxHeartbeats N inapplies to a single declaration and is followed by a comment explaining why the proof needs it.open Classicalis not used; useopen Classical inbefore a definition or theclassicaltactic inside a proof.- A file longer than 1500 lines states its length limit with
set_option linter.style.longFile N.
Documentation:
- A file starts with its imports, followed by a
/-! … -/module docstring that describes the file's contents and cites its sources. - Every definition, structure, structure field and class has a docstring, and so does every main theorem.
- Run
npm run buildto type-check before committing. - Informal statements in
results.jsonmust not contain Lean-style notation — translate all hypotheses to standard mathematical language and LaTeX. - The
informalfield may contain HTML (<span data-link="hN">…</span>for hover-linking,<p>,<strong>, etc.) but all math must use$…$or$$…$$KaTeX delimiters.
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.