-
Notifications
You must be signed in to change notification settings - Fork 245
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
Conversation
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 only understood the point of this once I read through all the backlog, including #1363.
So I think the smallest algebra that has Number
in it is "pointed unar" (single point, single unary operation). BiPointedMonoid is a really weird thing! (I know it is called PointedMonoid, but to me, Pointed means 1 point, not 2).
rawMonoid : RawMonoid c ℓ | ||
open RawMonoid rawMonoid using (Carrier) | ||
field | ||
• : Carrier |
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.
The comment "1 binary operation & 2 elements" is correct, but the rest of the names (Pointed
, etc) give the wrong impression of having a single distinguished element. BiPointed
?
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.
Much to think about here. Ever since my abortive Pointed
draft PRs #1958 #1963 , I've been thinking about PointedX
(and how to formalise the lift map/pointed extension operation from X
in a 'signature polymorphic' way) in general...
The two points in PointedMonoid
play distinct roles, so I'm unhappy to identify them as '2 points', because one is distinguished as an identity, while the other is an unconstrained extension of the signature...
... that said, BiPointedSet
/BiPointedMagma
do make sense, especially as Raw
bundles, but I've always been resistant to universal algebra ideas in this regard precisely because not all 'freely constructed' such signatures make sense in the absence of additional structure...?
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 comment
The 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 comment
The 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 Pointed
what you're describing is Inhabited
(I'm writing that up separately, i.e. the observation that the category whose objects are pairs of a type and a point of that type, but whose homomorphisms don't preserve that point, are exactly the inhabited types, without needing to have a notion of truncation).
Of course, a Monoid
is always inhabited -- the right name here would be NonTrivialMonoid
although that's tricky as the one-point monoid is a model as you don't actually want to assert that the extra point is not unit! Best you might be able to do is to ask that the obvious homomorphism induced by 'swap' not be homotopic to the identity.
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.
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 _+ pt
is the unary operation at hand, and we want it as (part of) an NNO-instance a SuccessorSet
instance to be preserved?
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.
And NonTrivialMonoid
...: does that exclude the case 0# = 1#
? I wouldn't want to insist on that...?
@JacquesCarette you wrote
Apologies for not providing enough context! As one of the commenters in the original issue, I'd imagined (magical thinking) that you'd still be across the issue (plus: never being entirely clear where 'detailed design discussion' belongs... on the issue, or on the pR?) It might have been easier to follow the original suggestion and simply use I'd reached the present PR in that spirit: Identifying Your comments are very helpful... and |
Facing the fact that there's only so much that I can keep in active memory all the time... My current feeling is indeed that |
|
Is it actually an So it's |
Good point. But I think I'd be happier (given the intended mode-of-use of this PR) to call it UPDATED:
yes! yes! yes! I've been a total idiot ignoring initiality... apologies to all, especially @JacquesCarette , for my idiocy on this point. |
I fully agree that if it is defined locally in this file, then |
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.
The design, at present, is pretty convoluted
Agreed. This PR needs some serious thinking about the design.
- it needs a
README
file to show it actually works... - Is
Pointed
supposed to be whole new subhierarchy? If so it should go underAlgebra.Pointed.(Structures/Bundles)
rather thanAlgebra.(Structures/Bundles).Pointed
- Having said that why do we need such generality? I feel we could get this working in about 5 lines of code in
Algebra.Properties.SemiringWithoutAnnihilatingZero
without needing to go through add 5 new modules, an entire new algebraic subhierarchy, and an entire new way of indexing algebraic structures. I think we need a pretty convincing argument for the need for the extra generality to justify all of this.
|
||
open PointedMonoid pointedMonoid | ||
|
||
-- Re-export `Number` 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.
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...
|
||
record IsPointedMonoid | ||
(rawMonoid : RawMonoid c ℓ) | ||
(• : RawMonoid.Carrier rawMonoid) : Set (c ⊔ ℓ) |
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'm confused. You don't have a not equal to assumption between •
and ε
so there's not necessarily two elements...
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.
Absolutely! Degenerate instances are/should always be possible: we don't insist that 0#
not be equal to 1#
in (Semi)ring*
, for example.
So perhaps the comment is bad, but this was mindless/lazy cut-and-paste from Algebra.*
...
_ו : ℕ → Carrier | ||
n ו = n × • where open Definitions rawMonoid | ||
|
||
module Literals where |
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.
Why define this as a named module, and not just a Number
record directly?
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 had stymied myself with imports from
Agda.Builtin.FromNat
, perhaps in the mistaken belief that that was howNumber
instances get introduced... - I had (for some reason) wanted to distinguish between the declaration of a module defining the implementation, from its export via a
number : Number ...
definition elsewhere...
So, thanks to each of you for the feedback on what was an 'essay'/attempt to attack the problem, while balancing a lot of ... competing tensions in how/where the library might be extended, esp. in respect of I'd be very happy to retire this one (or move it to (Meta: I maintain a tab of the list of |
@MatthewDaggitt wrote:
Agreed! My approach may be flawed, but it seems as though this hasn't been picked up since late 2020 when it was first proposed. I'd been picking at it on and off since 2021, but this was my first 'concentrated' effort since then.
OK.
That's a very good question! I had been following my nose a bit, given earlier attempts with the simplest cases of such a hierarchy, and wondering, but not (oops! this got left out earlier) committing to, the thought that perhaps, indeed, we did?
All fair points. And on that basis, I'd be happy to withdraw this, in favour of someone coming up with just such a simpler solution, save for the following:
These points might be moot for the time being, but I can't help thinking they will return as issues... eventually. So I had started to explore the consequences of thinking about how they might affect this specific PR... hope that goes some way to explaining, if not justifying, the avenues I'd taken here. |
On naming:
Can we agree on 'sensible' choices from this palette? |
I am happy to entertain any of |
Will revisit as and when #2277 gets merged... |
Possible fix for #1363 .
The design, at present, is pretty convoluted (I felt as though I were writing SML
functor
s again!):IsX
with those of the correspondingRawX
#2252 , definesIsPointedMonoid
as an extension ofRawMonoid
by an abstract point, inAlgebra.Structures.Pointed
;Literals
for such structures in-place, usingAlgebra.Definitions.RawMonoid._×_
;Number
instance inAlgebra.Structures.Literals
;PointedMonoid
bundles, inAlgebra.Bundles.Pointed
, and their associatedNumber
instance inAlgebra.Bundles.Literals
;SemiringWithoutAnnihilatingZero
using1#
as the point;Number
instance for such fromAlgebra.Literals
.I would really welcome a review, with hints as to 'sensible' refactoring, if any.