feat: add cbv_simproc infrastructure for user-extensible cbv simplification procedures#12597
Merged
wkrozowski merged 20 commits intoleanprover:masterfrom Mar 10, 2026
Merged
Conversation
…ssions with metavariables This PR adds `mkSimprocPatternFromExpr` to `Lean.Meta.Sym.Pattern`, which creates a discrimination tree `Pattern` from an expression containing metavariables. Metavariables become pattern wildcards, enabling simproc-style pattern registration where users specify match targets with underscores. The implementation mirrors the existing forall-based pattern construction (`mkPatternCore`/`mkPatternFromType`) with lambda-based equivalents (`mkPatternCoreFromLambda`/`mkPatternFromLambda`), since `abstractMVars` produces lambda binders. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
…cation procedures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c70055a to
2c4612e
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 15, 2026
This PR removes unused functions (`mkPatternCoreFromLambda`, `mkPatternFromLambda`, `mkSimprocPatternFromExpr`) and the `import Lean.Meta.AbstractMVars` that were added to `Lean.Meta.Sym.Pattern` after merging #12597.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
cbv_simprocsystem for thecbvtactic, mirroring simp'ssimprocinfrastructure but tailored to cbv's three-phase pipeline (↓pre,cbv_evaleval,↑post). User-defined simplification procedures are indexed by discrimination tree patterns and dispatched during cbv normalization.New syntax:
cbv_simproc [↓|↑|cbv_eval] name (pattern) := body— define and register a cbv simproccbv_simproc_decl name (pattern) := body— define without registeringattribute [cbv_simproc [↓|↑|cbv_eval]] name— register an existing declarationbuiltin_cbv_simprocvariants for the internal useNew files:
src/Init/CbvSimproc.lean— syntax and macrossrc/Lean/Meta/Tactic/Cbv/CbvSimproc.lean— types, env extensions, registration, dispatchsrc/Lean/Elab/Tactic/CbvSimproc.lean— pattern elaboration and command elaborators