Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add naming convention for Prop-valued classes #592

Open
wants to merge 1 commit into
base: lean4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions templates/contribute/naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,19 @@ Most predicates should be added as prefixes. Eg `IsClosed (Icc a b)` should be c
Some widely used predicates don't follow this rule. Those are the predicates that are analogous to an atom already suffixed by the naming convention. Here is a non-exhaustive list:
* We use `_inj` for `f a = f b ↔ a = b`, so we also use `_injective` for `Injective f`, `_surjective` for `Surjective f`, `_bijective` for `Bijective f`...
* We use `_mono` for `a ≤ b → f a ≤ f b` and `_anti` for `a ≤ b → f b ≤ f a`, so we also use `_monotone` for `Monotone f`, `_antitone` for `Antitone f`, `_strictMono` for `StrictMono f`, `_strictAnti` for `StrictAnti f`, etc...

### Prop-valued classes

Mathlib has many `Prop`-valued classes and other definitions. For example "let $R$ be a
topological ring" is written `variable (R : Type*) [Ring R] [TopologicalSpace R] [IsTopologicalRing R]`
and "let $G$ be a group and let $H$ be a normal subgroup" is written
`variable (G : Type*) [Group G] (H : Subgroup G) [Normal H]`. Here `IsTopologicalRing R`
and `Normal H` are not extra data, but are extra assumptions on data we have already.

Mathlib currently strives towards the following naming convention for these `Prop`-valued
classes. If the class is a noun then its name should begin with `Is`. If however is it an adjective
then its name does not need to begin with an `Is`. So for example `IsNormal` would be acceptable
for the "normal subgroup" typeclass, but `Normal` is also fine; we might say "assume the subgroup
`H` is normal" in informal language. However `IsTopologicalRing` is
preferred for the "topological ring" typeclass, as we do not say "assume the ring `R` is
topological" informally.