Improve error message when rfl-proved theorem fails module system defeq check
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
When a theorem is proved by rfl but the relevant definition is not @[exposed], the error message does not explain why a definitional equality is expected, nor does it suggest the available workarounds.
Current behavior
module
public def f (x : Nat) := x
@[simp] public theorem f_zero : f 0 = 0 := rfl
produces:
error: Not a definitional equality: the left-hand side
f 0
is not definitionally equal to the right-hand side
0
Note: This theorem is exported from the current module. This requires that all definitions that need to be unfolded to prove this theorem must be exposed.
There is a hint about exposing, but the message does not explain why a definitional equality is expected in the first place (because theorems proved by rfl have special status), and does not mention the alternatives.
Expected behavior
The error message should:
- Explain that theorems proved by
rflare implicitly treated as definitional equalities (and thus need all involved definitions to be exposed). - Suggest two alternatives:
- Mark the relevant definitions as
@[exposed]so downstream modules can still see the definitional equality. - Replace
rflwith(rfl)to opt out of the theorem being treated as a definitional equality.
- Mark the relevant definitions as
- Ideally, vary the message based on whether the defeq status was implicit (from
rfl) or explicit (from@[defeq]).
Currently, telling a user "replace rfl with (rfl)" feels like complete magic without further explanation.
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
Reproduce the module-system definitional-equality check with the f_zero example and locate the existing error-message entry point. Compare the implicit rfl case with the explicit @[defeq] case, then verify that the message explains the requirement and exposes both @[exposed] and (rfl) alternatives.
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