leanprover / leanprover/lean4

`conv in` can unexpectedly fail with `unknown metavariable` error

Open
#11,877 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.