-
Notifications
You must be signed in to change notification settings - Fork 234
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
jamesmckinna
wants to merge
28
commits into
agda:master
Choose a base branch
from
jamesmckinna:bundled-homomorphisms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 a33cff6
more bundles!
jamesmckinna ca14ed9
`RingWithoutOne` now exports a `RawRingWithoutOne` field
jamesmckinna a5f8c0e
disambiguation error when trying to add `RingWithoutOneHomomorphism` …
jamesmckinna 7d9649c
FIXED: disambiguation error when trying to add `RingWithoutOneHomomor…
jamesmckinna a4a1549
add `rawKleeneAlgebra`
jamesmckinna 32682ce
add `KleeneAlgebra`, `Quasigroup`, and `Lopp` homomorphisms
jamesmckinna 59474ac
add bundled `Identity` homomorphisms
jamesmckinna 6c8459f
avoid name clash: remove `open`ing of sub-homomorphism bundles
jamesmckinna df9b2da
add bundled `Composition` of homomorphisms
jamesmckinna 6c44f5b
more exported sub-bundles
jamesmckinna 150daaa
removed redundant anonymous `module`s
jamesmckinna 454d8ed
removed redundant anonymous `module`s
jamesmckinna 04fa1f4
add `isNearSemiring` to `IsRingWithoutOne` plus knock-on re-exports
jamesmckinna 71e8e2e
add `nearSemiring` to `RingWithoutOne` plus knock-on re-exports
jamesmckinna 8e1c8a1
add `rawNearSemiring` to `RingWithoutOne` plus knock-on re-exports
jamesmckinna da9b808
lots more exported sub-structures and sub-bundles
jamesmckinna 6d1c1c1
fix bug: restrict exports
jamesmckinna 88aa9f6
lots more exported sub-structures and sub-bundles
jamesmckinna deff25f
Merge branch 'master' into bundled-homomorphisms
jamesmckinna 6c31fde
refactor: `RawX` parameterisation
jamesmckinna 38fb861
knock-on: `Identity` takes a full `Bundle`
jamesmckinna 08624e5
tighten imports
jamesmckinna 52ab68a
knock-on: `Composition` takes full `Bundle`s
jamesmckinna 3409e84
`CHANGELOG`
jamesmckinna 2677916
Merge branch 'master' into bundled-homomorphisms
jamesmckinna dfb67c9
`fix-whitespace`
jamesmckinna 1e8c3d3
Merge branch 'master' into bundled-homomorphisms
jamesmckinna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 } | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 theRawBundles
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.There was a problem hiding this comment.
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 onMonomorphism
s?)... while the specific PR (#1962 ) which gave rise to (the use case giving rise to) this PR does already have the twoMagma
bundles at hand... and I'd never reconsidered that state of affairs...There was a problem hiding this comment.
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 themBundles
instead ofRawBundles
actually gains us? I can only see downsides.There was a problem hiding this comment.
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 probablyRelation.Morphism.Bundles
should be refactored to reflect (the eventual introduction of)RawSetoid
as index forSetoidHomomorphism
... ;-) cf. your #1464 / commit 9816023There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More knock-on:
Algebra.Morphism.Construct.Identity
, we needrefl
forIsXHomomorphism
, so do we parametrise byxHomomorphism
by the fullX
bundle, or theRawX
bundle, with an explicitrefl
witness...?trans
forAlgebra.Morphism.Construct.Composition
...Advice welcome!
There was a problem hiding this comment.
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 definitionX
bundle for theConstruct
ions