Skip to content

[Merged by Bors] - chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version - #29821

Closed
mcdoll wants to merge 2 commits into
leanprover-community:masterfrom
mcdoll:choose_le
Closed

mcdoll wants to merge 2 commits into
leanprover-community:masterfrom
mcdoll:choose_le

Conversation

@mcdoll

@mcdoll mcdoll commented Sep 19, 2025

Copy link
Copy Markdown
Member

Very easy, but there might be some golfs possible

Open in Gitpod

@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label Sep 19, 2025
@github-actions

github-actions Bot commented Sep 19, 2025 •

Copy link
Copy Markdown

PR summary ff8e821b0b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ choose_lt_two_pow

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 script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@grunweg grunweg self-assigned this Sep 20, 2025

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 grunweg added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 20, 2025
@mcdoll mcdoll removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 20, 2025

@grunweg grunweg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!
maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by grunweg.

@ghost ghost added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Sep 20, 2025
@mcdoll mcdoll changed the title chore(Data/Nat/Choose): add one lemma and rename old one chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt version Sep 20, 2025
@mcdoll mcdoll changed the title chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt version chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version Sep 20, 2025

@bryangingechen bryangingechen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!
bors r+

@ghost ghost added ready-to-merge This PR has been sent to bors. and removed maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. labels Sep 21, 2025
mathlib-bors Bot pushed a commit that referenced this pull request Sep 21, 2025
@mathlib-bors

mathlib-bors Bot commented Sep 21, 2025

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version [Merged by Bors] - chore(Data/Nat/Choose): add le-version of a bound and fix name of the lt-version Sep 21, 2025
@mathlib-bors mathlib-bors Bot closed this Sep 21, 2025
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Oct 2, 2025
zhuyizheng pushed a commit to zhuyizheng/mathlib4 that referenced this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants