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] - feat(data/nat/unique_factorization): a unique_factorization_monoid instance on N #4194

Closed
wants to merge 24 commits into from

Conversation

awainverse
Copy link
Collaborator

Provides a unique_factorization_monoid instance on nat
Shows its equivalence to nat.factors, which is list-valued


@awainverse awainverse added awaiting-review The author would like community review of the PR blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. labels Sep 21, 2020
@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
@awainverse awainverse removed 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 Sep 22, 2020
@awainverse awainverse changed the title feat(number_theory/unique_factorization): a unique_factorization_monoid instance on N (deps: #4156) feat(number_theory/unique_factorization): a unique_factorization_monoid instance on N Sep 22, 2020
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Sep 22, 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.

Some minor suggestions, it looks good otherwise!

section unique_units
variables [monoid α] [unique (units α)]

theorem associated_iff_eq {x y : α} : x ~ᵤ y ↔ x = y :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remark that you shouldn't feel the need to follow up on: we also have the implication associated = eq → unique (units α) from associated_one_iff_is_unit.

import data.nat.prime
import ring_theory.unique_factorization_domain

theorem nat.prime_iff {p : ℕ} : p.prime ↔ prime p :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

I never realized nat.prime had its own incompatible definition! Can you move this theorem to data/nat/prime.lean or will that cause cyclical imports?

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 made a new file, so as not to import algebra.associated into data.nat.prime for one lemma.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I'm a fan of small files but in this case I'm not sure. That nat.prime is the same as _root_.prime is a very fundamental result, so I would not expect it to be "hidden" in another file, as it were. And adding algebra.associated to the imports of data.nat.prime will only add two files to the import graph: algebra.associated itself and data.multiset.basic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, the proof of perm_of_prod_eq_prod seems to be screwed up by importing data.multiset.basic through algebra.associated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I figured it out.

{ right, rw [hn, nat.is_unit_iff.1 un, mul_one], } }
end

namespace nat
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the above two lemmas aren't in the nat namespace because it would interpret prime p as nat.prime, right? It looks a bit funny though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exactly. I should look into seeing how bad it'd be to replace nat.prime altogether.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It sounds like a good way to get rid of some spare time :)

src/number_theory/unique_factorization.lean Outdated Show resolved Hide resolved
src/number_theory/unique_factorization.lean Outdated Show resolved Hide resolved
src/number_theory/unique_factorization.lean Outdated Show resolved Hide resolved
src/number_theory/unique_factorization.lean Outdated Show resolved Hide resolved
@bors
Copy link

bors bot commented Sep 26, 2020

✌️ awainverse can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

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 🎉

I'm happy with the changes as they are, except that I'm in favour of incorporating data.nat.associated into data.nat.prime. It won't cause me to reject the PR though, so I'll let you decide what happens to it.

bors d+

@Vierkantor Vierkantor removed the awaiting-review The author would like community review of the PR label Sep 26, 2020
@Vierkantor Vierkantor added the delegated The PR author may merge after reviewing final suggestions. label Sep 26, 2020
@awainverse awainverse changed the title feat(number_theory/unique_factorization): a unique_factorization_monoid instance on N feat(data/nat/unique_factorization): a unique_factorization_monoid instance on N Sep 26, 2020
@awainverse
Copy link
Collaborator Author

bors r+

@bors
Copy link

bors bot commented Sep 26, 2020

Canceled.

@awainverse
Copy link
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request Sep 26, 2020
…instance on N (#4194)

Provides a `unique_factorization_monoid` instance on `nat`
Shows its equivalence to `nat.factors`, which is list-valued



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

bors bot commented Sep 26, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/nat/unique_factorization): a unique_factorization_monoid instance on N [Merged by Bors] - feat(data/nat/unique_factorization): a unique_factorization_monoid instance on N Sep 26, 2020
@bors bors bot closed this Sep 26, 2020
@bors bors bot deleted the nat_ufmonoid branch September 26, 2020 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants