[ refactor ] Revise definitions, consequences, and use, of Algebra.Definitions.(Almost)*Cancellative#2573
[ refactor ] Revise definitions, consequences, and use, of Algebra.Definitions.(Almost)*Cancellative#2573jamesmckinna wants to merge 53 commits into
Algebra.Definitions.(Almost)*Cancellative#2573Conversation
|
Besides the still-outstanding merge conflict, some improvement (I hope!) in the |
|
Drawback 1. OK... I might need to go back to the drawing board, a bit, now that we have, for *-cancelʳ-≡ : ∀ m n o .{{_ : NonZero o}} → m * o ≡ n * o → m ≡ n
*-cancelʳ-≡ m n o = almost⇒exceptʳ _ *-almostCancelʳ-≡ o m n {{≢-nonZero⁻¹ _}}
*-cancelˡ-≡ : ∀ m n o .{{_ : NonZero o}} → o * m ≡ o * n → m ≡ n
*-cancelˡ-≡ m n o rewrite *-comm o m | *-comm o n = *-cancelʳ-≡ m n oas the status quo ante, and with the new definitions, instead we would have (NB: argument order!) *-cancelʳ-≡ : Provided NonZero RightCancellative _*_
*-cancelʳ-≡ m n o = almost⇒exceptʳ _ *-almostCancelʳ-≡ m n o {{≢-nonZero⁻¹ _}}
*-cancelˡ-≡ : Provided NonZero LeftCancellative _*_
*-cancelˡ-≡ m n o rewrite *-comm m o | *-comm m n = *-cancelʳ-≡ m n oSo...: what is/should be the correct argument order in all the new definitions, or do we simply carry on breaking the API? |
|
Drawback 2. Suppose we want to rewrite eg. *-cancelʳ-≤ : ∀ m n o .{{_ : NonZero o}} → m * o ≤ n * o → m ≤ n
*-cancelʳ-≤ zero _ _ _ = z≤n
*-cancelʳ-≤ (suc m) (suc n) o@(suc _) le =
s≤s (*-cancelʳ-≤ m n o (+-cancelˡ-≤ _ _ _ le))
*-cancelˡ-≤ : ∀ o .{{_ : NonZero o}} → o * m ≤ o * n → m ≤ n
*-cancelˡ-≤ {m} {n} o rewrite *-comm o m | *-comm o n = *-cancelʳ-≤ m n oto use the new definitions, then, modulo Drawback 1., we would (be able to) have: *-cancelʳ-≡ : Provided NonZero RightCancellative _*_
*-cancelˡ-≡ : Provided NonZero LeftCancellative _*_modulo fiddling the imports so that we replace BUT: for *-cancelʳ-≤-neg : ∀ r .{{_ : Negative r}} → p * r ≤ q * r → p ≥ qin terms of My brain hurts. Doable, but exhausting... :-( And see all the other drawbacks (unsolved metas) which arise in #2580 ... |
|
(Potential) Drawback 3. UPDATED: yes, sort of, but will require the generalisations to multiple relations considered under 2. above. |
|
From the code you show, the argument order seems fine? Is there something I'm missing? It also seems to me that it is |
|
Re: argument order Re: |
|
I'm still not quite getting it. Re: |
|
Merge conflict fixed (including fixing some typos in
If you think this is mergeable, I'll let go for the time being. |
|
I think this PR is a good unit of progress as-is. |
|
Not quite sure how to go back to this after more than a year... and all the merge conflicts are definitely a headache! |
|
Merge conflicts are one thing, but I think I'd (now!? v3.0 etc.) like to be more radical in making this |
|
Beyond considerations of what this PR might/should actually contain, I've brought it up to date, and with two approvals from @JacquesCarette and @MatthewDaggitt suggest merging now/soon and then seeing how the dust settles? |
|
I agree with my past self: this PR, as of today, is a worthwhile series of improvements. The more radical version might be good too, but feels like a new step, best performed on top of this one. |
Fixes #1436 , ...
... at least as far as 'AlmostCancellative' properties of operations wrt equality relation; the various order-theoretic generalisations are not covered
... so the issue probably ought to be kept open even if this gets merged? cf. #2580
NB.:
breaking?namingissues... etc.)Algebra.Consequences.Baserefactoring [ refactor ] Add equality as a parameter toAlgebra.Consequences.Base#2572 should probably be merged first; fold in theinstance-based analysis forDecidable(and henceRecomputable) predicates intoExcept_-*Cancellative_?Algebra.Definitionsonly imported at the equality relation, but might better be left parameterised, so that the variousCancellativeproperties can be made generic...IntegerandRational, theCancellativeproperties wrt multiplication don't easily cash out via the 'generic' design strategy of going viaAlmostCancellative, so I haven't (yet) include such statements, nor refactored to make these the primary notions.