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

Expanding on the naming conventions #793

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5d1c20b
expanding naming conventions
EgbertRijke Sep 21, 2023
18e63c4
separate file for naming conventions
EgbertRijke Sep 21, 2023
efd8af3
separate file for naming conventions
EgbertRijke Sep 21, 2023
d8a9cd6
make pre-commit
EgbertRijke Sep 21, 2023
671b890
Merge branch 'master' of github.com:UniMath/agda-unimath into naming
EgbertRijke Sep 21, 2023
0b4e67b
explaining the naming of underlying objects
EgbertRijke Sep 21, 2023
1f470b1
make pre-commit
EgbertRijke Sep 21, 2023
3d521a8
Update NAMING.md
EgbertRijke Sep 21, 2023
92c28a4
fix broken links
EgbertRijke Sep 21, 2023
f1e82f9
Merge branch 'naming' of github.com:EgbertRijke/agda-unimath into naming
EgbertRijke Sep 21, 2023
d9ee159
sectioning
EgbertRijke Sep 21, 2023
e91cf2e
adding gregor
EgbertRijke Sep 21, 2023
0ab40db
make pre-commit
EgbertRijke Sep 21, 2023
a44bd45
further explaining our naming conventions
EgbertRijke Sep 22, 2023
2b17fa6
make pre-commit
EgbertRijke Sep 22, 2023
1d30aa6
further comments
EgbertRijke Sep 22, 2023
c922269
revised introduction
EgbertRijke Sep 22, 2023
4ac7ec8
update examples
EgbertRijke Sep 22, 2023
cc82fac
updating the general scheme
EgbertRijke Sep 22, 2023
e91085b
incorporating some of Vojtech's comments
EgbertRijke Sep 22, 2023
88a9226
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
74e0697
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
a8bfc8f
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
6f88244
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
fa770b4
make pre-commit
EgbertRijke Sep 22, 2023
633b471
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
bd3ed0b
make pre-commit
EgbertRijke Sep 22, 2023
0b27816
list of common descriptors
EgbertRijke Sep 22, 2023
63a0091
Update NAMING-CONVENTIONS.md
EgbertRijke Sep 22, 2023
1f95642
make pre-commit
EgbertRijke Sep 22, 2023
fdea201
equiv and htpy in the table
EgbertRijke Sep 22, 2023
693cb0f
work
EgbertRijke Sep 23, 2023
1fbc9b9
merge conflicts
EgbertRijke Sep 23, 2023
6006e80
explaining the goals
EgbertRijke Sep 23, 2023
81f66b8
predictability
EgbertRijke Sep 23, 2023
fce34cd
clarify use of
EgbertRijke Sep 23, 2023
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
9 changes: 9 additions & 0 deletions CODING-STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ the story. Here's how we handle indentation and line breaks in the
maintainability of the code, and you may find that it violates some of our
other conventions as well.

- Using the projection functions `pr1` and `pr2`, particularly their
compositions, can lead to short code, but we recommend to avoid doing so. When
constructions contain a lot of projections throughout their definition, the
projections reveal little of what is going on in that part of the projections.
We therefore prefer naming the projections. When a type of the form `Σ A B` is
given a name, naming its projections too can enhance readability and will
provide more informative responses when jumping to the definition.
Furthermore, it makes it easier to change the definition later on.

