Zulip Chat Archive
Stream: lean4
Topic: Custom Constructor
Kenny Lau (Sep 15 2025 at 13:59):
Over at Mathlib we often run into the following situation:
- a general definition
GeneralDefwith constructor. - a specialised definition
SpecialDefwhich is a special case (sayα := Bool), saydef SpecialDef := GeneralDef (α := Bool). - then we need specialised projections and constructor(s) for
SpecialDef, often namedSpecialDef.mk
I'm wondering whether we can enable some syntax to prioritise the special constructor SpecialDef.mk so that we can use ⟨a, b, c⟩ to mean SpecialDef.mk a b c.
For example, we now have (i forgot the name) syntax to indicate the preferred recursor that the tactic induction uses.
Kenny Lau (Sep 15 2025 at 14:01):
(Example: CategoryTheory.Limits.PullbackCone is a special case of CategoryTheory.Limits.Cone, with special constructor CategoryTheory.Limits.PullbackCone.mk.)
Kenny Lau (Sep 15 2025 at 14:13):
Update: I would also like the where thing to work with SpecialDef.mk as well
Kim Morrison (Sep 16 2025 at 01:12):
Could you write an RFC, please?
Bhavik Mehta (Sep 16 2025 at 01:32):
Kenny Lau said:
Update: I would also like the
wherething to work withSpecialDef.mkas well
Previous discussion on this here: #mathlib4 > Custom structure constructors with `where`
Kenny Lau (Sep 16 2025 at 13:50):
@Kim Morrison @Bhavik Mehta lean4#10412
Last updated: Dec 20 2025 at 21:32 UTC