`simp` uses `congr` lemmas that are not visible
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- 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
Private lemmas marked as @[congr] from imported modules are used by simp even though they are not visible, causing unknown constant errors.
Steps to Reproduce
- Check out the Lake project in this branch: https://github.com/datokrat/lean-bug-reproductions/tree/bugs7
- Open
Reproductions/Basic.leanand observe the error.
Reproductions/Dependency.lean:
module
public def f : Nat → Nat := sorry
@[congr]
theorem t (h : m = n) : f m = f n := sorry
module
import Reproductions.Dependency
/-- error: Unknown constant `_private.Reproductions.Dependency.0.t` -/
#guard_msgs in
theorem u (h : m = n) : f m = f n := by
simp [h]
Expected behavior:
simp should only use congr lemmas that are visible. (In the given example, theorem u should succeed because simp actually doesn't need to use a specialized congr lemma.)
Actual behavior:
An unknown constant error is caused by simp.
Versions
Lean 4.27.0-nightly-2025-11-30
Target: arm64-apple-darwin24.6.0 macOS
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
Run the Lake project from the bugs7 branch and reproduce the failure in Reproductions/Basic.lean, using Reproductions/Dependency.lean to understand the imported private congr lemma. Trace simp's congr-lemma handling and ensure theorem u succeeds without an unknown constant for an invisible lemma; rerun the reproduction to verify the fix.
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
- Mostly clear
- Newbie friendliness
- 42/100