Thank you for your interest in contributing to lean-toolchain.
- Fork the repository and clone your fork.
- Install Lean 4 and Rust (see
README.md). - From the repository root, run
lake buildandlake test. - If you touch the Rust generator or templates, run
lake exe extractandcargo test/cargo clippy --all-targets -- -D warningsinsiderust/.
The Lean version is pinned in lean-toolchain. mathlib is required in lakefile.lean with a git reference that matches that Lean release (for example the v4.21.0 tag line). When you bump Lean:
- Update
lean-toolchain. - Update the mathlib
requireline to the corresponding mathlib tag or revision. - Run
lake updateand fix any breakage before opening a PR.
Production code under LeanToolchain/ is expected to contain no sorry placeholders. CI runs scripts/check_sorry.sh, which fails on any occurrence except files explicitly listed in scripts/sorry_allowlist.txt (whole-file waivers only, one repo-relative path per line; use sparingly and justify in the PR).
- Follow
.editorconfigfor whitespace and indentation. - For Lean: descriptive names, docstrings where they aid readers, and constructive proofs.
- For generated Rust:
pub unsafe extern "C"entrypoints are used for FFI-shaped APIs; keepunsafeblocks minimal and obvious.
- Prefer Conventional Commits.
- Ensure
lake build,lake test, and (if applicable) therust/checks above succeed. - Link related issues in the PR description.
- Be respectful and inclusive.
- MkDocs: configuration lives in
docs/mkdocs.yml; start fromdocs/index.mdfor the full map. - CI details:
docs/development/ci.md. - Rust generator:
docs/development/extraction.md. - Security scope:
SECURITY.md.
Pushes and pull requests run a local GitHub Actions workflow (see .github/workflows/local-ci.yml) that builds Lean, runs tests, regenerates rust/ with lake exe extract, runs cargo test / cargo clippy, and enforces the sorry policy. Additional organization checks may run via SentinelOps (formal-verify.yml).
For a concise overview of how those pieces fit together, see docs/development/ci.md.