Commit 2025-09-29 08:46 a9af4dc7

View on Github →

feat(Algebra/Group/Hom/Defs): MonoidHom switching from MulOneClass to MulOne (#28702) Currently MonoidHom relies on a MulOneClass, stating that 1 is a multiplicative identity; when actually all a "monoid" hom does is preserve multiplication and one. So, really, a MonoidHom is a "mul-and-one hom", but one cannot use it with any type that isn't a MulOneClass. (It also does not enforce being a Monoid: associativity is not required.) In general, homs like this should only rely on the data being present in the source and destination type; any applications of it are then free to assume MulOneClass or Monoid where appropriate, which is essentially already how it does. This drops the MulOneClass assumption so that MonoidHom just takes the Mul and One types. But if we wrote MonoidHom [Mul M] [One M], this would essentially double the effort needed for typeclass inference. An experiment in #28889 confirmed this performance hit. So, we define a MulOne type which is just the Mul and One data bundled together, and the performance change becomes pretty minimal. And then there are the corresponding changes to AddMonoidHom / AddZeroClass becoming AddZero. This follows some discussion at #mathlib4 > RingHom for not-a-ring

Estimated changes

modified structure AddMonoidHom
modified theorem MonoidHom.cancel_left
modified theorem MonoidHom.cancel_right
modified theorem MonoidHom.coe_comp
modified theorem MonoidHom.coe_copy
modified theorem MonoidHom.coe_id
modified theorem MonoidHom.coe_mk
modified def MonoidHom.comp
modified theorem MonoidHom.comp_apply
modified theorem MonoidHom.comp_assoc
modified theorem MonoidHom.comp_id
modified theorem MonoidHom.comp_one
modified theorem MonoidHom.copy_eq
modified theorem MonoidHom.ext
modified def MonoidHom.id
modified theorem MonoidHom.id_comp
modified theorem MonoidHom.mk_coe
modified theorem MonoidHom.one_apply
modified theorem MonoidHom.one_comp
modified theorem MonoidHom.toFun_eq_coe
modified theorem MonoidHom.toMulHom_coe
modified theorem MonoidHom.toOneHom_coe
modified structure MonoidHom