Zulip Chat Archive
Stream: mathlib4
Topic: Coercion in WithBot ℕ
Violeta Hernández (Feb 02 2026 at 17:22):
WithBot ℕ has both a coercion ℕ → WithBot ℕ given by docs#WithBot.some, and a Nat.cast map ℕ → WithBot ℕ via docs#WithBot.addMonoidWithOne. Both pretty-print as ↑n, and neither is a simp-normal form of the other, leading to annoying simp/norm_cast failures.
Should we make one of them canonical? If so, which one?
Yury G. Kudryashov (Feb 02 2026 at 17:40):
For ENat, the canonical one is Nat.cast.
Violeta Hernández (Feb 02 2026 at 18:02):
Sure, that works for me.
Yury G. Kudryashov (Feb 02 2026 at 18:49):
Note: I rarely use this part of the library. My message was about a related datapoint, not about making a decision.
Eric Wieser (Feb 03 2026 at 07:18):
I don't think you can win here without ending up back at a lean3-style "there is only one coercion function" position
Eric Wieser (Feb 03 2026 at 07:19):
Otherwise you have to duplicate all the some lemmas for Nat.cast, or vice versa, to keep things confluent
Last updated: Feb 28 2026 at 14:05 UTC