Zulip Chat Archive

Stream: lean4

Topic: what naming scheme to use in mathlib4


Kenny Lau (Jan 08 2021 at 17:27):

/poll What should we use in mathlib4?
camelCase and PascalCase
snake_case

Kenny Lau (Jan 08 2021 at 17:32):

Sebastian Ullrich said:

Patrick Massot said:

I would say we should follow Lean + core lib with definitions, but keep underscores in lemma names.

FWIW, that's what I suggested last year image.png

^
image.png

Heather Macbeth (Jan 08 2021 at 18:02):

What happens to the distinction between docs#group and docs#Group, from category theory?

Adam Topaz (Jan 08 2021 at 18:13):

If we end up using unification hints this wouldn't be an issue, right?

Adam Topaz (Jan 08 2021 at 18:17):

(assuming categories are still defined using classes, that is)

Bryan Gin-ge Chen (Jan 08 2021 at 18:20):

Sorry, can you explain further? (Maybe I need to read more about unification hints.)

Adam Topaz (Jan 08 2021 at 18:45):

I don't really know what I'm talking about, but I remember monoids being declared in Leo's talk as M : Monoid

Adam Topaz (Jan 08 2021 at 18:45):

Maybe I misremembered

Michael Jam (Aug 27 2022 at 20:41):

Looking at List.Mem theorems in Init.Data.List.Basic, I find the naming convention slightly confusing. https://leanprover-community.github.io/mathlib4_docs////Init/Data/List/Basic.html#List.Mem
Mem starts with a capital letter but the following lemmas are List.mem_... instead of List.Mem_...
Does it mean I should uncapitalize or snakify Mem in a theorem name? I am unsure what to do and I find that weird to do.

List.Mem could be defined with a recursive def instead of an inductive. But inductive Prop's are preferred because it makes proofs easier.
However it sounds inelegant to decide to write Mem instead of mem just because that particular Prop happens to be recursively defined.

My suggestion is probably naive but wouldn't it be cleaner to change the naming conventions for something like:
any declaration ending with a Prop, or with Prop: like_that (connectives should be in lower case)
defs (not Props, not theorems): likeThat
inductive types (not Props): LikeThat
?

David Renshaw (Aug 27 2022 at 20:55):

My understanding is roughly: defs, namespaces, structures get capital camelcase. Theorems and lemmas get snake_case.

David Renshaw (Aug 27 2022 at 20:57):

Current conventions are codified by mathport, and you can see its latest output here: https://github.com/leanprover-community/lean3port/blob/f2dc09b58e3e976fb99eab9c5f2b659a27e2dc2a/Leanbin/Init/Data/List/Basic.lean#L46

David Renshaw (Aug 27 2022 at 20:58):

(Ignore the little .)

Michael Jam (Aug 27 2022 at 21:16):

OK I wasn't aware that def's that end with Sort are LikeThat. I thought a def was a term name in Sebastian's convention. I guess it's motivated by the idea that namespaces created by Props should always be capitalized. I kind of dislike that convention but that's only my taste..


Last updated: Dec 20 2023 at 11:08 UTC