agda / cubical

An experimental library for Cubical Agda
https://agda.github.io/cubical/Cubical.README.html
Other
451 stars 138 forks source link

Naming convention for algebra related code #403

Closed mortberg closed 2 years ago

mortberg commented 4 years ago

It would be nice if all the algebra would be using some more consistent naming schema. Here's a suggestion that we are more or less following:

I'm not sure about how to name lemmas like these: https://github.com/agda/cubical/blob/master/Cubical/Structures/Ring.agda#L272

This should be implemented after https://github.com/agda/cubical/pull/401

mchristianl commented 4 years ago

Would it be "safe" to rename every occurrence of _*_ to _·_ in the Cubical/Algebra subdirectory?

mortberg commented 4 years ago

Would it be "safe" to rename every occurrence of _*_ to _·_ in the Cubical/Algebra subdirectory?

Sure! I think this should be the name for multiplication of numbers as well

mortberg commented 4 years ago

(just to be clear, it's \cdot not \.)

mchristianl commented 4 years ago

The * is currently used in

Where I would replace it with \cdot in the fat marked parts. What about HITs/S1?

mortberg commented 4 years ago

I agree with all the fat marked parts. For the circle I think it's bad style that there is a definition rot which is then renamed to an operator. There should only be one of these, so please open another issue about this and leave it as it is for now.

mchristianl commented 4 years ago

I found that there are a lot algebraic properties that "preserve" or "reflect" a relation. The non-cubical standard library defines preservation like

_on_ : (B → B → C) → (A → B) → (A → A → C)
_*_ on f = f -⟨ _*_ ⟩- f

_=[_]⇒_ : Rel A ℓ₁ → (A → B) → Rel B ℓ₂ → Set _
P =[ f ]⇒ Q = P ⇒ (Q on f)

_Preserves_⟶_ : (A → B) → Rel A ℓ₁ → Rel B ℓ₂ → Set _
f Preserves P ⟶ Q = P =[ f ]⇒ Q

where _on_ is built up here.

In my own code, I've settled with a naming scheme like

suc-preserves-< : ∀ a b → a < b → suc a < suc b
suc-reflects-< : ∀ a b → suc a < suc b → a < b
suc-creates-< : ∀ a b → (suc a < suc b) ⇔ (a < b)

where the nomer "creates" was a hint from the agda irc channel.

Would such a naming scheme be applicable for the cubical standard library?

PS: The non-cubical standard library seems to use the nomer "mono" for such properties

pred-mono : pred Preserves _≤_ ⟶ _≤_

and uses "reflects" differently

-- The truth value of P is reflected by a boolean value.
data Reflects {p} (P : Set p) : Bool → Set p where
  ofʸ : ( p :   P) → Reflects P true
  ofⁿ : (¬p : ¬ P) → Reflects P false
mortberg commented 2 years ago

Leaving this open for now, but should be fixed very soon by