`conv in` can unexpectedly fail with `unknown metavariable` error
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
conv in pat is supposed to pattern match on the pattern pat. The following reproducer below fails unexpectedly with a unknown metavariable '?_uniq.301' error. The following minimized reproducer shows that the failure has to do with a lemma with a @congr annotation.
Context
This issue was minimized from this Zulip discussion.
Steps to Reproduce
def sum (_ : Nat → Nat) : Nat := 0
@[congr]
theorem sum_congr {f g} : (∀ x, f x = g x) → sum f = sum g := by sorry
theorem repro : (sum fun i ↦ sum fun j : Nat ↦ i + 1) = 0 := by
conv in (fun j : Nat ↦ _ + 1) => simp
sorry
Expected behavior: conv in correctly matches the sub-expression, or at the very least fails with a meaningful error message.
Actual behavior: Fails with an RPC error, unknown metavariable '?_uniq.301'
Versions
Lean 4.28.0-nightly-2026-01-02
Target: x86_64-unknown-linux-gnu
(Taken from lean-live)
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal conv in reproducer and investigate how pattern matching interacts with the @[congr] lemma sum_congr, especially the reported unknown metavariable. Done means the expression is matched and simplified correctly, or the command produces a meaningful error instead of the RPC failure; retest against the Lean nightly version.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100