Zulip Chat Archive

Stream: lean4

Topic: Can an attribute tell if it is applied to an instance?


Eric Wieser (May 23 2025 at 23:30):

In this mathlib PR, I ended up just checking if the name of the declaration starts with inst; can I do any better? The problem is that my attribute handler is running before the instance attribute handler, and so at the point I check the declaration has not been registered as an instance yet.

Robin Arnez (May 24 2025 at 09:59):

I don't think so but I don't think it would cause any problems if instance was appended to the start instead

Floris van Doorn (May 27 2025 at 13:28):

The instance attribute uses the default docs#Lean.AttributeApplicationTime, which is after type checking. One way to get simps to run after instance is to tell simps to apply after compilation (which, to be fair, is a bit of a hack).

Floris van Doorn (May 27 2025 at 13:29):

This is what we use in to_additive, IIRC to ensure that all equational lemmas have been generated.

Eric Wieser (May 28 2025 at 22:10):

I've updated #25125 to do that now, thanks for the tip


Last updated: Dec 20 2025 at 21:32 UTC