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/fintype): pigeonhole principles #4096

Closed
wants to merge 25 commits into from

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Sep 10, 2020

Add pigeonhole principles for finitely and infinitely many pigeons in finitely many holes. There are also strong versions of these, which say that there is a hole containing at least as many pigeons as the average number of pigeons per hole. Fixes #2272.


I'm not sure what they should be called or where they should go. Also, the proof of fintype.strong_pigeonhole can surely be simplified!

Also added strong pigeonhole principles: there is a preimage whose
cardinality is at least as large as the average cardinality.
@kmill kmill linked an issue Sep 10, 2020 that may be closed by this pull request
4 tasks
@bryangingechen bryangingechen changed the title feat(data/fintype) pigeonhole principles feat(data/fintype): pigeonhole principles Sep 10, 2020
@kmill
Copy link
Collaborator Author

kmill commented Sep 10, 2020

This now should contain all the pigeonhole principles in the linked issue (along with some versions for infinitely many pigeons). I'm still not sure what all these lemmas should be called or where they should go, especially the ones that are currently in algebra/big_operators/order.lean.

For the strong pigeonhole principles, I opted to have them include a nonemptiness hypothesis:

lemma strong_pigeonhole [fintype α] [fintype β] [nonempty β] [decidable_eq β] (f : α → β)
  (n : ℕ) (hn : fintype.card β * n ≤ fintype.card α) :
  ∃ y : β, n ≤ (univ.filter (λ x, f x = y)).card := sorry

This can be eliminated with a trick (as in the linked issue) like so:

lemma strong_pigeonhole [fintype α] [fintype β] [decidable_eq β] (f : α → β)
  (n : ℕ) (hn : fintype.card β * n < fintype.card α) :
  ∃ y : β, n < (univ.filter (λ x, f x = y)).card := sorry

The rationale is that in the first case, n is the quotient of fintype.card α by fintype.card β rounded down, where in the second case it is almost the the same, but with the difference that if the quotient yields no remainder then n is one less than the quotient, which seemed potentially difficult to work with. Edit: I analyzed this incorrectly. The second case is one less than the ceiling, so it gives a stronger statement.

@kmill kmill added the awaiting-review The author would like community review of the PR label Sep 10, 2020
@kmill kmill requested a review from urkud September 10, 2020 17:29
These lemmas might be too specialized, but they help relate filter and
image a little more.
@semorrison semorrison added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Sep 19, 2020
@kmill kmill added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Sep 24, 2020
src/algebra/big_operators/order.lean Outdated Show resolved Hide resolved
src/data/finset/basic.lean Outdated Show resolved Hide resolved
src/data/finset/basic.lean Outdated Show resolved Hide resolved
src/algebra/big_operators/order.lean Outdated Show resolved Hide resolved
src/algebra/big_operators/order.lean Outdated Show resolved Hide resolved
@robertylewis robertylewis removed the awaiting-review The author would like community review of the PR label Sep 25, 2020
@kmill kmill added the awaiting-review The author would like community review of the PR label Sep 25, 2020
@kmill
Copy link
Collaborator Author

kmill commented Sep 25, 2020

Some things that still need to be figured out are (1) what to call these lemmas and (2) where these lemmas should live. (Started a thread on Zulip.)

src/algebra/big_operators/order.lean Outdated Show resolved Hide resolved
src/algebra/big_operators/order.lean Outdated Show resolved Hide resolved
@urkud
Copy link
Member

urkud commented Sep 28, 2020

@semorrison or @robertylewis Could you please look at this one more time? I did some golfing, so I should be the one who merges it into master.

@robertylewis
Copy link
Member

Other than naming, it looks good to me. I agree with the discussion on Zulip that we should keep the declaration names (approximately) following the naming scheme and save the word "pigeonhole" for the doc strings.

Copy link
Member

@urkud urkud left a comment

Choose a reason for hiding this comment

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

Forgot to rename 2 lemmas.

src/data/fintype/basic.lean Outdated Show resolved Hide resolved
src/data/fintype/basic.lean Outdated Show resolved Hide resolved
Copy link
Collaborator

@semorrison semorrison left a comment

Choose a reason for hiding this comment

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

Looks good to me! Let's merge.

@semorrison
Copy link
Collaborator

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Oct 1, 2020
bors bot pushed a commit that referenced this pull request Oct 1, 2020
Add pigeonhole principles for finitely and infinitely many pigeons in finitely many holes. There are also strong versions of these, which say that there is a hole containing at least as many pigeons as the average number of pigeons per hole. Fixes #2272.



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
@bors
Copy link

bors bot commented Oct 1, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/fintype): pigeonhole principles [Merged by Bors] - feat(data/fintype): pigeonhole principles Oct 1, 2020
@bors bors bot closed this Oct 1, 2020
@bors bors bot deleted the pigeonhole branch October 1, 2020 04:57
adomani pushed a commit that referenced this pull request Oct 7, 2020
Add pigeonhole principles for finitely and infinitely many pigeons in finitely many holes. There are also strong versions of these, which say that there is a hole containing at least as many pigeons as the average number of pigeons per hole. Fixes #2272.



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pigeonhole principle
6 participants