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

Complete Algebra.exists_dvd_nonzero_if_isIntegral #157

Merged
merged 11 commits into from
Oct 11, 2024

Conversation

morrison-daniel
Copy link
Contributor

No description provided.

Copy link
Collaborator

@kbuzzard kbuzzard left a comment

Choose a reason for hiding this comment

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

Sorry it's taken me a while to get to this. FLT is supposed to be my full-time job right now but in practice there are some teething troubles whilst I get other aspects of my life under control (e.g. getting to inbox 0, which I've not had now for several months but am nearly achieving). My instinct is that this proof is too long. I think your idea of breaking it into two pieces is great. My instinct is that both pieces are too long right now but I'm happy to work with you to make it shorter.

obtain ⟨p, p_monic, p_eval⟩ := (@Algebra.isIntegral_def R S).mp inferInstance s
have p_neq_zero := ne_zero_of_ne_zero_of_monic X_ne_zero p_monic
let d := p.natTrailingDegree
use ∑ n ∈ p.support, monomial (n - d) (p.coeff n)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I knew this proof was going to be fiddly but I hadn't appreciated that it would be this long. Do you think that using Polynomial.divByMonic would be easier than this approach?

. apply monic_of_degree_le_of_coeff_eq_one (p.natDegree - d) this
rw [finset_sum_coeff]
rw [Finset.sum_eq_single_of_mem p.natDegree]
. simp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you fix this non-terminal simp (if you don't refactor the proof?), maybe using simpa using Monic.leadingCoeff p_monic?

rw [natTrailingDegree_eq_support_min' p_neq_zero]
exact Finset.min'_le p.support b b_support
have this2 : d ≤ p.natDegree := by
exact Polynomial.natTrailingDegree_le_natDegree p
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably you don't need this2, you can just use Polynomial.natTrailingDegree_le_natDegree p.

Comment on lines 560 to 561
. rw [finset_sum_coeff]
rw [Finset.sum_eq_single_of_mem d]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just do them both in one rewrite?

. rw [finset_sum_coeff]
rw [Finset.sum_eq_single_of_mem d]
. rw [coeff_monomial]
simp [d, p_neq_zero]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, nonterminal simps are brittle so I'd like to avoid them in the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain why nonterminal simps are bad? Is there a better way to let Lean help simplify things?

rw [Nat.sub_eq_iff_eq_add this] at h
simp [h, this]
. rw [eval₂_finset_sum]
simp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here and in other places.

@pitmonticone
Copy link
Collaborator

I can certainly help you in golfing this proof if you want.

I'll have more time tonight.

Copy link
Collaborator

@pitmonticone pitmonticone left a comment

Choose a reason for hiding this comment

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

I have suggested two slightly shorter versions of the proofs.

@pitmonticone
Copy link
Collaborator

I have also removed the import Mathlib minimising the imports.

@morrison-daniel
Copy link
Contributor Author

I added the two suggestions. I'll check out Polynomial.divByMonic to see if that helps more.

@morrison-daniel
Copy link
Contributor Author

I was able to get it down to ~30 lines total using Mathlib.Algebra.Polynomial.Div

@kbuzzard
Copy link
Collaborator

This looks much better now! Many thanks!

@kbuzzard kbuzzard merged commit 04249af into ImperialCollegeLondon:main Oct 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FROBENIUS: elements of top ring divide elements of bottom ring
3 participants