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] - refactor(ring_theory/unique_factorization_domain): completes the refactor of unique_factorization_domain #4156

Closed
wants to merge 15 commits into from

Conversation

awainverse
Copy link
Collaborator

Refactors unique_factorization_domain to unique_factorization_monoid
unique_factorization_monoid is a predicate
unique_factorization_monoid now requires no additive/subtractive structure


@awainverse awainverse added the awaiting-review The author would like community review of the PR label Sep 15, 2020
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 haven't looked at the big file yet... will do that later.
Thanks for doing this!

src/ring_theory/discrete_valuation_ring.lean Show resolved Hide resolved
src/ring_theory/principal_ideal_domain.lean Outdated Show resolved Hide resolved
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

I only looked at the big file, I will do the rest later :)

src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
Comment on lines 258 to 271
multiset.induction_on f
(λ h, (ha.1 (associated_one_iff_is_unit.1 h)).elim)
(λ p s _ hp hs, let ⟨u, hu⟩ := hp in ⟨p,
have hs0 : s = 0, from classical.by_contradiction
(λ hs0, let ⟨q, hq⟩ := multiset.exists_mem_of_ne_zero hs0 in
(hs q (by simp [hq])).2.1 $
(ha.2 ((p * ↑(u⁻¹)) * (s.erase q).prod) _
(by {rw [mul_right_comm _ _ q, mul_assoc, ← multiset.prod_cons, multiset.cons_erase hq,
mul_comm p _, mul_assoc, ← multiset.prod_cons, hu.symm, mul_comm, mul_assoc],
simp, })).resolve_left $
mt is_unit_of_mul_is_unit_left $ mt is_unit_of_mul_is_unit_left
(hs p (multiset.mem_cons_self _ _)).2.1),
⟨(by {clear _let_match; simp * at *}), hs0 ▸ rfl⟩⟩)
(pfa.2) (pfa.1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect this proof would be more readable if it's formatted in tactic-style. For example, the pfa.2 pfa.1 arguments at the end can stay with the function call if we make them the arguments to a refine call at the start.

Copy link
Member

Choose a reason for hiding this comment

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

While the proof is fresh in your mind you could even add a couple of comments saying what's going on. Christian Szegedy told me today that the machine learning people are desperate for comments in code.

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 made this a tactic proof, but I can't really say it's "fresh in my mind", because I didn't write the original and don't particularly understand it. I've added a docstring to the top because it took me a moment even to understand the statement.

src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
awainverse and others added 2 commits September 15, 2020 12:32
Co-authored-by: Vierkantor <Vierkantor@users.noreply.github.com>
Copy link
Member

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

This looks absolutely great to me. Many thanks for doing it!

Comment on lines 258 to 271
multiset.induction_on f
(λ h, (ha.1 (associated_one_iff_is_unit.1 h)).elim)
(λ p s _ hp hs, let ⟨u, hu⟩ := hp in ⟨p,
have hs0 : s = 0, from classical.by_contradiction
(λ hs0, let ⟨q, hq⟩ := multiset.exists_mem_of_ne_zero hs0 in
(hs q (by simp [hq])).2.1 $
(ha.2 ((p * ↑(u⁻¹)) * (s.erase q).prod) _
(by {rw [mul_right_comm _ _ q, mul_assoc, ← multiset.prod_cons, multiset.cons_erase hq,
mul_comm p _, mul_assoc, ← multiset.prod_cons, hu.symm, mul_comm, mul_assoc],
simp, })).resolve_left $
mt is_unit_of_mul_is_unit_left $ mt is_unit_of_mul_is_unit_left
(hs p (multiset.mem_cons_self _ _)).2.1),
⟨(by {clear _let_match; simp * at *}), hs0 ▸ rfl⟩⟩)
(pfa.2) (pfa.1)
Copy link
Member

Choose a reason for hiding this comment

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

While the proof is fresh in your mind you could even add a couple of comments saying what's going on. Christian Szegedy told me today that the machine learning people are desperate for comments in code.

@kbuzzard
Copy link
Member

kbuzzard commented Sep 15, 2020

Just to mention that there's this funny finiteness result polynomial.wf_dvd_monoid [integral_domain α] [wf_dvd_monoid α] : wf_dvd_monoid (polynomial α) in the UFD file. Is this also true for mv_polynomial? I think it might be.

Hey yeah I guess it's also true that if R is a UFD then so is mv_polynomial's over R with variables in an arbitrary type.

@awainverse awainverse added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Sep 15, 2020
@awainverse
Copy link
Collaborator Author

Just to mention that there's this funny finiteness result polynomial.wf_dvd_monoid [integral_domain α] [wf_dvd_monoid α] : wf_dvd_monoid (polynomial α) in the UFD file. Is this also true for mv_polynomial? I think it might be.

Hey yeah I guess it's also true that if R is a UFD then so is mv_polynomial's over R with variables in an arbitrary type.

Yeah, this is all that's needed other than Gauss's Lemma for showing that a polynomial ring over a UFD is a UFD.
I could try making it work for mv_polynomial, but I might want to wait for another PR

@awainverse awainverse added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Sep 16, 2020
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

Thank you so much for the changes! Just a few stylistic issues and it looks good to me.

src/ring_theory/discrete_valuation_ring.lean Outdated Show resolved Hide resolved
src/ring_theory/discrete_valuation_ring.lean Outdated Show resolved Hide resolved
src/ring_theory/discrete_valuation_ring.lean Outdated Show resolved Hide resolved
src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
Co-authored-by: Vierkantor <Vierkantor@users.noreply.github.com>
scripts/nolints.txt Outdated Show resolved Hide resolved
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.

lgtm

src/ring_theory/unique_factorization_domain.lean Outdated Show resolved Hide resolved
Co-authored-by: Johan Commelin <johan@commelin.net>
@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Sep 21, 2020
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Sep 21, 2020
@awainverse
Copy link
Collaborator Author

Hopefully fixing this merge conflict doesn't break anything.

@jcommelin
Copy link
Member

Thanks 🎉

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 Sep 22, 2020
bors bot pushed a commit that referenced this pull request Sep 22, 2020
…ctor of `unique_factorization_domain` (#4156)

Refactors `unique_factorization_domain` to `unique_factorization_monoid`
`unique_factorization_monoid` is a predicate
`unique_factorization_monoid` now requires no additive/subtractive structure




Co-authored-by: Aaron Anderson <65780815+awainverse@users.noreply.github.com>
@bors
Copy link

bors bot commented Sep 22, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(ring_theory/unique_factorization_domain): completes the refactor of unique_factorization_domain [Merged by Bors] - refactor(ring_theory/unique_factorization_domain): completes the refactor of unique_factorization_domain Sep 22, 2020
@bors bors bot closed this Sep 22, 2020
@bors bors bot deleted the ufmonoid branch September 22, 2020 08:04
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

5 participants