-
Notifications
You must be signed in to change notification settings - Fork 298
[Merged by Bors] - feat(number_theory): Bertrand's postulate, slightly different approach #8002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started looking at this PR and I am very happy that you are working on Bertrand's postulate! At the moment, I only have some golfing suggestions.
Good luck proving |
…8667) This PR is for a new lemma (currently called `exp_bound'`) which proves `exp x` is close to its `n`th degree taylor expansion for sufficiently large `n`. Unlike the previous bound, this lemma can be instantiated on any real `x` rather than just `x` with absolute value less than or equal to 1. I am separating this lemma out from #8002 because I think it stands on its own. The last time I checked it was sorry free - but that was before I merged with master and moved it to a different branch. It may also benefit from a little golfing. There are a few lemmas I proved as well to support this - one about the relative size of factorials and a few about sums of geometric sequences. The ~~geometric series ones should probably be generalized and moved to another file~~ this generalization sort of exists and is in the algebra.geom_sum file. I didn't find it initially since I was searching for "geometric" not "geom".
Update: Since being advised to tighten up the proof a little, I have been working on some things related to the prime counting function, so we can have a better bound on that if desired. Right now, I have gone through to comment out many of the calculus based proofs, some of which seem to have broken, and which shouldn't be necessary anyway if we go the " |
We do actually have Tochiori's bounds already, in |
Ok, after 6 or so months, this PR is once again compiling and sorry-free, now without derivatives. There are still things left to do in terms of making the tighter Tochiori bounds on the prime counting function and binomial coefficient so that we don't have to brute force a prime over 1024. Also, generally cleaning the proof up. Ideally, each of the statements in the main inequality chain should be isolated and extracted as their own lemmas, which are then chained together in a |
@BoltonBailey Thanks for plugging away at it! The PR will get shorter once #9925 is merged and we've integrated src/data/nat/choose/central.lean into this proof; it's basically a parallel cherry-picked development of the central binomial coefficient stuff, but it's already committed to mathlib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! LGTM modulo a few minor comments but I would prefer to have one more review before merging it.
UPD: @digama0 says that there is a better proof. I'm assigning this PR to him.
Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
@digama0 To explain what's happened with this PR since we discussed it last, and why we haven't implemented all the tricks from the Tochiori paper: We did start on these, but I think we concluded that the main thing that was causing the cutoff If you still feel that the cutoff should be around 64, I can follow through on the proof that |
The prime checking is not the bottleneck, the issue is the proof of the asymptotic part. Tochiori's proof both lowers the bound and also works out numerically much better, without the need for huge high precision estimates of log. |
Tochiori's proof sounds nice. But where does the current proof use high precision estimates of log? |
I think @digama0 may be thinking of a version of the proof from before you came and switched out the proof we had with the one using the concavity of In fact, even if I ignore the runtime from the lemmas in the Tochiori version which use the exponential bounds, I still get that the current version is about 10 seconds faster. I'm not sure it makes sense to switch back, given that it would apparently increase the running time. |
@digama0 🏓 |
@BoltonBailey The proof does indeed look a lot better now. I gave it a once-over, a mix of golfing, optimization, and unpacking some long lines, and now the whole file compiles in about 4 seconds, comparable to much more basic files, which is a testament to all the work that went into improving those bounds. Congratulations! bors r+ |
#8002) Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Pull request successfully merged into master. Build succeeded: |
#8002) Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
#8002) Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
\alpha
fromdata.nat.choose.central
instead]sqrt * log
is strictly convex on x>1 #14822convex_on.le_right_of_left_le
#14821Related to #2784, going via analysis.
@BoltonBailey You might be interested in this - the remaining sorries are all quite tractable.