Skip to content

simp uses congr lemmas that are not visible #11436

@datokrat

Description

@datokrat

Prerequisites

Please put an X between the brackets as you perform the following steps:

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

  1. Check out the Lake project in this branch: https://github.com/datokrat/lean-bug-reproductions/tree/bugs7
  2. Open Reproductions/Basic.lean and observe the error.

Reproductions/Dependency.lean:

module

public def f : Nat → Nat := sorry

@[congr]
theorem t (h : m = n) : f m = f n := sorry

Reproductions/Basic.lean:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions