-
Notifications
You must be signed in to change notification settings - Fork 247
In CommutativeRing, Ring.semiring ≠ CommutativeSemiring.semiring #898
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
Comments
Hmm I really like this proposal. It's always bugged me (#239) that sometimes the records don't inherit the way you think they should. This seems like a really neat way of side-stepping the problem and although not backwards compatible requires only a very minimal change to existing code (i.e. prepend the smart constructor in front of the record construction).
So I think the reason that you're running into this problem for modules is that for the first time you're breaking the pattern by parameterising "structures" with "packages" which isn't done anywhere else in the library. The "packages" don't compose in the same way that you're trying to make your "structures" compose and hence you run into the sort of conflicts above. I might add a comment on the PR discussing this. |
This is nice - but I wouldn't spend too much effort on it. When you have ~30 structures in your Algebra library, there's a limited number of natural diamonds that occur. When you get to ~300, there are way, way more of them, and this kind of patch is not sufficient anymore. I'm not quite ready to make a concrete proposal about an alternate way to handle things; in the meantime, what is proposed here is definitely better than the status quo. |
I thought it'd be worth summarising this comment here. Definitely things to do
|
For once, happy to find a long-standing issue is still open. But the discussion here, along perhaps with that on #1617 , might get lost in the wash... is there a better way for us to archive these long-standing |
In my own projects (here on github), I've been using the wiki feature to make sure such discussion gets a more archival home. Another possibility is markdown files in the repo itself. We are slowly collecting design information in the documentation itself. There might be other options as well. I don't really care which option is picked - but I'm with @jamesmckinna that this ought to be preserved in a more durable fashion that via issues. |
In the algebra hierarchy, we naturally have this diamond.
I shall abbreviate these CR, R, CSR, and SR.
In the standard library, the SR instance for CR comes from the CSR instance. CSR uses the commutativity property to cut down the number of fields of CSR, so we only have fields
distribʳ
andzeroˡ
, and the versions on the opposite side follow by commutativity. Via R, this is not a possibility because of the lack of commutativity, so there are fulldistrib
andzero
fields.This is causing trouble here. The required
isRightSemimodule
field is of typeIsRightSemimodule (Ring.semiring ring) m ℓm
, but the naturalisRightSemimodule
definition to export is of typeIsRightSemimodule (CommutativeSemiring.semiring commutativeSemiring) m ℓm
, becauseCommutativeRing.semiring = CommutativeSemiring.semiring ∘ CommutativeRing.commutativeSemiring
. These types are not definitionally equal.I don't understand how conflicts like this are handled further down in the hierarchy (like at
AbelianGroup
), but maybe that approach could be replicated successfully. My personal preference would be that the main structures in the hierarchy are unabbreviated, containing redundant lemmas, and we then have smart constructors to avoid explicit redundant proofs. Then, we would get hierarchies like this:The
===
are where smart constructors go from the abbreviated structure (likeCommutativeMonoidˡ
) to the canonical structure in the hierarchy. Abbreviated structures play no part in the hierarchy, and should not be used except from in the smart constructor.The text was updated successfully, but these errors were encountered: