Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

Multramate
Copy link
Collaborator


Open in Gitpod

@Multramate Multramate changed the title feat(Algebra/GroupWithZero/Divisibility): add Ring.divide feat(Algebra/GroupWithZero/Divisibility): add ad-hoc ring division Jul 15, 2023
@Multramate Multramate added the t-algebra Algebra (groups, rings, fields, etc) label Jul 17, 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
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

@Multramate Multramate Jul 18, 2023

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 Ring.divide as I have and then add notation? I figured it out!

Copy link
Member

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...

Copy link
Collaborator Author

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.

@jcommelin jcommelin added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Jul 18, 2023
@Multramate Multramate added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 18, 2023
@Multramate
Copy link
Collaborator Author

This seems to cause a whole lot of other overloading (?) issues - any ideas?

@eric-wieser
Copy link
Member

Making this a div instance is a very bad idea IMO

@Multramate
Copy link
Collaborator Author

Yeah, I reverted it.

Copy link
Collaborator

@ericrbg ericrbg left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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

@ericrbg
Copy link
Collaborator

ericrbg commented Aug 8, 2023

Like epsilon in some ring where epsilon^2 = 0. I meant to reply to Johan's comments so maybe that's where the reply option is.

And I get that with this definition, zero_divide needs a domain - I wonder if we could tweak it so that it works everywhere

@ocfnash
Copy link
Contributor

ocfnash commented Aug 20, 2023

I'm not convinced that we should introduce such an arbitrary function for all MonoidWithZero. To be convinced I think I'd need to see:

  • evidence of significant benefit that this provides in some setting (e.g., your polynomial rings), and
  • evidence that no other solutions exist,

(and even then I might still be dubious).

I'm going to relabel this "awaiting-author" pending such evidence.

@ocfnash ocfnash added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Aug 20, 2023
@Multramate
Copy link
Collaborator Author

Multramate commented Aug 20, 2023

I'm not convinced that we should introduce such an arbitrary function for all MonoidWithZero.

The only reason I'm defining it for a MonoidWithZero is to match Ring.inverse, which shares a similar name, but I really only need it for an integral domain as I mentioned above. I'm definitely open to restricting this.

  • evidence of significant benefit that this provides in some setting (e.g., your polynomial rings), and

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 f : \N -> R[X] for a commutative ring R, such that when n is even, f n is defined to be some polynomial g (in terms of f (n / 2 - 1), etc) divided by f 2. It's impossible to extract out a factor of f 2 from g formally, and the only way I can think of is to use my current Ring.divide, and prove later that g is divisible by f 2.

  • evidence that no other solutions exist,

I don't know how to show this other than providing the example.

@Multramate Multramate added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels Aug 20, 2023
@ocfnash
Copy link
Contributor

ocfnash commented Aug 21, 2023

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?

@ocfnash ocfnash added the awaiting-author A reviewer has asked the author a question or requested changes label Aug 21, 2023
@Multramate
Copy link
Collaborator Author

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

@Multramate Multramate added awaiting-review and removed awaiting-author A reviewer has asked the author a question or requested changes labels Aug 21, 2023
@ericrbg
Copy link
Collaborator

ericrbg commented Aug 21, 2023

Ring.divide...chooseP

Here's an idea I had to use a choose Preferring (hence the name). All the theorems you proved are true (if not in more generality) and I didn't take much care to make the API nice yet, as it's just an idea. What do you think, David?

@Multramate
Copy link
Collaborator Author

Multramate commented Aug 21, 2023

Ring.divide...chooseP

Here's an idea I had to use a choose Preferring (hence the name). All the theorems you proved are true (if not in more generality) and I didn't take much care to make the API nice yet, as it's just an idea. What do you think, David?

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 Ring was again just arbitrary.

@bors bors bot changed the base branch from master to ScottCarnahan/BinomialRing2 September 17, 2023 03:24
@kim-em kim-em changed the base branch from ScottCarnahan/BinomialRing2 to master September 17, 2023 12:16
@kbuzzard
Copy link
Member

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).

@Multramate
Copy link
Collaborator Author

I am closing this after discussions with Kevin (Thanks!) :)

@Multramate Multramate closed this Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-algebra Algebra (groups, rings, fields, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants