-
Notifications
You must be signed in to change notification settings - Fork 297
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/cubic_discriminant): remove custom cubic
structure and replace by API about new to_poly
#15088
base: master
Are you sure you want to change the base?
Conversation
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 like the idea, though I'm not very familiar with this API so someone else should give their opinion too.
|
||
lemma ne_zero_of_c_ne_zero (hc : P.c ≠ 0) : P.to_poly ≠ 0 := | ||
(or_imp_distrib.mp (or_imp_distrib.mp (or_imp_distrib.mp ne_zero).2).2).1 hc | ||
lemma coeff_to_poly_ge_four (P : fin N → R) (n : ℕ) (hn : N ≤ n) : (to_poly P).coeff n = 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.
These new names are nonsense for anything other than a cubic polynomial.
|
||
lemma degree_of_a_eq_zero (ha : P.a = 0) (hb : P.b ≠ 0) : P.to_poly.degree = 2 := | ||
by rw [of_a_eq_zero ha, degree_quadratic hb] | ||
lemma degree_to_poly_le : (to_poly P).degree ≤ N := |
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't you prove this with degree_to_poly_lt
and nat.lt_succ_iff
?
Currently, the leaf file
algebra/cubic_discriminant
by @Multramate introduces a customcubic
structure for polynomials of degree at most 3, which consists of a 4-tuple representing the coefficients plus some API.As far as I can tell, this structure would be just as useful if it worked for
N
-tuples rather than just 4-tuples. So in this PR I introduce a constructor (temporarily namedto_poly
, following the existing name for cubics) for a polynomial overR
given a vectorfin N → R
of the coefficients, and switch thecubic_discriminant
file over to this, deleting thecubic
structure.If the idea is accepted as a good one, I will move the material about
to_poly
out of thecubic_discriminant
file intodata/polynomial
somewhere. But for now, I am keeping everything inalgebra/cubic_discriminant
to demonstrate that it at least has the merit of decreasing the length of that file by 40 lines.Zulip
polynomial.roots
#14908The PR generalizes some of the existing results from cubics to arbitrary-length polynomials, which depends on a variant of Vieta's formulas, coincidentally recently PR'd. The diff of this PR is therefore large, but all the changes I propose are (temporarily) in the
cubic_discriminant
file.