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

Add bundled homomorphisms #2383

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fe3fea0
Bundle `Algebra.Morphism`s
jamesmckinna May 7, 2024
a33cff6
more bundles!
jamesmckinna May 8, 2024
ca14ed9
`RingWithoutOne` now exports a `RawRingWithoutOne` field
jamesmckinna May 15, 2024
a5f8c0e
disambiguation error when trying to add `RingWithoutOneHomomorphism` …
jamesmckinna May 15, 2024
7d9649c
FIXED: disambiguation error when trying to add `RingWithoutOneHomomor…
jamesmckinna May 15, 2024
a4a1549
add `rawKleeneAlgebra`
jamesmckinna May 16, 2024
32682ce
add `KleeneAlgebra`, `Quasigroup`, and `Lopp` homomorphisms
jamesmckinna May 16, 2024
59474ac
add bundled `Identity` homomorphisms
jamesmckinna May 16, 2024
6c8459f
avoid name clash: remove `open`ing of sub-homomorphism bundles
jamesmckinna May 16, 2024
df9b2da
add bundled `Composition` of homomorphisms
jamesmckinna May 16, 2024
6c44f5b
more exported sub-bundles
jamesmckinna May 16, 2024
150daaa
removed redundant anonymous `module`s
jamesmckinna May 16, 2024
454d8ed
removed redundant anonymous `module`s
jamesmckinna May 16, 2024
04fa1f4
add `isNearSemiring` to `IsRingWithoutOne` plus knock-on re-exports
jamesmckinna May 17, 2024
71e8e2e
add `nearSemiring` to `RingWithoutOne` plus knock-on re-exports
jamesmckinna May 17, 2024
8e1c8a1
add `rawNearSemiring` to `RingWithoutOne` plus knock-on re-exports
jamesmckinna May 17, 2024
da9b808
lots more exported sub-structures and sub-bundles
jamesmckinna May 17, 2024
6d1c1c1
fix bug: restrict exports
jamesmckinna May 17, 2024
88aa9f6
lots more exported sub-structures and sub-bundles
jamesmckinna May 17, 2024
deff25f
Merge branch 'master' into bundled-homomorphisms
jamesmckinna May 31, 2024
6c31fde
refactor: `RawX` parameterisation
jamesmckinna Jun 12, 2024
38fb861
knock-on: `Identity` takes a full `Bundle`
jamesmckinna Jun 12, 2024
08624e5
tighten imports
jamesmckinna Jun 12, 2024
52ab68a
knock-on: `Composition` takes full `Bundle`s
jamesmckinna Jun 12, 2024
3409e84
`CHANGELOG`
jamesmckinna Jun 12, 2024
2677916
Merge branch 'master' into bundled-homomorphisms
jamesmckinna Jun 12, 2024
dfb67c9
`fix-whitespace`
jamesmckinna Jun 12, 2024
1e8c3d3
Merge branch 'master' into bundled-homomorphisms
jamesmckinna Jun 13, 2024
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ New modules
Algebra.Module.Bundles.Raw
```

* Bundled morphisms between algebraic structures:
```
Algebra.Morphism.Bundles
```

* Prime factorisation of natural numbers.
```
Data.Nat.Primality.Factorisation
Expand Down Expand Up @@ -185,6 +190,11 @@ Additions to existing modules
+-rawGroup : RawGroup _ _
```

* Exporting `RawRingWithoutOne` substructure from `Algebra.Bundles.RingWithoutOne`:
```agda
rawRingWithoutOne : RawRingWithoutOne _ _
```

* In `Algebra.Construct.Terminal`:
```agda
rawNearSemiring : RawNearSemiring c ℓ
Expand Down
24 changes: 19 additions & 5 deletions src/Algebra/Bundles.agda
Original file line number Diff line number Diff line change
Expand Up @@ -868,20 +868,34 @@ record RingWithoutOne c ℓ : Set (suc (c ⊔ ℓ)) where

open IsRingWithoutOne isRingWithoutOne public

rawRingWithoutOne : RawRingWithoutOne _ _
rawRingWithoutOne = record
{ Carrier = Carrier
; _≈_ = _≈_
; _+_ = _+_
; _*_ = _*_
; -_ = -_
; 0# = 0#
}

open RawRingWithoutOne rawRingWithoutOne public

+-abelianGroup : AbelianGroup _ _
+-abelianGroup = record { isAbelianGroup = +-isAbelianGroup }

*-semigroup : Semigroup _ _
*-semigroup = record { isSemigroup = *-isSemigroup }

open AbelianGroup +-abelianGroup public
using () renaming (group to +-group; invertibleMagma to +-invertibleMagma; invertibleUnitalMagma to +-invertibleUnitalMagma)
using ()
renaming (group to +-group;
invertibleMagma to +-invertibleMagma;
invertibleUnitalMagma to +-invertibleUnitalMagma)

open Semigroup *-semigroup public
using () renaming
( rawMagma to *-rawMagma
; magma to *-magma
)
using ()
renaming (magma to *-magma)


------------------------------------------------------------------------
-- Bundles with 2 binary operations, 1 unary operation & 2 elements
Expand Down
176 changes: 176 additions & 0 deletions src/Algebra/Morphism/Bundles.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Bundled definitions of homomorphisms between algebras
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

module Algebra.Morphism.Bundles where

open import Algebra.Bundles -- using (Magma)
open import Algebra.Morphism.Structures -- using (IsMagmaHomomorphism)
open import Level using (Level; suc; _⊔_)
open import Relation.Binary.Morphism using (IsRelHomomorphism)
open import Relation.Binary.Morphism.Bundles using (SetoidHomomorphism)

private
variable
ℓ a ℓa b ℓb : Level


------------------------------------------------------------------------
-- Morphisms between Magmas
------------------------------------------------------------------------

record MagmaHomomorphism (A : Magma a ℓa) (B : Magma b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a brief comment documenting why you decided to use Bundles here instead of the RawBundles used by the morphism structures? Having thought about it for all of a minute, it's not terribly obvious to me why we should make the switch. In particular, these morphisms are often used to transfer properties from one structure, e.g. a magma, to prove that another structure is also a magma. Assuming that they're both a magma to starts with, prevents you from using these morphisms for that purpose.

Copy link
Contributor Author

@jamesmckinna jamesmckinna Jun 5, 2024

Choose a reason for hiding this comment

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

Oh-ho-ho! Good catch... will have to go back to the drawing board and scratch my head for a bit.

My first (worst?) thought is that such a use case could be handled via the already-existing IsMagmaHomomorphism infrastructure... but I have not tested that conjecture (related to @Taneb 's #2276 on Monomorphisms?)... while the specific PR (#1962 ) which gave rise to (the use case giving rise to) this PR does already have the two Magma bundles at hand... and I'd never reconsidered that state of affairs...

Copy link
Contributor

Choose a reason for hiding this comment

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

So yes, it can (and is!) handled by IsMagmaHomomorphism and co. The question is what does making them Bundles instead of RawBundles actually gains us? I can only see downsides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'm convinced: but there's a knock-on consequence... : we can no longer define a SetoidHomomorphism manifest field at the bottom of the hierarchy... and probably Relation.Morphism.Bundles should be refactored to reflect (the eventual introduction of) RawSetoid as index for SetoidHomomorphism... ;-) cf. your #1464 / commit 9816023

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More knock-on:

  • For Algebra.Morphism.Construct.Identity, we need refl for IsXHomomorphism, so do we parametrise by xHomomorphism by the full X bundle, or the RawX bundle, with an explicit refl witness...?
  • Ditto. with trans for Algebra.Morphism.Construct.Composition...

Advice welcome!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Latest commits:

  • RawX bundle for the definition
  • X bundle for the Constructions

private
module A = Magma A
module B = Magma B

field
⟦_⟧ : A.Carrier → B.Carrier

isMagmaHomomorphism : IsMagmaHomomorphism A.rawMagma B.rawMagma ⟦_⟧

open IsMagmaHomomorphism isMagmaHomomorphism public

setoidHomomorphism : SetoidHomomorphism A.setoid B.setoid
setoidHomomorphism = record { isRelHomomorphism = isRelHomomorphism }

------------------------------------------------------------------------
-- Morphisms between Monoids
------------------------------------------------------------------------

record MonoidHomomorphism (A : Monoid a ℓa) (B : Monoid b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
private
module A = Monoid A
module B = Monoid B

field
⟦_⟧ : A.Carrier → B.Carrier

isMonoidHomomorphism : IsMonoidHomomorphism A.rawMonoid B.rawMonoid ⟦_⟧

open IsMonoidHomomorphism isMonoidHomomorphism public

magmaHomomorphism : MagmaHomomorphism A.magma B.magma
magmaHomomorphism = record { isMagmaHomomorphism = isMagmaHomomorphism }

open MagmaHomomorphism magmaHomomorphism public

------------------------------------------------------------------------
-- Morphisms between Groups
------------------------------------------------------------------------

record GroupHomomorphism (A : Group a ℓa) (B : Group b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
private
module A = Group A
module B = Group B

field
⟦_⟧ : A.Carrier → B.Carrier

isGroupHomomorphism : IsGroupHomomorphism A.rawGroup B.rawGroup ⟦_⟧

open IsGroupHomomorphism isGroupHomomorphism public

monoidHomomorphism : MonoidHomomorphism A.monoid B.monoid
monoidHomomorphism = record { isMonoidHomomorphism = isMonoidHomomorphism }
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved

open MonoidHomomorphism monoidHomomorphism public

------------------------------------------------------------------------
-- Morphisms between NearSemirings
------------------------------------------------------------------------

record NearSemiringHomomorphism (A : NearSemiring a ℓa) (B : NearSemiring b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
private
module A = NearSemiring A
module B = NearSemiring B

field
⟦_⟧ : A.Carrier → B.Carrier

isNearSemiringHomomorphism : IsNearSemiringHomomorphism A.rawNearSemiring B.rawNearSemiring ⟦_⟧

open IsNearSemiringHomomorphism isNearSemiringHomomorphism public

+-monoidHomomorphism : MonoidHomomorphism A.+-monoid B.+-monoid
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
+-monoidHomomorphism = record { isMonoidHomomorphism = +-isMonoidHomomorphism }

open MonoidHomomorphism +-monoidHomomorphism public

*-magmaHomomorphism : MagmaHomomorphism A.*-magma B.*-magma
*-magmaHomomorphism = record { isMagmaHomomorphism = *-isMagmaHomomorphism }

------------------------------------------------------------------------
-- Morphisms between Semirings
------------------------------------------------------------------------

record SemiringHomomorphism (A : Semiring a ℓa) (B : Semiring b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
private
module A = Semiring A
module B = Semiring B

field
⟦_⟧ : A.Carrier → B.Carrier

isSemiringHomomorphism : IsSemiringHomomorphism A.rawSemiring B.rawSemiring ⟦_⟧

open IsSemiringHomomorphism isSemiringHomomorphism public

*-monoidHomomorphism : MonoidHomomorphism A.*-monoid B.*-monoid
*-monoidHomomorphism = record { isMonoidHomomorphism = *-isMonoidHomomorphism }

open MonoidHomomorphism *-monoidHomomorphism public

------------------------------------------------------------------------
-- Morphisms between RingWithoutOnes
------------------------------------------------------------------------

record RingWithoutOneHomomorphism (A : RingWithoutOne a ℓa) (B : RingWithoutOne b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
private
module A = RingWithoutOne A
module B = RingWithoutOne B

field
⟦_⟧ : _ → _ -- A.Carrier → B.Carrier causes an disambiguation error!?
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
isRingWithoutOneHomomorphism : IsRingWithoutOneHomomorphism A.rawRingWithoutOne B.rawRingWithoutOne ⟦_⟧

open IsRingWithoutOneHomomorphism isRingWithoutOneHomomorphism public

+-groupHomomorphism : GroupHomomorphism A.+-group B.+-group
+-groupHomomorphism = record { isGroupHomomorphism = +-isGroupHomomorphism }

open GroupHomomorphism +-groupHomomorphism public

*-magmaHomomorphism : MagmaHomomorphism A.*-magma B.*-magma
*-magmaHomomorphism = record { isMagmaHomomorphism = *-isMagmaHomomorphism }

open MagmaHomomorphism *-magmaHomomorphism public
hiding (setoidHomomorphism)

------------------------------------------------------------------------
-- Morphisms between Rings
------------------------------------------------------------------------

record RingHomomorphism (A : Ring a ℓa) (B : Ring b ℓb) : Set (a ⊔ b ⊔ ℓa ⊔ ℓb) where
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
private
module A = Ring A
module B = Ring B

field
⟦_⟧ : A.Carrier → B.Carrier
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
isRingHomomorphism : IsRingHomomorphism A.rawRing B.rawRing ⟦_⟧

open IsRingHomomorphism isRingHomomorphism public

+-groupHomomorphism : GroupHomomorphism A.+-group B.+-group
+-groupHomomorphism = record { isGroupHomomorphism = +-isGroupHomomorphism }

open GroupHomomorphism +-groupHomomorphism public

*-monoidHomomorphism : MonoidHomomorphism A.*-monoid B.*-monoid
*-monoidHomomorphism = record { isMonoidHomomorphism = *-isMonoidHomomorphism }

Loading