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

[Merged by Bors] - feat(data/polynomial/degree): lemmas on nat_degree and behaviour under multiplication by constants #6224

Closed
wants to merge 10 commits into from

Conversation

adomani
Copy link
Collaborator

@adomani adomani commented Feb 13, 2021

These lemmas extend the API for nat_degree

I intend to use them to work with integrality statements


... = f.nat_degree + 0 : by rw nat_degree_C a
... = f.nat_degree : add_zero _

lemma nat_degree_mul_C_eq_of_mul_eq_one {ai : R} (au : a * ai = 1) {f : polynomial R} :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lemmas hold more generally for \forall ai, ai * a \ne 0 right? In particular, that hypothesis means you can create a simpler lemma for no_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.

I am on my phone, so I may be misunderstanding. I agree that it suffices to assume that a is a non-zero divisor and I could prove it in this case, adding then a lemma saying that having an inverse implies being a non-zero divisor. However, assuming every non-zero element of R is a non-zero divisor is more than I want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting both - show that it suffices for a to be a nonzero divisor, but for convenience, also provide the lemma that provides that hypothesis automatically from the fact that it is true for all a using typeclass search when working in the reals, rationals, etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eric, I decided to add a more direct lemma, assuming that the product a * f.leading_coeff does not vanish. This implies quickly the result that you want about non-zero divisors. The proofs of the results that I needed, though, have not been affected.

I also found out that the final section on no_zero_divisors assumed comm_semiring and I removed the comm assumption: let's see if mathlib likes this! If it does not, I will add the hypothesis back and that refactor will wait a separate PR.

Comment on lines 786 to 802
/-- Although not explicitly stated, the assumptions of this lemma force the polynomial `p` to be
non-zero, via `p.leading_coeff ≠ 0`. The lemmas below split cases, effectively removing this
assumption in some cases.
-/
lemma nat_degree_mul_C_eq_of_mul_ne_zero (h : p.leading_coeff * a ≠ 0) :
(p * C a).nat_degree = p.nat_degree :=
begin
refine eq_nat_degree_of_le_mem_support (nat_degree_mul_C_le p a) _,
refine mem_support_iff_coeff_ne_zero.mpr _,
rwa coeff_mul_C,
end

/-- Although not explicitly stated, the assumptions of this lemma force the polynomial `p` to be
non-zero, via `p.leading_coeff ≠ 0`. The lemmas below split cases, effectively removing this
assumption in some cases.
-/
lemma nat_degree_C_mul_eq_of_mul_ne_zero (h : a * p.leading_coeff ≠ 0) :
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 explicitly name the lemmas you're referring to here, so that they link in doc-gen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks for the suggestion!

@adomani adomani added the awaiting-review The author would like community review of the PR label Feb 15, 2021
@jcommelin
Copy link
Member

I question about the more general structure... the file is definitions.lean and there is also lemmas.lean. There are already many results in this file, but I'm guessing that's contra the original file layout. So maybe we should move all those lemmas to lemmas.lean?

@adomani
Copy link
Collaborator Author

adomani commented Feb 16, 2021

Johan,

I like your suggestion and I agree that this file is getting long. I am happy to simply move these lemmas somewhere else, but your suggestion seems to imply a larger migration. I do not have a criterion, though, for which lemmas belong to "definitions" and which to "lemmas". If you have some guidance, I can move the lemmas of this PR, along with some of the ones that are already misplaced, in their correct home.

@adomani
Copy link
Collaborator Author

adomani commented Feb 16, 2021

I moved the new lemmas from definitions to lemmas, since I imagine that moving more stuff could be tricky, due to older imports.

I still agree that having shorter files is desirable. In more geometric/topological arguments, the theory is often split into "properties about a single point" and "properties about more than one point". The first class contains all the local stuff (e.g. filters, neighbourhoods); the second class contains "relative" properties (e.g. separation axioms).

We could try a similar split, with lemmas whose statement is about a single polynomial on one side and lemmas with more than one polynomial in their statement. I imagine that such a clean cut will not be possible, but it may inform a strategy. What do you think?

@robertylewis
Copy link
Member

I think this looks great for now, thanks @adomani ! If there's more refactoring to be done, maybe another PR is welcome. I don't know the ideal way to split this stuff up. Maybe worth a Zulip thread.

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Feb 22, 2021
bors bot pushed a commit that referenced this pull request Feb 22, 2021
…r multiplication by constants (#6224)

These lemmas extend the API for nat_degree

I intend to use them to work with integrality statements
@adomani
Copy link
Collaborator Author

adomani commented Feb 22, 2021

Rob, thanks! I have not given the splitting more thought, so for the moment, I am happy like this!

@bors
Copy link

bors bot commented Feb 22, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/polynomial/degree): lemmas on nat_degree and behaviour under multiplication by constants [Merged by Bors] - feat(data/polynomial/degree): lemmas on nat_degree and behaviour under multiplication by constants Feb 22, 2021
@bors bors bot closed this Feb 22, 2021
@bors bors bot deleted the adomani_nat_degree_inequalities branch February 22, 2021 17:13
b-mehta pushed a commit that referenced this pull request Apr 2, 2021
…r multiplication by constants (#6224)

These lemmas extend the API for nat_degree

I intend to use them to work with integrality statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants