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(data/polynomial/trinomial): Bundled trinomials #6428
Conversation
I wonder if we should have |
I suppose so (although binomials aren't nearly as bad as trinomials, when working with them as polynomials). |
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 almost all the lemmas in trinomial.lean
should be simp-lemmas.
structure trinomial (R : Type*) [semiring R] := | ||
(a b c : R) (ha : a ≠ 0) (hb : b ≠ 0) (hc : c ≠ 0) (i j k : ℕ) (hij : i < j) (hjk : j < k) |
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.
Playing devil's advocate - would this definition be as easy to work with?
structure n_omial (R : Type*) (n : ℕ) [semiring R] :=
(coeffs : fin n → R)
(powers : fin n → ℕ)
(h_coeffs : ∀ i, coeffs i ≠ 0)
(h_powers : monotone powers) -- or `(list.of_fn powers).sorted (<))`, but that's likely harder to work with
abbreviation trinomial := n_omial 3
because it scales much better to working with "quadnomials" etc
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.
It would certainly be better than working with polynomials. I'll have to play around with this definition a bit to see whether it is nice to work with.
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've defined to_polynomial
and of_polynomial
for n_omial
, and proved that they are inverses. So far, things are working ok (and the amount of code is about the same). I'll continue to see how my proof ports over.
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.
@eric-wieser Here are my thoughts so far:
- It seems possible to develop an API for
n_omial
, although some parts liken_omial.reverse'
would be rather painful. - For the purposes of proving irreducibility of
X^n - X -1
,trinomial
is much better thann_omial
. The point oftrinomial
is that you can quickly figure what thenat_degree
is or what thereverse'
is (or other similar things). Forn_omial
, this is not the case. For example, thenat_degree
of ann_omial
iscoeff (fin.mk n.pred (nat.pred_lt n_ne_zero)
, and thereverse'
of ann_omial
is also messy (the cleanest definition that I can think of involves passing to a list and invoking list.reverse).
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.
n_omial
s are sometimes called "fewnomials"; see also the chapter on "Bernstein's theorem and Fewnomials" in Sturmfels's book Solving systems of polynomial equations (though he never defines "fewnomial" formally, he just talks about polynomials with at most m
distinct monomials).
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.
Ah, I see that it's not. Could you push the progress you made on that definition to a branch?
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's a bunch of errors at the end, but here's what I have so far: https://github.com/leanprover-community/mathlib/compare/nomial
Feel free to play around with 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.
p.support.order_emb_of_fin
can replace your definition of kth_power
, and produces an order_embedding
which already has lots of API.
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've pushed to your branch with that change.
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.
It seems that this lemma is missing:
f : fin n ↪o ℕ
⊢ (finset.image ⇑f finset.univ).order_emb_of_fin _ = f
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
…hlib into selmer8 merge
This PR defines bundled trinomials. Working directly with specific polynomials (like X^n - X - 1) is really painful, since whenever you try to do something simple like checking that the polynomial is monic or computing its degree, you have to prove a bunch of trivial inequalities. Bundling solves this problem.
(this PR is part of the irreducibility saga)