- The use of `where` blocks in definitions is perfectly fine but keeping them
short and specific to the definition of the current object is beneficial. Note
that definitions made in a `where` block in a definition cannot be reused
Expand Down
118 changes: 56 additions & 62 deletions NAMING-CONVENTIONS.md
EgbertRijke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ of conceptual understanding of your entries. The naming scheme should help
reveal common patterns in names, which hopefully helps to find predictable
namings for entries. On the other hand, we understand that this is not always
possible. If you find yourself not knowing what to name something, give it your
best shot to come up with a name, or reach out to us on the Univalent Agda
discord to ask if we have any suggestions.
best shot to come up with a name, or reach out to us on the
[Univalent Agda discord server](https://discord.gg/Zp2e8hYsuX) to ask if we have
any suggestions. One of the most commonly asked questions is what to name a
certain entry.

We also mention that the naming scheme of agda-unimath evolves as the library
grows. This implies that there are necessarily some inconsistencies in the
Expand Down Expand Up @@ -61,64 +63,71 @@ naming scheme aims for clarity and predictability.
In general, our naming scheme follows the pattern:

```text
[name]-[type]-[hypotheses]-[Namespace]
[descriptor]-[output-type]-[input-types]-[Namespace]
```

In this general pattern, all the components are optional. However, their order
is fixed and should be maintained for consistency.

The general naming pattern breaks down as follows:

- **[name]:** This part is used to give a custom descriptive name for the entry.
- **[type]:** This part of the name refers to the output type of the entry.
- **[hypotheses]:** This part of the name consists of descriptors for the
hypotheses used in the type specification of the entry.
- **[descriptor]:** This part is used to give a custom descriptive name for the
entry.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **[descriptor]:** This part is used to give a custom descriptive name for the
entry.
- **[descriptor]:** This part is used to give a custom descriptive name for the
entry, or refer to the custom descriptive name of another entry.

If I didn't misunderstand, this is how it is used in the below example is-iso-prop-hom-Ring.

- **[output-type]:** This part of the name refers to the output type of the
entry.
- **[input-types]:** This part of the name consists of references to the input
types used in the type specification of the entry.
- **[Namespace]:** This part of the name describes what important concept or
general category the entry is about.

Given Agda's current lack of a namespace mechanism, we've incorporated what
would typically be a namespace directly into the name. This convention is
Given Agda's current lack of a namespace mechanism, we can't have named logical
collection of definitions that span multiple files. Instead, we've incorporated
EgbertRijke marked this conversation as resolved.
Show resolved Hide resolved
what would typically be a namespace directly into the name. This convention is
particularly applied to key mathematical concepts, such as groups, rings,
categories, graphs, and trees.
categories, graphs, and trees, and so on.
EgbertRijke marked this conversation as resolved.
Show resolved Hide resolved

### Naming mathematical structures

We saw, for example, that the prediate `is-iso-hom-Ring` has the part `Ring`
capitalized. This signifies that the predicate is about rings. This name follows
the scheme `[name]-[hypotheses]-[Namespace]`. Note that there is also the entry
`is-iso-prop-hom-Ring`. This is a predicate that returns for each ring
the scheme `[descriptor]-[input-types]-[Namespace]`. Note that there is also the
entry `is-iso-prop-hom-Ring`. This is a predicate that returns for each ring
homomorphism the _proposition_ that it is an isomorphism, and therefore it
follows the scheme `[name]-[type]-[hypotheses]-[Namespace]`. Now we can guess
what a construction named `hom-iso-Ring` should be about: It should be a
construction that constructs the underlying homomorphism of an isomorphisms of
rings. This name follows the pattern `[type]-[hypotheses]-[Namespace]`.

There is also a common class of entries where we don't use the `[name]` part in
the name of an entry: underlying objects. For example, the underlying set of a
group is called `set-Group`, which uses the pattern `[type]-[Namespace]`. The
construction of the underlying set of a group returns for each group a set,
which is an element of type `Set`. Similarly, we have `type-Group]`,
`semigroup-Group`, `type-Ring`, `set-Ring`, and so on. Another instance where
this happens is in `hom-iso-Group`, which is the construction that returns the
underlying group homomorphism of an isomorphism of group. The fact that a group
isomorphism is an isomorphsim is called `is-iso-iso-Group`, which also uses the
pattern `[type]-[Namespace]`. One could also consider calling it
`is-iso-hom-iso-Group`, to emphasize that the underlying group homomorphism of
the isomorphism is an isomorphism. However, this name does not fit our patterns
in any way, and the addition of `hom` to the name adds no extra useful
information. This situation is common in instances where we omit the `[name]`
part of a name. For instance `is-category-Category` and `is-ideal-ideal-Ring`
follow the patterns `[type]-[Namespace]` and `[type]-[hypotheses]-[Namespace]`.
follows the scheme `[descriptor]-[output-type]-[input-types]-[Namespace]`. Now
we can guess what a construction named `hom-iso-Ring` should be about: It should
be a construction that constructs the underlying homomorphism of an isomorphisms
of rings. This name follows the pattern
`[output-type]-[input-types]-[Namespace]`.

There is also a common class of entries where we don't use the `[descriptor]`
part in the name of an entry: underlying objects. For example, the underlying
set of a group is called `set-Group`, which uses the pattern
`[output-type]-[Namespace]`. The construction of the underlying set of a group
returns for each group a set, which is an element of type `Set`. Similarly, we
have `type-Group`, `semigroup-Group`, `type-Ring`, `set-Ring`, and so on.
Another instance where this happens is in `hom-iso-Group`, which is the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't hom-iso-Group an instance of [output-type]-[input-types]-[Namespace]?

construction that returns the underlying group homomorphism of an isomorphism of
group. The fact that a group isomorphism is an isomorphsim is called
`is-iso-iso-Group`, which also uses the pattern `[output-type]-[Namespace]`. One
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this also an instance of [output-type]-[input-types]-[Namespace]?

could also consider calling it `is-iso-hom-iso-Group`, to emphasize that the
underlying group homomorphism of the isomorphism is an isomorphism. However,
this name does not fit our patterns in any way, and the addition of `hom` to the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me how this does not fit our patterns better than the proposed one. Also, the name would be more consistent with is-iso-hom-inv-iso-Group

name adds no extra useful information. This situation is common in instances
fredrik-bakke marked this conversation as resolved.
Show resolved Hide resolved
where we omit the `[descriptor]` part of a name. For instance
`is-category-Category` and `is-ideal-ideal-Ring` follow the patterns
`[output-type]-[Namespace]` and `[output-type]-[input-types]-[Namespace]`,
Copy link
Collaborator

@VojtechStep VojtechStep Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second reading I'm not sure why

  • is-category-Category : (C : Category) -> is-category C and
  • is-ideal-ideal-Ring : (I : ideal-Ring) -> is-ideal I

are different? Even the modules where they are defined seem to follow the exact same structure.

respectively.

Another class of entries where the naming scheme needs some explanation, is
where we define a structured object from another structured object. For
instance, the [kernel](group-theory.kernels.md) of a
[group homomorphism](group-theory.homomorphisms-groups.md) is defined to be the
[normal subgroup](group-theory.normal-subgroups.md) `kernel-hom-Group`. This
name follows the scheme `[name]-[hypotheses]-[Namespace]`. When we want to
define the underlying structure of the kernel of a group homomorphism, we follow
the scheme `[type]-[hypotheses]-[Namespace]`. For instance, the underlying group
of the kernel of a group homomorphism is called `group-kernel-hom-Group`.
name follows the scheme `[descriptor]-[input-types]-[Namespace]`. When we want
to define the underlying structure of the kernel of a group homomorphism, we
follow the scheme `[output-type]-[input-types]-[Namespace]`. For instance, the
underlying group of the kernel of a group homomorphism is called
`group-kernel-hom-Group`.

### Naming conventions for mathematical laws

Expand All @@ -129,8 +138,8 @@ stated as `left-unit-law` and `right-unit-law`. The fact that
[multiplication on the integers](elementary-number-theory.multiplication-integers.md)
satisfies the unit laws is then stated as `left-unit-law-mul-ℤ` and
`right-unit-law-mul-ℤ`. In the general naming scheme, this naming follows the
pattern `[type]-[Namespace]`, because it states the type of which an element is
constructed, and we treat `ℤ` as a namespace.
pattern `[output-type]-[Namespace]`, because it states the type of which an
element is constructed, and we treat `ℤ` as a namespace.

For a second example, `interchange-law` states what it means to satisfy the
[interchange law](foundation.interchange-law.md). This interchange law requires
Expand All @@ -142,7 +151,7 @@ the same. For example, in the [integers](elementary-number-theory.integers.md)
there is an interchange law for addition over addition, which states that
`(a + b) + (c + d) = (a + c) + (b + d)`. This law is called
`interchange-law-add-add-ℤ`. Again, this naming follows the pattern
`[type]-[Namespace]`, because it states the type of which an element is
`[output-type]-[Namespace]`, because it states the type of which an element is
constructed.

### Further naming conventions for operations on types
Expand Down Expand Up @@ -191,11 +200,7 @@ pointwise equal to `tr-Ω` as `compute-tr-Ω`.
[full width equals sign](https://codepoints.net/U+ff1d) for the identity type,
as the standard equals sign is a reserved symbol in Agda.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also mention the homotopy composition and whiskering situation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other examples are the asterisk vs asterisk operator, and big vee vs small vee. Maybe rephrase to "try to avoid subtly different"


If you are unsure about what to name your entry, ask us on the Univalent Agda
discord server. One of the most commonly asked questions is what to name a
certain thing.

## Naming conventions we try to avoid
## Naming practices we try to avoid

- Abbreviations might seem like a good way to shorten names, but we use them
sparingly. They might save a couple of keystrokes for the author, but in the
Expand All @@ -212,23 +217,12 @@ certain thing.
and not `commutative-×`, and the unit of a modality is called `unit-modality`
and not `unit-○`.

- To enhance conceptual clarity, we suggest names of constructions avoid
- To improve conceptual clarity, we suggest names of constructions avoid
referring to variable names. This makes code more understandable, even at a
glance, and easier to work with in subsequent code.

- Using the projection functions `pr1` and `pr2`, particularly their
compositions, can lead to short code, but we recommend to avoid doing so. When
constructions contain a lot of projections throughout their definition, the
projections reveal little of what is going on in that part of the projections.
We therefore prefer naming the projections. When a type of the form `Σ A B` is
given a name, naming its projections too can enhance readability and will
provide more informative responses when jumping to the definition.
Furthermore, it makes it easier to change the definition later on.

- Lastly, we recommend not naming constructions after infix notation of
operations included in them. Preferring primary prefix notation over infix
notation can help keep our code consistent. For example, it's preferred to use
`commutative-prod` instead of `commutative-×` for denoting the commutativity
of cartesian products.

- Names never reference variables.
- Names never reference variables. For example, `G`-sets are called
[group actions](group-theory.group-actions.md) in our library. The type of all
group actions on a given group `G` is called `Abstract-Group-Action`. This
name also contains the prefix `Abstract` in order to disambiguate from
[concrete group actions](group-theory.concrete-group-actions.md).