leanprover / leanprover/lean4

RFC: expand reducibility warning about class-typed `def`s

Open Beginner friendly
#13,351 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Proposal

Lean warns about class-typed defs that aren't marked with a reducibility attribute:

/--
warning: Definition `foo` of class type must be marked with `@[reducible]` or `@[implicit_reducible]`
-/
#guard_msgs in
def foo : @Std.Refl Nat Eq where
  refl _ := rfl

(in elabMutualDef and addInstance)

I think this warning should be expanded to include e.g. a link to docs/reference, and maybe "when in doubt, choose @[implicit_reducible]".
I forgot which one was less reducible, and wanted the warning to tell me.

Additionally it should have the standard message telling the user how to turn off the linter, with set_option warn.classDefReducibility false.

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

Read the warning logic in src/Lean/Elab/MutualDef.lean at elabMutualDef and src/Lean/Meta/Instances.lean at addInstance. Update the class-typed def warning with reducibility guidance, relevant documentation or reference links, the suggested default, and the standard option-disabling message; done means both warning paths provide the expanded guidance.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.