feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables#12569
Open
wkrozowski wants to merge 4 commits intoleanprover:masterfrom
Open
feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables#12569wkrozowski wants to merge 4 commits intoleanprover:masterfrom
mkSimprocPatternFromExpr for creating patterns from expressions with metavariables#12569wkrozowski wants to merge 4 commits intoleanprover:masterfrom
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:
|
mkSimprocPatternFromExpr for creating patterns from expressions with metavariables
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 lambda-based pattern construction to
Lean.Meta.Sym.Pattern, needed bycbv_simprocmachinery (#12597), where users provide trigger patterns as expressions with metavariable wildcards (e.g.,Nat.succ _).The existing pattern API of
Sym(mkPatternFromExpr,mkPatternFromDecl,mkPatternFromType) only handles forall-bound theorem types. SinceabstractMVarsconverts metavariables (appearing in expressions such asNat.succ _) into lambda binders, not forall binders, the existing API cannot be reused. This PR addsmkPatternCoreFromLambda,mkPatternFromLambda, and the public entry pointmkSimprocPatternFromExpras lambda-based counterparts.Regular
simprocdoes not need this because it indexes viaDiscrTree.mkPathdirectly. Thecbvtactic usesSym.Pattern.match?/Pattern.unify?for structural matching, so it must produceSym.Patternvalues.