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(data/polynomial/trinomial): Bundled trinomials #6428

Closed
wants to merge 23 commits into from
Closed

Conversation

tb65536
Copy link
Collaborator

@tb65536 tb65536 commented Feb 25, 2021

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)


@github-actions github-actions bot added the blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. label Feb 25, 2021
@semorrison
Copy link
Collaborator

I wonder if we should have binomial as well?

@tb65536
Copy link
Collaborator Author

tb65536 commented Feb 25, 2021

I suppose so (although binomials aren't nearly as bad as trinomials, when working with them as polynomials).

@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Feb 26, 2021
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Feb 26, 2021
Copy link
Member

@jcommelin jcommelin 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 almost all the lemmas in trinomial.lean should be simp-lemmas.

src/data/polynomial/trinomial.lean Outdated Show resolved Hide resolved
src/data/polynomial/trinomial.lean Show resolved Hide resolved
Comment on lines +33 to +34
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)
Copy link
Member

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

Copy link
Collaborator Author

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.

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

Copy link
Collaborator Author

@tb65536 tb65536 Feb 27, 2021

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:

  1. It seems possible to develop an API for n_omial, although some parts like n_omial.reverse' would be rather painful.
  2. For the purposes of proving irreducibility of X^n - X -1, trinomial is much better than n_omial. The point of trinomial is that you can quickly figure what the nat_degree is or what the reverse' is (or other similar things). For n_omial, this is not the case. For example, the nat_degree of an n_omial is coeff (fin.mk n.pred (nat.pred_lt n_ne_zero), and the reverse' of an n_omial is also messy (the cleanest definition that I can think of involves passing to a list and invoking list.reverse).

Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Member

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?

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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

@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Aug 8, 2021
@tb65536 tb65536 closed this Jul 16, 2022
@tb65536 tb65536 deleted the selmer8 branch September 29, 2022 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. merge-conflict Please `git merge origin/master` then a bot will remove this label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants