-
Notifications
You must be signed in to change notification settings - Fork 384
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
feat(Algebra/GroupWithZero/Divisibility): add ad-hoc ring division #5930
Conversation
Multramate
commented
Jul 15, 2023
Note that while this is in the `Ring` namespace for brevity, it requires the weaker assumption | ||
`MonoidWithZero M₀` instead of `Ring M₀`. -/ | ||
noncomputable def divide (x y : M₀) : M₀ := | ||
if h : y ≠ 0 ∧ y ∣ x then h.right.choose else 0 |
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 do you require y
to be non-zero? In a general ring, being non-zero isn't a very natural condition. You can still have plenty of nilpotents and/or zero-divisors.
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.
Fair enough. In my head I'm working with only integral domains, but I just didn't want to impose this on the definition. Without this condition I wouldn't be able to prove divide_zero
, which I think is something nice to have.
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 mean somthing like epsX / epsX should still be well-defined, I guess?
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.
but it'd also be nice to have zero_divide
in general. I wonder if there's another design that allows this, maybe prioritising zero if it's possible
import Mathlib.Algebra.Divisibility.Units | ||
|
||
/-! | ||
# Divisibility in groups with zero. | ||
|
||
Lemmas about divisibility in groups and monoids with zero. | ||
|
||
We also define `Ring.divide`, a globally defined function on any ring |
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.
Can you please elaborate on how/where you want to use this function? Would a DivInvMonoid
work in your setting?
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 looking at polynomial rings over (say) a commutative ring, which a priori don't have division/inversion but the notion of "cancelling out factors formally" still makes sense.
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.
Shouldn't we treat division in polynomial rings the same way we treat it in Nat
and Int
? So we can just use the ordinary division symbol for some "truncated division" operation.
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.
Yes I think we should, but I don't know how to best introduce this. Define I figured it out!Ring.divide
as I have and then add notation?
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.
Isn't this what rem
and quot
are for? I don't remember what typeclass they are from...
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 are EuclideanDomain.quotient
and EuclideanDomain.remainder
but my polynomial rings are not Euclidean.
This seems to cause a whole lot of other overloading (?) issues - any ideas? |
Making this a div instance is a very bad idea IMO |
Yeah, I reverted it. |
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 think it's probably fine to leave more API building to when it's needed, Ring.divide (a + b) x
is probably one of the obvious things but I have a feeling that's actually got stronger requirements than you'd hope.
Note that while this is in the `Ring` namespace for brevity, it requires the weaker assumption | ||
`MonoidWithZero M₀` instead of `Ring M₀`. -/ | ||
noncomputable def divide (x y : M₀) : M₀ := | ||
if h : y ≠ 0 ∧ y ∣ x then h.right.choose else 0 |
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 mean somthing like epsX / epsX should still be well-defined, I guess?
Note that while this is in the `Ring` namespace for brevity, it requires the weaker assumption | ||
`MonoidWithZero M₀` instead of `Ring M₀`. -/ | ||
noncomputable def divide (x y : M₀) : M₀ := | ||
if h : y ≠ 0 ∧ y ∣ x then h.right.choose else 0 |
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.
but it'd also be nice to have zero_divide
in general. I wonder if there's another design that allows this, maybe prioritising zero if it's possible
Like And I get that with this definition, |
I'm not convinced that we should introduce such an arbitrary function for all
(and even then I might still be dubious). I'm going to relabel this "awaiting-author" pending such evidence. |
The only reason I'm defining it for a
I don't have my environment set up currently, but the gist of what I'm trying to do is as follows. I have a (strong odd/even) recursive function
I don't know how to show this other than providing the example. |
Your example sounds interesting but I would like to see a precise statement before it is admitted as evidence for a decision on this PR. Can you provide such a statement (informally) or a reference with the precise details? |
I'm trying to define a characteristic two version of division polynomials, a slightly incorrect version of which can be found in Silverman's The Arithmetic of Elliptic Curves Exercise 3.7. The code would look something like: #6703 |
Here's an idea I had to use a |
I don't know enough of the design principle behind classical choice, so I can't say for sure this is a good idea, but I do not mind. I would think there's a lot of API to be developed though. It might also just be overkill, since my choice of having |
What the application David has in mind boils down to, is the theory of elliptic divisibility sequences https://en.wikipedia.org/wiki/Elliptic_divisibility_sequence . So the question really is whether one can formalise these without having to introduce some ad hoc ring division (and I suspect we can). |
I am closing this after discussions with Kevin (Thanks!) :) |