-
Notifications
You must be signed in to change notification settings - Fork 247
[ re #1752 ] add properties of ordered structures for Nat. #1759
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
Conversation
Shout-out to @Taneb who originally suggested implementing this PR. |
That's okay, no worries, I can do the refactoring myself at AIM tomorrow. |
@sstucki just doing this now. The first thing I notice is that the fields of |
Sorry @MatthewDaggitt, I don't understand what you mean by "symmetric". Can you give an example? |
Definition of record IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
field
isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero + * 0# 1#
zero : Zero 0# * Definition of record IsPosemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
+-isCommutativePomonoid : IsCommutativePomonoid + 0#
*-mono : Monotonic₂ _≤_ _≤_ _≤_ *
*-assoc : Associative *
*-identity : Identity 1# *
distrib : * DistributesOver +
zero : Zero 0# * I'd expect it to be: record IsPosemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isPosemiringWithoutAnnihilatingZero : IsPosemiringWithoutAnnihilatingZero _≤_ + * 0# 1#
zero : Zero 0# * |
Oh, I see. Indeed, I skipped a few intermediate structures. There's no good reason for that other than, when I first mechanized the ordered structures, the algebraic hierarchy was a lot simpler. Also, to be honest, I have no idea where you'd ever use a |
So if it's been added, it's been used. The problem is that if it was added then the record definition of |
I don't understand what you mean by that.
But that would still be the case if the algebraic structures would be at the base, no? You'd still need two new definition for each of the definitions in the hierarchy. Even if those new definitions would just be adding the pre/partial order components. Or am I missing something? |
BTW, if you want me to "fill in" the missing structures in the |
Thanks for the nice diagrams @MatthewDaggitt, they are very helpful. But I don't entirely buy it. You say
That can't be right. First, the vertical branches in your second picture don't magically appear, someone still has to add them. Also, code that depends on the base hierarchy still breaks if that changes. And finally, the records wouldn't just contain the extra fields representanted by the vertical branches, they would also contain convenience definitions and re-exports of the related (ordered) algebraic structures. E.g. a promonoid would contain a field But I get your point, fewer things would break if one decided to establish the "symmetry" between the different "levels" of the pictures in a lazy fashion. I guess. Then again, you just argued against having an asymmetric set of hierarchies:
So then I guess one would really have just as much breaking code and maintenance anyway? |
Sorry, yes you're right that was imprecise phrasing on my behalf. The point is that missing vertical branches can be added in a backwards compatible manner, and therefore don't need to be all added at the same time. In contrast, if you miss out one of the nodes in the second diagram then it's impossible to add it in in a backwards compatible manner.
That's the thing though, yes the code in the library breaks and yes the user's original algebra code breaks, but their code building the ordered structures doesn't right?
Again I agree with what you've said, but the crucial thing is that if we get that overlay wrong then to fix it we don't have to break backwards compatibility in the same way that we would if we adopt the current approach.
No you wouldn't. The amount of breaking code would be much less. The maintenance might be the same. How about this as a final reason? I admit is either a weak one or a strong one depending on your perspective, but there's a reason these structures are called |
I think it does though. Because in order to show something is a preordered-X, you now need to show that it is an X first, then that it is preordered. The second half won't break, the first half will. So, unless they decide to implement everything twice (and not use the derived definitions/modules/proofs provided in the ordered structures), the same amount of code will break. No?
Hehe, I'm not sure about that one. Some authors refer to a preordered (commutative) monoid as a (symmetric) monoidal preorder (e.g. Fong and Spivak in their Seven Sketches in Compositionality). Look @MatthewDaggitt, I don't think there's a clear winner here, but you're the boss. You have put way more time into this library and I defer to your judgment. If you prefer the hierarchy to be layered the other way, let's fix it! |
Thank you, apologies always difficult to judge when to put your foot down and I don't mean to overrule your concerns. You've definitely convinced me the decision is more nuanced than I'd thought, but I still think swapping the layout is preferable. Would you be willing to change it? If not then I'm happy to put my money where my mouth is and do it myself 👍 |
Yes. But it may take a while (I have some other obligations this week), sorry. If it's urgent, please go ahead and make the changes. |
Any likelihood of solving this design problem (in time) for v2.0? |
Sorry for the inactivity on this one. I should have accepted @MatthewDaggitt offer to do the refactor. Unfortunately, I've since changed jobs, so I have even less time to work on Agda-related things. @jamesmckinna and @MatthewDaggitt: I haven't been paying attention to recent developments of this library. Is the new design proposed by @MatthewDaggitt still relevant? |
Yes unfortunately I'm still convinced the current design is the wrong one. Unfortunately I don't think I have the time to push through a better design before the release of v2.0... As, from a backwards compatability view, a design that needs to be changed is actually worse than no design, I'm going to very reluctantly open a PR removing the I'm really really sorry. I know it's super annoying to have one's work undone and I really didn't want to have to do this. However, I think it is important to get the right design in. Of course, we're still very open to subsequent PRs after v2.0 that re-add it with the new design 👍 |
Follow-up to #1752, implementing the new ordered structures for
Data.Nat
. The PR currently replaces the old (unordered) proofs by ordered ones and then re-exports derived versions of the old ones. The re-exports are named so as to retain backwards compatibility. If desired, I can refactor the PR to keep the old proofs.