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(data/nat/factorization): Change definition of factorization to be computable #12301

Closed
wants to merge 62 commits into from

Conversation

BoltonBailey
Copy link
Collaborator

@BoltonBailey BoltonBailey commented Feb 26, 2022

This PR changes the definition of data.nat.factorization to not depend on multiset.to_finsupp and instead to depend on padic_val_nat. This sidesteps the computability issues with finsupp discussed in this thread.

To deal with the changed imports this PR also moves some material from number_theory/padics/padic_val and ring_theory/multiplicity into data/nat/factorization/basic.

Co-authored-by: Stuart Presnell stuart.presnell@gmail.com


Open in Gitpod

@ericrbg
Copy link
Collaborator

ericrbg commented Feb 26, 2022

I think if you want to do this, the right way is to make a computable multiset.to_finsupp without the add part

@BoltonBailey
Copy link
Collaborator Author

As Reid said here, the algorithm to compute nat.factors is one you would never want to use. In particular, I think that if we do this by making a computable multiset.to_finsupp, then when we call n.factorization p, we will have to completely factorize n, which will ultimately take time O(sqrt(max prime factor of n)). But this way, we are just getting the multiplicity of p in n the standard way and then checking that p is prime (which will be very fast if p is, say, 2).

@semorrison semorrison added the awaiting-author A reviewer has asked the author a question or requested changes label Feb 27, 2022
@BoltonBailey BoltonBailey added the WIP Work in progress label Feb 27, 2022
@leanprover-community-bot-assistant leanprover-community-bot-assistant added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Feb 28, 2022
@leanprover-community-bot-assistant leanprover-community-bot-assistant removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Mar 1, 2022
@stuart-presnell
Copy link
Collaborator

The proofs of factorization_zero and factorization_one can change to by simpa [factorization], and the proof of support_factorization becomes by simp [factorization].

@BoltonBailey
Copy link
Collaborator Author

Thanks for the helpful comments, I'll wait to implement them until this refactor of padic_norm is done if that's all right.

@leanprover-community-bot-assistant leanprover-community-bot-assistant 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 Mar 10, 2022
@leanprover-community-bot-assistant leanprover-community-bot-assistant added merge-conflict Please `git merge origin/master` then a bot will remove this label. and removed 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 Apr 21, 2022
@leanprover-community-bot-assistant leanprover-community-bot-assistant added blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. and removed merge-conflict Please `git merge origin/master` then a bot will remove this label. labels Apr 21, 2022
@stuart-presnell
Copy link
Collaborator

stuart-presnell commented Apr 23, 2022

Your most recent commit seems to be deleting the entire file src/data/part.lean. Is this an error (or am I misunderstanding)?

@BoltonBailey
Copy link
Collaborator Author

Your most recent commit seems to be deleting the entire file src/data/part.lean. Is this an error (or am I misunderstanding)?

Yes, I spun off a change to that file into a new PR, and then I hit delete, thinking it would revert my changes. Sort of my fault because I guess it did what it said it was going to do, but why there's a delete file option but not a revert file option seems strange to me. I'll add it back when I merge #13588

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.

Thanks!

bors d+

src/data/nat/factorization/basic.lean Outdated Show resolved Hide resolved
src/data/nat/factorization/basic.lean Outdated Show resolved Hide resolved
src/data/nat/totient.lean Outdated Show resolved Hide resolved
src/data/nat/totient.lean Outdated Show resolved Hide resolved
src/group_theory/exponent.lean Show resolved Hide resolved
src/group_theory/exponent.lean Outdated Show resolved Hide resolved
src/data/nat/factorization/basic.lean Outdated Show resolved Hide resolved
@bors
Copy link

bors bot commented Jul 18, 2022

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

@leanprover-community-bot-assistant leanprover-community-bot-assistant added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Jul 18, 2022
BoltonBailey and others added 7 commits July 18, 2022 16:54
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@BoltonBailey
Copy link
Collaborator Author

bors r+

@bors
Copy link

bors bot commented Jul 19, 2022

Canceled.

@BoltonBailey
Copy link
Collaborator Author

bors r-

@BoltonBailey
Copy link
Collaborator Author

BoltonBailey commented Jul 20, 2022

Ok, trying again

@BoltonBailey
Copy link
Collaborator Author

bors r+

bors bot pushed a commit that referenced this pull request Jul 20, 2022
…` to be computable (#12301)

This PR changes the definition of `data.nat.factorization` to not depend on `multiset.to_finsupp` and instead to depend on `padic_val_nat`. This sidesteps the computability issues with finsupp discussed in [this thread](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/.60ite.60.20with.20multiple.20decidable.20instances/near/272409877).

To deal with the changed imports this PR also moves some material from `number_theory/padics/padic_val` and `ring_theory/multiplicity` into `data/nat/factorization/basic`. 

Co-authored-by: Stuart Presnell <stuart.presnell@gmail.com>



Co-authored-by: Stuart Presnell <stuart.presnell@gmail.com>
@bors
Copy link

bors bot commented Jul 20, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(data/nat/factorization): Change definition of factorization to be computable [Merged by Bors] - refactor(data/nat/factorization): Change definition of factorization to be computable Jul 20, 2022
@bors bors bot closed this Jul 20, 2022
@bors bors bot deleted the BoltonBailey/computable-factorization branch July 20, 2022 21:45
joelriou pushed a commit that referenced this pull request Jul 23, 2022
…` to be computable (#12301)

This PR changes the definition of `data.nat.factorization` to not depend on `multiset.to_finsupp` and instead to depend on `padic_val_nat`. This sidesteps the computability issues with finsupp discussed in [this thread](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/.60ite.60.20with.20multiple.20decidable.20instances/near/272409877).

To deal with the changed imports this PR also moves some material from `number_theory/padics/padic_val` and `ring_theory/multiplicity` into `data/nat/factorization/basic`. 

Co-authored-by: Stuart Presnell <stuart.presnell@gmail.com>



Co-authored-by: Stuart Presnell <stuart.presnell@gmail.com>
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

6 participants