Zulip Chat Archive

Stream: mathlib4

Topic: Bad `simp` lemmas for `AddConstMap`


Yury G. Kudryashov (Jun 29 2024 at 20:04):

About @Matthew Ballard 's #14233 (adding scoped to a bunch of simp lemmas). First of all, thank you for locating and fixing this! Second, could you please explain to me why these lemmas are bad, so that I don't introduce a similar performance issue in the future? Is it because Lean tries them every time when it sees DFunLike.coe f (_ + _) but they rarely apply (as opposed to _root_.map_add which usually applies when it matches)?

Yury G. Kudryashov (Jun 29 2024 at 20:05):

If yes, does it mean that lemmas like docs#AddConstMap.coe_mk and below are OK as non-scoped but you've scoped them for consistency?

Matthew Ballard (Jun 29 2024 at 20:13):

Yury G. Kudryashov said:

Is it because Lean tries them every time when it sees DFunLike.coe f (_ + _) but they rarely apply (as opposed to _root_.map_add which usually applies when it matches)?

Yes, my understanding is that they get through the discrimination tree filter now but rarely apply. Since this is a leaf file, we don't notice. But in linting, we have all of mathlib to check simp on.

Matthew Ballard (Jun 29 2024 at 20:14):

I just scoped everything mindlessly. But I think consistency is a good goal. You don't want to guess which are and which are out.

Yury G. Kudryashov (Jun 29 2024 at 20:51):

I guess, lemmas in AddConstMapClass should be scoped, lemmas about AddConstMaps don't need scoped.

Yury G. Kudryashov (Jun 29 2024 at 20:59):

Testing in #9726

Yury G. Kudryashov (Jun 29 2024 at 21:29):

I droped scoped on lemmas about concrete types. Bench says no significant changes. Would you like have a look from the perf point of view?

Matthew Ballard (Jun 30 2024 at 13:36):

Looks good to me.


Last updated: May 02 2025 at 03:31 UTC