Lean 4 fork for HoTT-compatible kernel extensions (Path types, transport, HITs). Maintained against upstream leanprover/lean4.
This PR adds the attributes `[grind norm]` and `[grind unfold]` for controlling the `grind` normalizer/preprocessor. The `norm` modifier instructs `grind` to use a theorem as a normalization rule. That is, the theorem is applied during the preprocessing step. This feature is meant for advanced users who understand how the preprocessor and `grind`'s search procedure interact with each other. New users can still benefit from this feature by restricting its use to theorems that completely eliminate a symbol from the goal. Example: ```lean theorem max_def : max n m = if n ≤ m then m else n ``` For a negative example, consider: ```lean opaque f : Int → Int → Int → Int theorem fax1 : f x 0 1 = 1 := sorry theorem fax2 : f 1 x 1 = 1 := sorry attribute [grind norm] fax1 attribute [grind =] fax2 example (h : c = 1) : f c 0 c = 1 := by grind -- fails ``` In this example, `fax1` is a normalization rule, but it is not applicable to the input goal since `f c 0 c` is not an instance of `f x 0 1`. However, `f c 0 c` matches the pattern `f 1 x 1` modulo the equality `c = 1`. Thus, `grind` instantiates `fax2` with `x := 0`, producing the equality `f 1 0 1 = 1`, which the normalizer simplifies to `True`. As a result, nothing useful is learned. In the future, we plan to include linters to automatically detect issues like these. Example: ```lean opaque f : Nat → Nat opaque g : Nat → Nat @[grind norm] axiom fax : f x = x + 2 @[grind norm ←] axiom fg : f x = g x example : f x ≥ 2 := by grind example : f x ≥ g x := by grind example : f x + g x ≥ 4 := by grind ``` The `unfold` modifier instructs `grind` to unfold the given definition during the preprocessing step. Example: ```lean @[grind unfold] def h (x : Nat) := 2 * x example : 6 ∣ 3*h x := by grind ``` |
||
|---|---|---|
| .claude | ||
| .github | ||
| doc | ||
| images | ||
| releases_drafts | ||
| script | ||
| src | ||
| stage0 | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .gitpod.Dockerfile | ||
| .gitpod.yml | ||
| .ignore | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| CODEOWNERS | ||
| CONTRIBUTING.md | ||
| flake.lock | ||
| flake.nix | ||
| lean-toolchain | ||
| lean.code-workspace | ||
| 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.