Thanks for your interest. Conventions below are non-negotiable for merged contributions but liberally relaxable for sketches / WIP / drafts.
-
Math object is primary; Lean is a UI. API surface, ergonomics, and discoverability come first. Engineering noise (chart-pullback helpers, typeclass cascades, smoothness bridges) is
privateand hidden under sections inside the.leanfile of the math object it serves. -
Chain depth over breadth. OpenGA targets proof depth on the Riemannian → GMT chain rather than broad parity with Mathlib's full differential geometry. If a theorem isn't on the chain, we don't pre-port it; pull when needed.
-
Self-build when Mathlib lacks a primitive. When Mathlib has a gap blocking the chain (e.g., the framework-owned
RiemannianMetrictypeclass that sidesteps the lean4#13063 NACG diamond), we build the framework analog rather than wait for upstream.
- Read
docs/NAMING_CONVENTION.mdbefore opening a PR. It's enforced by reviewers. - Skim
docs/REFACTOR_PLAYBOOK.mdif your change touches more than one file. The playbook describes the verifiable-object consolidation pattern, programmatic bulk-edit recipes, and the pitfalls we've encountered. - Pick a sorry to close, or open an issue first if your idea is
architectural. Every
sorryin the lib carries a closure plan in its docstring (**Sorry status**:/Closure path:/Repair plan:); start from one whose path you understand. Good first issues: closing low-dependency PRE-PAPER sorries inAlgebraic/,Tensor/. - External references —
external/(git-ignored) contains theqinz1yang/differential-geometryreference repo we draw from. We re-implement in our conventions — never copy.
- Fork + branch off
main. One concern per PR — don't bundle rename + refactor + bug-fix. - Local
lake buildmust be clean (warnings OK; no errors). - Local CI checks:
sorrycount andaxiomcount are CI-enforced (see.github/workflows/ci.yml). If your PR changes either:- Update the
EXPECTEDconstant in the workflow. - Document the new
sorry/axiomin the relevant module docstring with a closure plan.
- Update the
- Commit messages — short subject line, prose body explaining
why (not just what); reference the issue if relevant. Don't
add Co-Authored-By trailers for AI assistants (we strip them on
release). The repo ships a
commit-msghook in.githooks/that strips Claude Code attribution automatically; activate per-clone with:git config core.hooksPath .githooks - Open PR against
main. Reviewers will check naming + chain depth + docstring quality. Expect one round of feedback for non-trivial changes.
| Aspect | Where to look |
|---|---|
| Naming (defs, theorems, types) | docs/NAMING_CONVENTION.md §1-§3 |
| Docstring template | docs/NAMING_CONVENTION.md §5-§6 |
| File / namespace structure | docs/NAMING_CONVENTION.md §7-§9 |
@[simp] / @[ext] policy |
docs/NAMING_CONVENTION.md (Phase 5 deferred — apply conservatively) |
| Engineering hiding | docs/NAMING_CONVENTION.md §7 (private, where-aux) |
| Bulk codemods | docs/REFACTOR_PLAYBOOK.md + scripts/ |
In short: textbook-clean math API at the surface, engineering
hidden underneath. If a reader of the API has to scroll past
set_option backward.isDefEq.respectTransparency false or
coordChangeL_apply_of_mem_baseSet to find the math, the file is
mis-organized.
Co-Authored-Bytrailers for AI assistants in commit messages (we strip on release).Inspired by <repo>/Adapted from <author>attribution in source files — attribution belongs in commit history, not in code or docstrings.paper §X/ project-specific cross-references inAlgebraic/,Tensor/,Riemannian/,GeometricMeasureTheory/— these namespaces must be paper-agnostic; paper-specific work lives in downstream consumer repos.- Self-tests / UX tests as
exampleblocks at end of file — these are documentation pretending to be test; we keep the real math in the body and let LSP +lake buildcatch regressions. - Adding
sorrywithout updatingEXPECTEDin CI + adding a closure plan in docstring.
Open an issue. Architectural / design questions are welcome there before you write code.