Add negatives for commutative monoids and semirings (Abelian group and ring completions) - #3106
Add negatives for commutative monoids and semirings (Abelian group and ring completions)#3106LionOfJewdah wants to merge 2 commits into
Conversation
|
I didn't do it yet, but I could add if desired that if the monoid / semigroup is already a group / ring, its completion is isomorphic to itself with (a, b) -> a - b Edit: Now I did it |
6d0fabd to
21b1912
Compare
|
Notwithstanding existing mathematical terms-of-art, I'd probably reckon that |
|
How about |
|
(Also I just realized I can reuse more of the proofs from |
21b1912 to
9a9fd05
Compare
|
As to where things (should) live, I sort of agree with |
|
Re: equational reasoning proofs See also |
|
Re: force-pushing branches (Happy to be corrected on matters As I understand it, this makes it harder (if not impossible, without directly accessing individual commits?) to survey the history of an evolving PR, even at the barebones level of satisfying reviewers that requested/suggested changes have been taken into account ... ... but at a less adversarial level, my experience is that, absent more serious attempts to document our development process(es), PR history can still provide valuable insight into the evolution of ideas, esp. design ideas, as well as a(n admittedly highly diffuse) archive of 'learning resources' for the community, esp. future developers and maintainers. |
|
My apologies on the Regarding rearrangement lemmas and other monoid properties, on that now. Would you prefer this be one file or two? |
|
Regarding file-level organisation as modules, 2 seems easier to grasp right now, but I haven't had time to sit down and do a serious review (yet), so I can't really say definitively for the now... |
JacquesCarette
left a comment
There was a problem hiding this comment.
I wonder, how much of the CommutativeMonoid completion can re-use the Semiring completion? Or is it a sufficiently different construction that basically none can be?
|
|
||
| open M² public using (Carrier) renaming (_∙_ to _+_; ε to 0#) | ||
|
|
||
| pos : Carrier → Base |
There was a problem hiding this comment.
I don't think pos and neg should be exported from this construction.
|
|
||
| _≈_ : Rel Carrier (m ⊔ ℓ) | ||
| x ≈ y = ∃[ slack ] | ||
| (pos x +ₘ neg y) +ₘ slack ≈ₘ (pos y +ₘ neg x) +ₘ slack |
There was a problem hiding this comment.
perhaps slack should be on the left, so that when it is 0, cancellation is free?
I wonder if there should be a 'tight' equivalence also defined, i.e. without the slack.
| (inverseᵇ⇒bijective; strictlyInverseˡ⇒inverseˡ | ||
| ; strictlyInverseʳ⇒inverseʳ) | ||
|
|
||
| open G using () renaming |
There was a problem hiding this comment.
Have to wonder if using G. instead of all these renamings would be just as clear?
| a b c d : Base | ||
|
|
||
| infix 4 _≈[_]_ | ||
| _≈[_]_ : Carrier → Base → Carrier → Set ℓ |
There was a problem hiding this comment.
Maybe comment as to why the slack now has to be explicit? I think I can figure it out, but the next reader shouldn't have to!
|
As to where it should live: I find the current choice pretty good, actually! Yes, the nesting is deep, but this is a reflection that the library is getting larger. |
|
I'm working on the latest feedback. I also realized two things:
On semimodules:
On the universal property:
I forget the path in stdlib, but I know there's already an action module for the naturals on any monoid. I forget if there is for the integers and groups. |
Reuse algebra properties and remove single-use proof scaffolding. Address review feedback by hiding projections, exposing zero-slack balance, qualifying bundle operations, and aligning absorption with left slack.
Summary
Algebra.Construct.Add.Negatives.CommutativeMonoid, constructing formal differences of a commutative monoid with a slack-balance setoid relationAlgebra.Construct.Add.Negatives.Semiring, extending the additive completion with the semiring multiplication1# ≈ 0#in the ring completionMotivation
These modules provide reusable group and ring completions without relying on the algebra solver. The carrier reuses
Algebra.Construct.DirectProduct; the proofs use setoid equational reasoning, product combinators, and existing algebra-property lemmas.Validation
fix-whitespace --check CHANGELOG.md src/Algebra/Construct/Add/Negatives/CommutativeMonoid.agda src/Algebra/Construct/Add/Negatives/Semiring.agdaagda --safe --ignore-interfaces -Werror +RTS -M6G -A128M -RTS -i src src/Algebra/Construct/Add/Negatives/CommutativeMonoid.agdaagda --safe --ignore-interfaces -Werror +RTS -M6G -A128M -RTS -i src src/Algebra/Construct/Add/Negatives/Semiring.agdaEverythingSafewith the same safety, warning, and RTS flags