Zulip Chat Archive
Stream: mathlib4
Topic: Alias of Prop type instances
Jiang Jiedong (Oct 10 2024 at 15:54):
Hi everyone,
I was trying to create some deprecated alias after renaming. The CI complains
/- The `defLemma` linter reports:
INCORRECT DEF/LEMMA: -/
-- Mathlib.Algebra.Group.Units.Hom
Error: ././././Mathlib/Algebra/Group/Units/Hom.lean:252:1: error: @MonoidHom.isLocalRingHom_comp is a def, should be lemma/theorem
The code is like this, where IsLocalHom
takes values in Prop
instance MonoidHom.isLocalHom_comp (g : S →* T) (f : R →* S) [IsLocalHom g]
[IsLocalHom f] : IsLocalHom (g.comp f) where
map_nonunit a := IsLocalHom.map_nonunit a ∘ IsLocalHom.map_nonunit (f := g) (f a)
@[deprecated (since := "2024-10-10")]
alias MonoidHom.isLocalRingHom_comp := MonoidHom.isLocalHom_comp
Is this a bug? When creating an alias for Prop
valued instances, it will be treated as def and further trigger the defLemma
linter.
Yaël Dillies (Oct 10 2024 at 16:00):
Yes, that's a bug. But it's not the fault of alias
. Instead, instance
creates def
s regardless of whether the typeclass is Prop- or Type-valued
Jiang Jiedong (Oct 10 2024 at 16:04):
Yes, but without alias, the defLemma
linter does not complain. So maybe the true solution is that we should fix instances? (not alias nor linter)
Jiang Jiedong (Oct 10 2024 at 16:05):
I think for my PR I'll just drop these deprecated alias for instances.
Matthew Ballard (Oct 10 2024 at 16:06):
Silencing the linter seems to be the kick-the-can solution currently
Jiang Jiedong (Oct 10 2024 at 16:07):
And shall I write an issue in the GitHub page of Mathlib for this?
Yaël Dillies (Oct 10 2024 at 16:07):
There is already an issue on the lean4 repo
Yaël Dillies (Oct 10 2024 at 16:10):
Actually, I don't find it :thinking:
Jiang Jiedong (Oct 10 2024 at 16:26):
How to see whether a declaration (instance) is a def
or a theorem
?
Jiang Jiedong (Oct 10 2024 at 16:27):
I was trying to write a new issue but don't know the way to exhibit this def
-or-theorem
difference.
Markus Himmel (Oct 10 2024 at 16:37):
import Lean.Elab.Command
open Lean
class A : Prop
instance a : A where
/-- info: it's a definition -/
#guard_msgs in
run_meta do
if let .defnInfo _ ← getConstInfo `a then
logInfo "it's a definition"
Kyle Miller (Oct 10 2024 at 16:48):
Yaël Dillies said:
Actually, I don't find it :thinking:
It would be nice if someone reported this!
Jiang Jiedong (Oct 10 2024 at 17:22):
I opened lean#5672 to report this.
Eric Wieser (Oct 10 2024 at 17:24):
Does writing @[instance] theorem
fix the problem for now?
Jiang Jiedong (Oct 10 2024 at 17:25):
Eric Wieser said:
Does writing
@[instance] theorem
fix the problem for now?
Yes, that would fix the problem.
Jiang Jiedong (Oct 10 2024 at 17:47):
Thank you! I've adopted this solution in my PR.
Edward van de Meent (Oct 11 2024 at 19:25):
Jiang Jiedong said:
How to see whether a declaration (instance) is a
def
or atheorem
?
give it a name and use #print
Eric Wieser (Oct 11 2024 at 19:32):
Or hover over the word instance
to find the generated name
Junyan Xu (Dec 12 2024 at 16:41):
The issue has been resolved by lean#5856
Last updated: May 02 2025 at 03:31 UTC