Zulip Chat Archive

Stream: Is there code for X?

Topic: Attribute to map rewrite rules through a functor?


𝚠𝚘𝚓𝚌𝚒𝚎𝚌𝚑 𝚗𝚊𝚠𝚛𝚘𝚌𝚔𝚒 (Apr 25 2025 at 21:27):

The category theory library has a useful attribute, @[reassoc], to generate a lemma f ≫ (g ≫ a) = h ≫ a from f ≫ g = h; simp can apply the former but not the latter after reassociating to the right. Another thing that sometimes happens is that we want to apply F.map f ≫ F.map g = F.map h as a simp rule, but this also will not trigger from just the original lemma; is there an attribute to automatically generate this (perhaps quantifying over all F)?

Adam Topaz (Apr 25 2025 at 23:01):

i think grind is supposed to eesolve all such issues

Adam Topaz (Apr 25 2025 at 23:02):

but the answer is no.

𝚠𝚘𝚓𝚌𝚒𝚎𝚌𝚑 𝚗𝚊𝚠𝚛𝚘𝚌𝚔𝚒 (Apr 25 2025 at 23:05):

Is there a writeup anywhere of how grind will deal with situations like this one? In the meantime, I wrote the attribute by copy-pasting reassoc.

Yaël Dillies (Apr 26 2025 at 14:02):

Just to flag that @Andrew Yang have the same thought as you in the context of Toric

Andrew Yang (Apr 26 2025 at 14:04):

I suggest we have this in mathlib and tag every category theory lemma with this.

𝚠𝚘𝚓𝚌𝚒𝚎𝚌𝚑 𝚗𝚊𝚠𝚛𝚘𝚌𝚔𝚒 (Apr 26 2025 at 18:54):

It would be quite a lot of lemmas added to the simp set.. I am mostly using these in a particular situation where we work with yoneda.map a lot. You also run into the funny situation of needing all of f ≫ g = h, f ≫ (g ≫ a) = h ≫ a, F.map f ≫ F.map g = F.map h, and F.map f ≫ (F.map g ≫ a) = F.map h ≫ a which is achieved via the monstrous @[functor_map (attr := reassoc (attr := simp))].

Kevin Buzzard (Apr 26 2025 at 19:13):

you might call it monstrous but it's pretty cool if that works.

Yaël Dillies (Apr 26 2025 at 20:41):

I think that actually the lemmas that are eligible for this new kind of auxiliary lemma generation are the same that are available for reassoc. So I think we don't need a new attribute at all, but merely an extension of reassoc.

Robin Carlier (Apr 27 2025 at 09:27):

If you want to make it an extension of reassoc, be aware that I have an open PR (#24303) modifying reassoc, so there might be some conflicts in the code.


Last updated: May 02 2025 at 03:31 UTC