-
Notifications
You must be signed in to change notification settings - Fork 246
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
[fixes #1363] Add Algebra.Literals
#2264
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Algebra Literals, from a PointedMonoid bundle | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Algebra.Bundles.Pointed | ||
|
||
module Algebra.Bundles.Literals | ||
{c ℓ} (pointedMonoid : PointedMonoid c ℓ) | ||
where | ||
|
||
open PointedMonoid pointedMonoid | ||
|
||
-- Re-export `Number` instance defined in Algebra.Structures.Literals | ||
|
||
open import Algebra.Structures.Literals isPointedMonoid public using (number) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- `Pointed` intermediate between `Monoid` and `SemiringWithoutAnnihilatingZero` | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Algebra.Bundles | ||
open import Algebra.Bundles.Raw | ||
open import Algebra.Core | ||
open import Algebra.Structures.Pointed as Pointed using (IsPointedMonoid) | ||
import Algebra.Properties.Monoid.Mult as Mult | ||
open import Data.Nat.Base as ℕ using (ℕ) | ||
open import Data.Unit.Base | ||
open import Level using (Level; suc; _⊔_; Lift) | ||
open import Relation.Binary.Core using (Rel) | ||
|
||
module Algebra.Bundles.Pointed where | ||
|
||
private | ||
variable | ||
c ℓ : Level | ||
|
||
------------------------------------------------------------------------ | ||
-- Bundles with 1 binary operation & 2 elements | ||
------------------------------------------------------------------------ | ||
|
||
record PointedMonoid c ℓ : Set (suc (c ⊔ ℓ)) where | ||
field | ||
rawMonoid : RawMonoid c ℓ | ||
open RawMonoid rawMonoid using (Carrier) | ||
field | ||
• : Carrier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment "1 binary operation & 2 elements" is correct, but the rest of the names ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much to think about here. Ever since my abortive The two points in ... that said, So from my POV, I'd want to keep things more cleanly separated... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: they do "make sense", but they are not necessarily sufficiently useful. Phrased that way, I'd say that our current state of knowledge makes this true. [Usefulness is a temporal quality, not absolute.] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The next question is: that extra point, is it meant to be preserved by homomorphisms or not? If not, then rather than Of course, a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also an excellent observation (although I'm still insufficently homotopically-inclined to arbitrate on the last point). I think that points should be preserved (esp. in this setting, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
isPointedMonoid : IsPointedMonoid rawMonoid • | ||
|
||
open IsPointedMonoid isPointedMonoid public | ||
|
||
------------------------------------------------------------------------ | ||
-- instance from any SemiringWithoutAnnihilatingZero | ||
|
||
pointedMonoid : SemiringWithoutAnnihilatingZero c ℓ → PointedMonoid c ℓ | ||
pointedMonoid semiringWithoutAnnihilatingZero | ||
= record { isPointedMonoid = isPointedMonoid } | ||
where | ||
open SemiringWithoutAnnihilatingZero semiringWithoutAnnihilatingZero | ||
using (1#; +-rawMonoid; +-isMonoid) | ||
isPointedMonoid : IsPointedMonoid +-rawMonoid 1# | ||
isPointedMonoid = record { isMonoid = +-isMonoid } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Algebra Literals, from a SemiringWithoutAnnihilatingZero | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Algebra.Bundles using (SemiringWithoutAnnihilatingZero) | ||
|
||
module Algebra.Literals {c ℓ} | ||
(semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero c ℓ) | ||
where | ||
|
||
open import Algebra.Bundles.Pointed | ||
|
||
-- Re-export `Number` instance defined in Algebra.Bundles.Literals | ||
|
||
open import Algebra.Bundles.Literals | ||
(pointedMonoid semiringWithoutAnnihilatingZero) public using (number) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Algebra Literals | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Algebra.Bundles.Raw | ||
open import Algebra.Structures.Pointed | ||
|
||
module Algebra.Structures.Literals | ||
{c ℓ} {rawMonoid : RawMonoid c ℓ} {•} | ||
(isPointedMonoid : IsPointedMonoid rawMonoid •) | ||
where | ||
|
||
open import Agda.Builtin.FromNat | ||
open IsPointedMonoid isPointedMonoid | ||
|
||
number : Number Carrier | ||
number = record { Literals } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Defines `IsPointedMonoid` | ||
-- intermediate between `Monoid` and `SemiringWithoutAnnihilatingZero` | ||
-- | ||
-- By contrast with the rest of `Algebra.Structures`, this is modelled | ||
-- on an underlying `RawMonoid`, rather than a 'flattened' such signature | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Algebra.Bundles.Raw | ||
import Algebra.Structures as Structures | ||
open import Data.Nat.Base as ℕ using (ℕ) | ||
open import Data.Unit.Base | ||
open import Level using (Level; _⊔_; Lift) | ||
|
||
import Algebra.Definitions.RawMonoid as Definitions | ||
|
||
module Algebra.Structures.Pointed where | ||
|
||
private | ||
variable | ||
c ℓ : Level | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Structures with 1 binary operation & 2 elements | ||
------------------------------------------------------------------------ | ||
|
||
record IsPointedMonoid | ||
(rawMonoid : RawMonoid c ℓ) | ||
(• : RawMonoid.Carrier rawMonoid) : Set (c ⊔ ℓ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused. You don't have a not equal to assumption between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely! Degenerate instances are/should always be possible: we don't insist that |
||
where | ||
open RawMonoid rawMonoid public | ||
open Structures _≈_ | ||
|
||
field | ||
isMonoid : IsMonoid _∙_ ε | ||
|
||
_ו : ℕ → Carrier | ||
n ו = n × • where open Definitions rawMonoid | ||
|
||
module Literals where | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why define this as a named module, and not just a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Constraint : ℕ → Set c | ||
Constraint _ = Lift c ⊤ | ||
fromNat : ∀ n → {{Constraint n}} → Carrier | ||
fromNat n = n ו |
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.
There is no instance defined in
Algebra.Structures.Literals
....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.
No, but this seems to be the model in eg
Data.Nat.Literals
which I had been mindlessly following...