Repository navigation
[Merged by Bors] - feat(Data/Set/Card): cardinality of complement and difference - #43424
SnirBroshi wants to merge 10 commits into
Conversation
PR summary eb8ac302cdImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
!radar |
|
Benchmark results for 3d2a658 against 2308bf9 are in. No significant results found. @SnirBroshi
Small changes (2🟥)
|
b-mehta
left a comment
There was a problem hiding this comment.
oops I started reviewing and got distracted - I think this looks broadly nice!
…o feature/data/set-ncard-lemmas
Ruben-VandeVelde
left a comment
There was a problem hiding this comment.
maintainer delegate
|
🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde. |
…o feature/data/set-ncard-lemmas
Co-authored-by: Ruben Van de Velde <[email protected]>
j-loreaux
left a comment
There was a problem hiding this comment.
If you think the lemmas would succeed reasonably often with simps default discharger, then you can keep them.
bors d+
| alias ncard_inter_add_ncard_diff_eq_ncard := ncard_inter_add_ncard_sdiff_eq_ncard | ||
|
|
||
| /-- `ncard` of a difference with no subset assumption -/ | ||
| @[simp] |
There was a problem hiding this comment.
Unfortunately, this is mostly useless as a simp lemma, unless you expect (t ∩ s).Finite to be provable by whatever discharger the user provides to simp. The reason is that, unless the user supplies s and t first, the autoparam for by toFinite_tac doesn't fire, which means the user has to write the lemma manually. Essentially, the unification that causes the lemma to be applied happens too late (in the SimpM monad) to call the tactic (which would require TacticM). This is leanprover/lean4#3475
| @[simp] |
There was a problem hiding this comment.
This successfully fires in the simp call on line 1126 (right below this theorem), and also in something like
example {α : Type*} (x : α) : (Set.univ \ {x}).ncard = Nat.card α - 1 := by simp
example {α : Type*} {x y : α} (h : x ≠ y) : (Set.univ \ {x, y}).ncard = Nat.card α - 2 := by simp [h](which was the motivation to add this)
I think that in these cases the finiteness assumption is handled by simp, so it doesn't need to run the autoparam.
When the autoparam has to be used simp does seem to fail, but rw works:
example {α : Type*} [Finite α] (s t : Set α) : (s \ t).ncard ≤ s.ncard := by
rw [Set.ncard_sdiff'']
simpThis is unlike what the issue says, although the mwe there still fails. Not sure what causes the difference.
So these seem to succeed when at least one of the sets involved is given explicitly (with Insert notation), which I expect are the kinds of goals people try simp on.
Although the Lean issue is unfortunate here.
| (h : Nat.card α = n + s.ncard) : | ||
| sᶜ.ncard = n := by | ||
| rwa [← ncard_compl_add_ncard s, Nat.add_right_cancel_iff] at h | ||
| @[simp] |
There was a problem hiding this comment.
| @[simp] |
|
✌️ SnirBroshi can now approve this pull request until 2026-10-13 23:29 UTC (in 2 weeks). To approve and merge, reply with
|
|
Thanks! bors merge |
- `ncard_compl` doesn't need `sᶜ.Finite` - added `sᶜ.encard` lemma - added `[e]ncard (t \ s)` lemmas that don't require `s ⊆ t` - tag them `simp`
|
Pull request successfully merged into master. Build succeeded: |
ncard_compldoesn't needsᶜ.Finitesᶜ.encardlemma[e]ncard (t \ s)lemmas that don't requires ⊆ tsimpand generalized nearby similar things.
ncard_sdiff_singleton_of_memandpred_ncard_le_ncard_sdiff_singletonwere moved down to be able to use thencarddiff lemma.