Skip to content

IsCommutativeMonoid should use IsMonoid not IsSemigroup #239

Closed
@MatthewDaggitt

Description

@MatthewDaggitt

Obviously Maybe a case of mis-subclassing. It leads to unobvious requirements and also makes the record much longer than it needs to be.

record IsCommutativeMonoid {a ℓ} {A : Set a} (≈ : Rel A ℓ)
(_∙_ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
open FunctionProperties
field
isSemigroup : IsSemigroup ≈ _∙_
identityˡ : LeftIdentity ε _∙_
comm : Commutative _∙_

Activity

MatthewDaggitt

MatthewDaggitt commented on Mar 12, 2018

@MatthewDaggitt
ContributorAuthor

Likewise with IsCommutativeSemiring

gallais

gallais commented on Mar 12, 2018

@gallais
Member

I think the point of this is that an IsCommutativeX can be used anywhere an X is
expected thanks to subtyping. Not sure whether it'd still be the case if everything was
packed up in a subfield.

That being said, I'm not sure how useful the subtyping aspect is.

MatthewDaggitt

MatthewDaggitt commented on Mar 12, 2018

@MatthewDaggitt
ContributorAuthor

Ooh I hadn't considered that. Apologies for my too hasty comment.

Hang on, does that mean identityˡ : LeftIdentity ε _∙_ is a subtype of identity : Identity ε ∙?

andreasabel

andreasabel commented on Mar 12, 2018

@andreasabel
Member

I could imagine the reason is that in the presence of commutativity, left identity implies right identity, thus, there is less proof obligations to build a commutative monoid.

Unless there are strong reasons for change, I'd advise to leave it as-is. (Maybe add documentation to not fall into the same trap again.)

MatthewDaggitt

MatthewDaggitt commented on Mar 16, 2018

@MatthewDaggitt
ContributorAuthor

Unless there are strong reasons for change, I'd advise to leave it as-is. (Maybe add documentation to not fall into the same trap again.)

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @gallais@andreasabel@MatthewDaggitt

      Issue actions

        `IsCommutativeMonoid` should use `IsMonoid` not `IsSemigroup` · Issue #239 · agda/agda-stdlib