Zulip Chat Archive

Stream: mathlib4

Topic: naming arguments to recursors


Aaron Liu (Apr 28 2025 at 01:58):

In #mathlib4 > Induction argument order @ đź’¬ it was decided that the "motive" argument should be called motive. But what about the other arguments? What should they be called?

Here's a random sample of some declarations that I would consider to be "recursors":

Eric Wieser (Apr 28 2025 at 02:44):

I think the rough guideline is "pretend this was the recursor generated by an inductive type, and so name the arguments in the recursor as you would the constructors in the inductive type"

Edward van de Meent (Apr 28 2025 at 07:23):

the names you choose matter: they get used for naming new goals, and they are also the labels for with branches to cases and induction

Edward van de Meent (Apr 28 2025 at 07:23):

So that's something to keep in mind

Aaron Liu (Apr 28 2025 at 10:25):

Eric Wieser said:

I think the rough guideline is "pretend this was the recursor generated by an inductive type, and so name the arguments in the recursor as you would the constructors in the inductive type"

What do this mean for docs#Surreal.lift, which is a "quotient recursor"?

Edward van de Meent (Apr 28 2025 at 10:32):

ah, but that's not really a recursor

Edward van de Meent (Apr 28 2025 at 10:33):

in the sense that there is no motive

Edward van de Meent (Apr 28 2025 at 10:33):

or at least, it seems to me like there isn't any?

Eric Wieser (Apr 28 2025 at 10:49):

Yeah, that's more (half of) a universal property than a recursor

Aaron Liu (Apr 28 2025 at 10:57):

Edward van de Meent said:

in the sense that there is no motive

I analyzed this as a non-dependent recursor in which the motive {α : Sort*} is not allowed to depend on the major premise (_ : Surreal)

Aaron Liu (Apr 28 2025 at 10:57):

Eric Wieser said:

Yeah, that's more (half of) a universal property than a recursor

That's what a recursor is, right? It's (half of) a universal property

Aaron Liu (Apr 28 2025 at 10:58):

Anyways, even if you don't think Surreal.lift counts as a recursor, there are plenty more that follow this pattern. What about docs#Multiset.rec, then? Surely that's a recursor.

Chris Bailey (Apr 28 2025 at 11:14):

I think using "major" and some variation of "minor<constructor>" would make sense when applicable. The minor premises are usually anonymous in the type, but last I checked the iota rules just use the constructor name which is a little bit of a hit to readability (even though they're sort of hidden).

Aaron Liu (Apr 28 2025 at 11:16):

Chris Bailey said:

I think using "major" and some variation of "minor<constructor>" would make sense when applicable. The minor premises are usually anonymous in the type, but last I checked the iota rules just use the constructor name which is a little bit of a hit to readability (even though they're sort of hidden).

When you do induction x using Foo.rec with, the alternatives are named according to the minor premises.

Aaron Liu (Apr 28 2025 at 11:19):

Here's an example of this pattern, which is why they need to have names that make sense.

Aaron Liu (Apr 28 2025 at 16:04):

Also, sometimes there can be more than one major premise, for example in docs#Nat.recDiag both m and n are major premises.

Aaron Liu (Apr 28 2025 at 16:06):

Chris Bailey said:

I think using "major" and some variation of "minor<constructor>" would make sense when applicable.

This also doesn't answer what I should name the C_cons_heq argument of docs#Multiset.rec.

Eric Wieser (Apr 28 2025 at 16:45):

C_0 and C_cons should be called zero and cons

Eric Wieser (Apr 28 2025 at 16:46):

C_cons_heq I guess is emulating a quotient-inductive type, so maybe sound (referring to docs#Quotient.sound) or cons_sound is appropriate?

Aaron Liu (Apr 28 2025 at 17:00):

Sure! This seems like the correct naming if I'm thinking of Multiset as a higher inductive type. What other quotient-inductive recursors, like docs#Quotient.hrecOn₂? Should φ be replaced with motive, f be replaced with mk, and c be replaced with sound?

Aaron Liu (Apr 28 2025 at 17:08):

Also, what should the major premises be named?

Aaron Liu (Apr 28 2025 at 17:14):

Eric Wieser said:

C_cons_heq I guess is emulating a quotient-inductive type, so maybe sound (referring to docs#Quotient.sound) or cons_sound is appropriate?

The theorem is called docs#Multiset.cons_swap, so maybe cons_swap?

Robin Arnez (Apr 28 2025 at 18:17):

In my opinion you really only need to care about the minor premises and the motive specifically (naming them like constructors and well, motive). For major premises just use whatever name is typical for the type or whatever or just go with a single letter (recursors for inductive types use the name t by default iirc). Side conditions, such as the C_cons_heq can just be called as if they were just regular proofs, e.g. h is probably fine. Regarding Quotient.hrecOn and variants: using the names motive and mk would probably be better here, c can be h or whatever (although I may note that this function is not really usable with induction / cases so it's less relevant to change things).


Last updated: May 02 2025 at 03:31 UTC