Zulip Chat Archive

Stream: maths

Topic: ring_hom


Kevin Buzzard (May 11 2021 at 11:08):

Whilst making a MWE for this I noticed that we have

structure ring_hom (α : Type*) (β : Type*) [semiring α] [semiring β]
  extends monoid_hom α β, add_monoid_hom α β, monoid_with_zero_hom α β

However monoid_with_zero_hom is defined to extend zero_hom M N (part of add_monoid_hom) and monoid_hom M N, and adds no new fields, so we don't need it at all from a maths point of view. Is there a reason it's there anyway?

Eric Wieser (May 11 2021 at 11:14):

I thought I wrote down why I did this at docs#ring_hom

Eric Wieser (May 11 2021 at 11:14):

From that link:

This extends from both monoid_hom and monoid_with_zero_hom in order to put the fields in a
sensible order, even though monoid_with_zero_hom already extends monoid_hom.

Kevin Buzzard (May 11 2021 at 11:16):

you're justifying why you extend monoid_hom, I was asking the other way around, but either way I don't ubderstand your answer -- surely the sensible order starts with 0?

Eric Wieser (May 11 2021 at 11:16):

If you had extends monoid_with_zero_hom α β, add_monoid_hom α β then the order would be zero, one, mul, add

Eric Wieser (May 11 2021 at 11:16):

Oh, it's so you get ring_hom.to_monoid_with_zero_hom for free

Eric Wieser (May 11 2021 at 11:17):

You're right, I was answering a different question.

Kevin Buzzard (May 11 2021 at 11:17):

The order I learnt them was zero, one, add, mul, which is closer to this than what we have right now ;-) OK so it's just a field order thing? All this is going to have to be refactored before the Lean 4 port anyway, right, because old structures are evil?

Kevin Buzzard (May 11 2021 at 11:18):

Eric Wieser said:

Oh, it's so you get ring_hom.to_monoid_with_zero_hom for free

This was what I was wondering about.

Eric Wieser (May 11 2021 at 11:18):

I think there might be bits of mathlib that rely on the field order, and I didn't want to have to touch them when I added monoid_with_zero_hom

Kevin Buzzard (May 11 2021 at 11:18):

Yes that sounds believable, sometimes people just make complex structures by listing the fields in \< \>

Kevin Buzzard (May 11 2021 at 11:19):

given that elab_as_eliminator is gone and now it's much harder to use recursors directly, one gets the impression that the devs are suggesting that listing the fields is supposed to be idiomatic nowadays (even on a split of an or)

Eric Wieser (May 11 2021 at 11:19):

Either it would need refactoring for lean 4, or we add some meta code to add back old structures. Using new structures sounds like it matters more for typeclass inference

Eric Wieser (May 11 2021 at 11:21):

I think field order is unavoidably public whatever you do; ring_hom.mk is probably not going away


Last updated: Dec 20 2023 at 11:08 UTC