Skip to content

feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables#12569

Open
wkrozowski wants to merge 4 commits intoleanprover:masterfrom
wkrozowski:wojciech/cbv_simproc_sym_pattern
Open

feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables#12569
wkrozowski wants to merge 4 commits intoleanprover:masterfrom
wkrozowski:wojciech/cbv_simproc_sym_pattern

Conversation

@wkrozowski
Copy link
Copy Markdown
Contributor

@wkrozowski wkrozowski commented Feb 18, 2026

This PR adds lambda-based pattern construction to Lean.Meta.Sym.Pattern, needed by cbv_simproc machinery (#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. Since abstractMVars converts metavariables (appearing in expressions such asNat.succ _) into lambda binders, not forall binders, the existing API cannot be reused. This PR adds mkPatternCoreFromLambda, mkPatternFromLambda, and the public entry point mkSimprocPatternFromExpr as lambda-based counterparts.

Regular simproc does not need this because it indexes via DiscrTree.mkPath directly. The cbv tactic uses Sym.Pattern.match? /Pattern.unify? for structural matching, so it must produce Sym.Pattern values.

…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>
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 18, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing bot commented Feb 18, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f1934c8d5288d42c218e0fe3e162188278d8a805 --onto 91bd6e19a7b7aca769f9720e1127c768df0cd2a7. You can force Mathlib CI using the force-mathlib-ci label. (2026-02-18 23:39:00)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1f03e3252001a9a5cdfb354bfc45895d047bf4ff --onto 91bd6e19a7b7aca769f9720e1127c768df0cd2a7. You can force Mathlib CI using the force-mathlib-ci label. (2026-02-19 14:17:46)
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-03-04 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-04 12:13:02)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented Feb 18, 2026

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase f1934c8d5288d42c218e0fe3e162188278d8a805 --onto 5c7a508e21c5ebc710b0dfe65648d5beba4e34e0. You can force reference manual CI using the force-manual-ci label. (2026-02-18 23:39:02)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 1f03e3252001a9a5cdfb354bfc45895d047bf4ff --onto 5c7a508e21c5ebc710b0dfe65648d5beba4e34e0. You can force reference manual CI using the force-manual-ci label. (2026-02-19 14:17:48)
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-03-04 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-03-04 12:13:04)

@wkrozowski wkrozowski changed the title feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables feat: add mkSimprocPatternFromExpr for creating patterns from expressions with metavariables Feb 20, 2026
@wkrozowski wkrozowski added the changelog-language Language features and metaprograms label Mar 4, 2026
@wkrozowski wkrozowski marked this pull request as ready for review March 4, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants