feat(Combinatorics): link Nat.Partition to YoungDiagram#39722
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 8f7e4fe3b7Import changes exceeding 2%
|
| File | Base Count | Head Count | Change |
|---|---|---|---|
| Mathlib.Combinatorics.Young.YoungDiagram | 533 | 553 | +20 (+3.75%) |
Import changes for all files
| Files | Import difference |
|---|---|
Mathlib.Combinatorics.Young.SemistandardTableau Mathlib.Combinatorics.Young.YoungDiagram |
20 |
Mathlib.Combinatorics.Enumerative.Partition.YoungDiagram (new file) |
722 |
Declarations diff (regex)
+ card_ofPartition
+ card_transpose
+ conjugate
+ conjugate_conjugate
+ equivPartition
+ ofPartition
+ ofPartition_toPartition
+ rowLens_ofPartition_eq_sort_parts
+ sum_rowLens_eq_card
+ toPartition
+ toPartition_ofPartition
You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.
Declarations diff (Lean)
✅ Lean-aware diff — post-build, computed from the Lean environment (commit
8f7e4fe).
- +12 new declarations
- −0 removed declarations
+Nat.Partition.conjugate
+Nat.Partition.conjugate_conjugate
+YoungDiagram.card_ofPartition
+YoungDiagram.card_transpose
+YoungDiagram.equivPartition
+YoungDiagram.ofPartition
+YoungDiagram.ofPartition_toPartition
+YoungDiagram.rowLens_ofPartition_eq_sort_parts
+YoungDiagram.sum_rowLens_eq_card
+YoungDiagram.toPartition
+YoungDiagram.toPartition.congr_simp
+YoungDiagram.toPartition_ofPartitionNo changes to strong technical debt.
Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)
| Current number | Change | Type (weak) |
|---|---|---|
| 4974 | 1 | exposed public sections |
Current commit 8f7e4fe3b7
Reference commit 8d0d1cff7b
This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
wwylele
left a comment
There was a problem hiding this comment.
Mostly comments on naming convention
|
Thank you for the review @wwylele. Questions for my own edification:
|
|
wwylele
left a comment
There was a problem hiding this comment.
Mostly minor golfing. I don't have other comments
| (p.parts.sort (· ≥ ·)).sum | ||
| = (↑(p.parts.sort (· ≥ ·)) : Multiset ℕ).sum := Multiset.sum_coe _ | ||
| _ = p.parts.sum := by rw [Multiset.sort_eq] |
There was a problem hiding this comment.
This part feels like a missing lemma ((?a : Multiset a).sort ?b).sum = (?a : Multiset a).sum that we should extract out
There was a problem hiding this comment.
#find_home suggests [Mathlib.Combinatorics.Enumerative.Composition]
NoahW314
left a comment
There was a problem hiding this comment.
Glad to see this is getting done!
I'm a little hesitant to place all of this in Partition/Basic since many other files import it as well. However, I do see the point of having conjugate defined here. Perhaps it would be better to move the equivalence to YoungDiagram (since this is essentially a leaf file) and then make a new file under Partition/ for conjugate?
Do we want this equivalence to be toYoungDiagram/ofYoungDiagram or toPartition/ofPartition? To me the latter seems more natural, but I'm curious to know what other people think.
Yeah, I'm down for this approach, as the equivalence isn't really the important part here.
I am biased as a number theorist, but converting a partition to a Young diagram to then perform some useful operation (e.g. conjugating, computing partition statistics, finding t-hooks) is "the" natural direction, seemingly more so than the other way around. That said, future modules that do these sorts of things don't actually have to care about this API direction, at least to the end user. |
Sorry, my original comment was poorly worded. To be clear, I'm suggesting moving everything to |
Implemented this since I agree that it makes the API and imports generally cleaner. |
Doing this in a later PR would be great! |
wwylele
left a comment
There was a problem hiding this comment.
Just one comment on the doc
wwylele
left a comment
There was a problem hiding this comment.
Sorry, I missed one small thing
Co-authored-by: Weiyi Wang <wwylele@gmail.com>
Nat.Partition to YoungDiagramNat.Partition to YoungDiagram
|
|
||
| @[simp] | ||
| lemma card_transpose (μ : YoungDiagram) : μ.transpose.card = μ.card := by | ||
| simp [transpose, YoungDiagram.card] |
There was a problem hiding this comment.
| simp [transpose, YoungDiagram.card] | |
| simp [transpose, card] |
or is that protected/ambiguous?
There was a problem hiding this comment.
The abbreviation is protected (L181).
Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
There was a problem hiding this comment.
For me it would make sense to make a file under Partition about the connection to Young diagrams, rather than chucking that in the basic YoungDiagram file, then this very short file needn't exist
There was a problem hiding this comment.
I intend to add some useful definitions and bijections concerning specifically conjugation in the future that would have made it less of a stub file, though I agree that the equivalence can naturally live in Partition.
Should the "direction" of the equivalences be changed as well? i.e. Nat.Partition.toYoungDiagram ?
| rw [← sum_rowLens_eq_card, rowLens_ofPartition_eq_sort_parts] | ||
| calc | ||
| (p.parts.sort (· ≥ ·)).sum | ||
| = (↑(p.parts.sort (· ≥ ·)) : Multiset ℕ).sum := Multiset.sum_coe _ | ||
| _ = p.parts.sum := by rw [Multiset.sort_eq] | ||
| _ = n := p.parts_sum |
There was a problem hiding this comment.
| rw [← sum_rowLens_eq_card, rowLens_ofPartition_eq_sort_parts] | |
| calc | |
| (p.parts.sort (· ≥ ·)).sum | |
| = (↑(p.parts.sort (· ≥ ·)) : Multiset ℕ).sum := Multiset.sum_coe _ | |
| _ = p.parts.sum := by rw [Multiset.sort_eq] | |
| _ = n := p.parts_sum | |
| rw [← sum_rowLens_eq_card, rowLens_ofPartition_eq_sort_parts, List.sort_perm.sum_eq, p.parts_sum] |
where sort_perm is a (missing?! surely I overlooked it) lemma saying l.sort _ is a permutation of l
There was a problem hiding this comment.
LeanSearch finds some close misses, such as List.perm_insertionSort. I'm unsure the best way to decide on a refactor given none of the options are quite right.
|
@kg583 As a reminder, you can type |
|
-awaiting-author |
AI disclosure: Claude was used to source some proof sketches.