feat(Data/Finset/Card): of cardinality between#20433
feat(Data/Finset/Card): of cardinality between#20433
Conversation
madvorak
commented
Jan 3, 2025
PR summary 61b2a51af5Import 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
|
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
| lemma of_cardinality_between_of_disjoint (hs : #s < n) (hn : n ≤ #s + #t) (hst : Disjoint s t) : | ||
| ∃ (x : Finset α) (hxs : Disjoint x s), #(x.disjUnion s hxs) = n ∧ Nonempty x := by |
There was a problem hiding this comment.
I think we should be satisfied with this statement:
| lemma of_cardinality_between_of_disjoint (hs : #s < n) (hn : n ≤ #s + #t) (hst : Disjoint s t) : | |
| ∃ (x : Finset α) (hxs : Disjoint x s), #(x.disjUnion s hxs) = n ∧ Nonempty x := by | |
| lemma of_cardinality_between_of_disjoint (hs : #s ≤ n) (hn : n ≤ #s + #t) (hst : Disjoint s t) : | |
| ∃ (x : Finset α) (hxs : Disjoint x s), #(x.disjUnion s hxs) = n := by |
because nonemptiness can be easily deduced from this:
import Mathlib
open Finset in
example {n} {α} (s x : Finset α) (hxs : Disjoint x s) (eq : #(x.disjUnion s hxs) = n)
(lt : #s < n) : x ≠ ∅ := by
rintro rfl; rw [← eq] at lt; simp at lt
(Note I've replaced Nonempty x with x ≠ ∅.)
There was a problem hiding this comment.
For the purposes of #19607 I prefer the stronger version.
There was a problem hiding this comment.
Do you want to have both lemmas?
There was a problem hiding this comment.
Yes please; and please use the x ≠ ∅ statement: from the lemmas around Finset.nonempty_iff_ne_empty I think statements involving ∅ are considered the normal form.
There was a problem hiding this comment.
Pinging @YaelDillies for a second opinion on whether that or Nonempty is preferred.
|
I don't really see the point of this lemma. Why can't you directly use |
You are right I don't use the new lemma. The lemma I use at the moment is: It will probably change after the refactor suggested by Kevin Buzzard. |
|
Can you @YaelDillies nevertheless clarify whether |
Ah okay, then I suggest we leave that PR unmerged for the time being, until what you actually need becomes clearer
|
|
Yes. All four PRs are labelled as WIP now. |
|
In the end, I will need exactly this lemma: Do you @YaelDillies want to weigh in on how it should be generalized for Mathlib? |
|
This lemma is overly specific, I find, so I think you should inline it where needed. Here's a golf, using new machinery that could belong in mathlib: |
|
Interesting. |
As a bonus, this lets us reduce imports. Also add the API that I independently came up with in #20433 (comment).
|
See also #23020 |
As a bonus, this lets us reduce imports. Also add the API that I independently came up with in #20433 (comment).
Add the API that I independently came up with in #20433 (comment).