Repository navigation
[Merged by Bors] - chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version - #29821
[Merged by Bors] - chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version#29821mcdoll wants to merge 2 commits into
Conversation
PR summary ff8e821b0bImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.You can run this locally as
|
grunweg
left a comment
There was a problem hiding this comment.
Thanks for this PR. I found a small golf (see below); otherwise LGTM.
| rw [← Nat.sub_add_cancel p] | ||
| exact choose_succ_le_two_pow (n - 1) k | ||
|
|
||
| theorem choose_le_two_pow (n k : ℕ) : n.choose k ≤ 2 ^ n := by |
There was a problem hiding this comment.
Here's a golf:
theorem choose_le_two_pow (n k : ℕ) : n.choose k ≤ 2 ^ n := by
obtain (rfl | hk) := eq_zero_or_pos k
· simp [Nat.one_le_two_pow]
· obtain (rfl | hn) := eq_zero_or_pos n
· have : choose 0 k = 0 := by convert Nat.choose_zero_succ (k - 1); omega
simp [this]
· exact (Nat.choose_lt_two_pow _ _ hn).le
You can use omega for both subgoals after the convert,
and if you use the right lemma to case-split, you can avoid some rewrites by dummy hypotheses.
There was a problem hiding this comment.
It might be worth extracting a lemma that choose 0 k is always <= 1 (either, it's choose 0 0 = 1, or 0 by the above).
Do you think this would be worth it? (If it exists, please use it; exact? did not find it, though.)
There was a problem hiding this comment.
I don't think so and I don't know how useful it would be. I usually just want to bound the whole thing independently of k , because it pops up whenever you have to estimate products of derivatives.
grunweg
left a comment
There was a problem hiding this comment.
Thanks!
maintainer merge
|
🚀 Pull request has been placed on the maintainer queue by grunweg. |
|
Pull request successfully merged into master. Build succeeded: |
Very easy, but there might be some golfs possible