Lean 4 fork for HoTT-compatible kernel extensions (Path types, transport, HITs). Maintained against upstream leanprover/lean4.
This PR adds `whileM`, a counterpart to `Lean.Loop.forIn` that admits a one-step unfolding lemma `whileM_eq` (impossible to prove for the original `partial def`). `Lean.Loop.forIn` now expands to `whileM`, so `repeat`/`while` keep working without source changes, and the `Spec.whileM`/`Spec.forIn_loop` `@[spec]` theorems let `mvcgen` discharge their bodies given a Nat variant and an `α ⊕ β` invariant. `whileM.impl` is still a `partial def`, but returns a `Subtype (whileM.Pred f a)` whose property pins the value to an `Acc.recOn` term whenever an `Acc` and a `MonadAttach` witness exist; `whileM_eq` extracts that property. A `@[implemented_by]` `whileM.erased` keeps the runtime a tail call after specialization and would be unnecessary if the compiler were able eta-expand through the trivial `Subtype` structure. Supporting infrastructure: `Internal.Ensures`/`MayReturn`/`ErasesTo`/`IsAttach` and `WPAdequate` for `Id`/`ReaderT`/`StateT`/`ExceptT`/`OptionT`. The resulting `while` loops take more work to optimize, hence a modest increase in build time instructions. |
||
|---|---|---|
| .claude | ||
| .github | ||
| .vscode | ||
| doc | ||
| images | ||
| releases_drafts | ||
| script | ||
| src | ||
| stage0 | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .gitpod.Dockerfile | ||
| .gitpod.yml | ||
| .ignore | ||
| AGENTS.md | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| CODEOWNERS | ||
| CONTRIBUTING.md | ||
| flake.lock | ||
| flake.nix | ||
| lean-toolchain | ||
| LICENSE | ||
| LICENSES | ||
| README.md | ||
| RELEASES.md | ||
This is the repository for Lean 4.
About
- Quickstart
- Homepage
- Theorem Proving Tutorial
- Functional Programming in Lean
- Documentation Overview
- Language Reference
- Release notes starting at v4.0.0-m3
- Examples
- External Contribution Guidelines
Installation
See Install Lean.
Contributing
Please read our Contribution Guidelines first.
Building from Source
See Building Lean.