-
Notifications
You must be signed in to change notification settings - Fork 251
initial+terminal algebras #1902
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
69d0dff
refactored `Algebra.Construct.Zero` into `Initial` and `Terminal`
jamesmckinna 92305c2
added `Algebra.Construct.Initial` and `Terminal`
jamesmckinna 0d2a36d
refactored `Zero` for modules
jamesmckinna 22b5b22
consistency between sources
jamesmckinna e54f2a7
`CHANGELOG`
jamesmckinna 3891c16
removed unnecessary imports from `Data.Unit`
jamesmckinna 7c592c1
Matthew's feedback
jamesmckinna 83cb803
capitalise comments
jamesmckinna 46aa741
reorder declarations in `𝕆ne`
jamesmckinna 5fbceb2
fixed `Algebra.Module.Construct.Zero`
jamesmckinna 579e6df
fix whitespace
jamesmckinna 88ca243
Capitalise comments
jamesmckinna d8117f7
I think I have understood record/module infernce a bit better now
jamesmckinna 19181c0
forgot `Algebra.Module.Construct.Zero`
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 hidden or 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 hidden or 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,97 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Instances of algebraic structures where the carrier is ⊥. | ||
-- In mathematics, this is usually called 0. | ||
-- | ||
-- From monoids up, these are zero-objects – i.e, the initial | ||
-- object is the terminal object in the relevant category. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --without-K --safe #-} | ||
|
||
open import Level using (Level) | ||
|
||
module Algebra.Construct.Initial {c ℓ : Level} where | ||
|
||
open import Algebra.Bundles | ||
using (Magma; Semigroup; Band) | ||
open import Algebra.Bundles.Raw | ||
using (RawMagma) | ||
open import Algebra.Core using (Op₂) | ||
open import Algebra.Definitions using (Congruent₂) | ||
open import Algebra.Structures using (IsMagma; IsSemigroup; IsBand) | ||
open import Data.Empty.Polymorphic | ||
open import Relation.Binary using (Rel; Reflexive; Symmetric; Transitive; IsEquivalence) | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Re-export those algebras which are also terminal | ||
|
||
open import Algebra.Construct.Terminal {c} {ℓ} public | ||
hiding (rawMagma; magma; semigroup; band) | ||
|
||
------------------------------------------------------------------------ | ||
-- Gather all the functionality in one place | ||
|
||
module ℤero where | ||
|
||
infixl 7 _∙_ | ||
infix 4 _≈_ | ||
|
||
Carrier : Set c | ||
Carrier = ⊥ | ||
|
||
_≈_ : Rel Carrier ℓ | ||
_≈_ () | ||
|
||
_∙_ : Op₂ Carrier | ||
_∙_ () | ||
|
||
refl : Reflexive _≈_ | ||
refl {x = ()} | ||
|
||
sym : Symmetric _≈_ | ||
sym {x = ()} | ||
|
||
trans : Transitive _≈_ | ||
trans {i = ()} | ||
|
||
∙-cong : Congruent₂ _≈_ _∙_ | ||
∙-cong {x = ()} | ||
|
||
open ℤero | ||
|
||
------------------------------------------------------------------------ | ||
-- Raw bundles | ||
|
||
rawMagma : RawMagma c ℓ | ||
rawMagma = record { ℤero } | ||
|
||
------------------------------------------------------------------------ | ||
-- Structures | ||
|
||
isEquivalence : IsEquivalence _≈_ | ||
isEquivalence = record { ℤero } | ||
|
||
isMagma : IsMagma _≈_ _∙_ | ||
isMagma = record { isEquivalence = isEquivalence ; ∙-cong = ∙-cong } | ||
|
||
isSemigroup : IsSemigroup _≈_ _∙_ | ||
isSemigroup = record { isMagma = isMagma ; assoc = λ () } | ||
|
||
isBand : IsBand _≈_ _∙_ | ||
isBand = record { isSemigroup = isSemigroup ; idem = λ () } | ||
|
||
------------------------------------------------------------------------ | ||
-- Bundles | ||
|
||
magma : Magma c ℓ | ||
magma = record { isMagma = isMagma } | ||
|
||
semigroup : Semigroup c ℓ | ||
semigroup = record { isSemigroup = isSemigroup } | ||
|
||
band : Band c ℓ | ||
band = record { isBand = isBand } | ||
|
This file contains hidden or 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,86 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Instances of algebraic structures where the carrier is ⊤. | ||
-- In mathematics, this is usually called 0 (1 in the case of Group). | ||
-- | ||
-- From monoids up, these are zero-objects – i.e, both the initial | ||
-- and the terminal object in the relevant category. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --without-K --safe #-} | ||
|
||
open import Level using (Level) | ||
|
||
module Algebra.Construct.Terminal {c ℓ : Level} where | ||
|
||
open import Algebra.Bundles | ||
open import Data.Unit.Polymorphic | ||
open import Relation.Binary.Core using (Rel) | ||
|
||
------------------------------------------------------------------------ | ||
-- Gather all the functionality in one place | ||
|
||
module 𝕆ne where | ||
|
||
infix 4 _≈_ | ||
Carrier : Set c | ||
Carrier = ⊤ | ||
|
||
_≈_ : Rel Carrier ℓ | ||
_ ≈ _ = ⊤ | ||
|
||
------------------------------------------------------------------------ | ||
-- Raw bundles | ||
|
||
rawMagma : RawMagma c ℓ | ||
rawMagma = record { 𝕆ne } | ||
|
||
rawMonoid : RawMonoid c ℓ | ||
rawMonoid = record { 𝕆ne } | ||
|
||
rawGroup : RawGroup c ℓ | ||
rawGroup = record { 𝕆ne } | ||
|
||
rawSemiring : RawSemiring c ℓ | ||
rawSemiring = record { 𝕆ne } | ||
|
||
rawRing : RawRing c ℓ | ||
rawRing = record { 𝕆ne } | ||
|
||
------------------------------------------------------------------------ | ||
-- Bundles | ||
|
||
magma : Magma c ℓ | ||
magma = record { 𝕆ne } | ||
|
||
semigroup : Semigroup c ℓ | ||
semigroup = record { 𝕆ne } | ||
|
||
band : Band c ℓ | ||
band = record { 𝕆ne } | ||
|
||
commutativeSemigroup : CommutativeSemigroup c ℓ | ||
commutativeSemigroup = record { 𝕆ne } | ||
|
||
monoid : Monoid c ℓ | ||
monoid = record { 𝕆ne } | ||
|
||
commutativeMonoid : CommutativeMonoid c ℓ | ||
commutativeMonoid = record { 𝕆ne } | ||
|
||
idempotentCommutativeMonoid : IdempotentCommutativeMonoid c ℓ | ||
idempotentCommutativeMonoid = record { 𝕆ne } | ||
|
||
group : Group c ℓ | ||
group = record { 𝕆ne } | ||
|
||
abelianGroup : AbelianGroup c ℓ | ||
abelianGroup = record { 𝕆ne } | ||
|
||
semiring : Semiring c ℓ | ||
semiring = record { 𝕆ne } | ||
|
||
ring : Ring c ℓ | ||
ring = record { 𝕆ne } | ||
|
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.