Lean 4 fork for HoTT-compatible kernel extensions (Path types, transport, HITs). Maintained against upstream leanprover/lean4.
This PR adds a user-extension mechanism for the `try?` tactic. You can either use the `@[try_suggestion]` attribute on a declaration with signature ``MVarId -> Try.Info -> MetaM (Array (TSyntax `tactic))`` to produce suggestions, or the `register_try?_tactic <stx>` command with a fixed piece of syntax. User-extensions are only tried *after* the built-in try strategies have been tried and failed. I wanted to ensure that if the user provides a tactic that produces a "Try this:" suggestion, we both emit the original tactic and the suggested replacement (this is what we already do with `grind` and `simp`). I have this working, but it is quite hacky: we grab the message log and parse it. I fear this will break when the "Try this:" format is inevitably changed in the future. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds user-defined suggestion generators for `try?` via `@[try_suggestion]` and `register_try?_tactic`, executed after built-ins with priority and double-suggestion handling. > > - **Parser/Command**: > - Add command syntax `register_try?_tactic (priority := n)? <tacticSeq>` in `Lean.Parser.Command`. > - **Suggestion registry**: > - Introduce `@[try_suggestion (prio)]` attribute with a scoped env extension to register generators (`MVarId → Try.Info → MetaM (Array (TSyntax `tactic))`). > - Priority ordering (higher first); supports local/global scope. > - **Tactic engine (`try?`)**: > - New unsafe pipeline to collect and run user generators after built-in tactics; expands nested "Try this" outputs from user tactics. > - `mkTryEvalSuggestStx` now takes `(goal, info)`; integrates user tactics as fallback via `attempt_all`. > - Suppress intermediate "Try this" messages during `evalAndSuggest` by restoring the message log. > - **Imports**: > - Add `meta import Lean.Elab.Command` for command elaboration. > - **Tests**: > - `try_register_builtin.lean`: command availability and warning without import. > - `try_user_suggestions.lean`: basic, priority, built-in fallback, double-suggestion, and command registration cases. > - Update `versoDocMissing.lean.expected.out` to include `register_try?_tactic` in expected commands. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 302dc9454450eb29ad4ea9b01d87ac60365299ad. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> |
||
|---|---|---|
| .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.