-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(Combinatorics): link Nat.Partition to YoungDiagram
#39722
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
Open
kg583
wants to merge
22
commits into
leanprover-community:master
Choose a base branch
from
kg583:partition-young-diagram
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ad4e392
Add `YoungDiagram` conversion
kg583 73823e2
Add equivalence and conjugation
kg583 a19cde8
Prefer implicit binder
kg583 9b69192
Namespace nits
kg583 1caea90
Nits
kg583 e7b7763
Fix names
kg583 2afbc10
Move Young diagram lemma
kg583 a54c616
Golfs
kg583 fe6087d
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] c182087
Extract out `transpose_card_eq_card`
kg583 d182b96
Move equivalence and split out `Conjugate`
kg583 3905844
Additional `@[simp]`s
kg583 b1a5d07
Add `Conjugate` to Mathlib
kg583 15d77a8
Remove `selfConjugate` def (for now)
kg583 a7c4321
Rename to `card_transpose`
kg583 1fc2b96
Redundant docstring
kg583 3d512d8
Use direct subtype
kg583 8affb65
Whitespace lint
kg583 487d6f1
Merge remote-tracking branch 'upstream/master' into partition-young-d…
kg583 a9e05b3
Add `@[simp]`
kg583 3bb7bcc
Remove `rowLens_ofPartition_eq_parts`
kg583 8f7e4fe
Move Young diagram definitions
kg583 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
Mathlib/Combinatorics/Enumerative/Partition/YoungDiagram.lean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /- | ||
| Copyright (c) 2026 Kevin Gomez. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Kevin Gomez | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.Combinatorics.Enumerative.Partition.Basic | ||
| public import Mathlib.Combinatorics.Young.YoungDiagram | ||
|
|
||
| /-! | ||
| # Young diagram of a partition | ||
|
|
||
| This file defines the equivalence between Young diagrams `μ` with cardinality `n` and | ||
| partitions of `n`, where each row of the diagram becomes a part of the partition. | ||
| The two directions are `YoungDiagram.toPartition` and `YoungDiagram.ofPartition`. | ||
|
|
||
| Using this equivalence, the conjugate of a partition is also defined. Given the Young | ||
| diagram `μ` representing a partition `λ`, its conjugate `λ'` is the partition obtained | ||
| by flipping `μ` about the main diagonal, i.e. the columns of `μ` are the parts of `λ'`. | ||
| This is implemented here directly via `YoungDiagram.transpose`. | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| namespace YoungDiagram | ||
|
|
||
| /-- Convert a Young diagram to a partition. -/ | ||
| def toPartition {n : ℕ} (μ : YoungDiagram) (h : μ.card = n) : Nat.Partition n where | ||
| parts := μ.rowLens | ||
| parts_pos := μ.pos_of_mem_rowLens _ | ||
| parts_sum := by simp [sum_rowLens_eq_card, h] | ||
|
|
||
| /-- Convert a partition to a Young diagram. -/ | ||
| def ofPartition {n : ℕ} (p : Nat.Partition n) : YoungDiagram := | ||
| ofRowLens | ||
| (p.parts.sort (· ≥ ·)) | ||
| (Multiset.pairwise_sort p.parts (· ≥ ·)).sortedGE | ||
|
|
||
| @[simp] | ||
| theorem rowLens_ofPartition_eq_sort_parts {n : ℕ} (p : Nat.Partition n) : | ||
| (ofPartition p).rowLens = p.parts.sort (· ≥ ·) := by | ||
| grind [ofPartition, rowLens_ofRowLens_eq_self, Multiset.mem_sort] | ||
|
|
||
| @[simp] | ||
| theorem card_ofPartition {n : ℕ} (p : Nat.Partition n) : | ||
| (ofPartition p).card = n := by | ||
| 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 | ||
|
|
||
| @[simp] | ||
| theorem ofPartition_toPartition {n : ℕ} {μ : YoungDiagram} (h : μ.card = n) : | ||
| ofPartition (μ.toPartition h) = μ := by | ||
| simp [ofPartition, toPartition, List.mergeSort_eq_self (· ≥ ·) μ.rowLens_sorted.pairwise, | ||
| ofRowLens_to_rowLens_eq_self] | ||
|
|
||
| @[simp] | ||
| theorem toPartition_ofPartition {n : ℕ} {p : Nat.Partition n} : | ||
| (ofPartition p).toPartition (card_ofPartition p) = p := by | ||
| ext | ||
| simp [toPartition] | ||
|
|
||
| /-- Equivalence between Young diagrams of cardinality `n` and partitions of `n`. -/ | ||
| def equivPartition {n : ℕ} : { μ : YoungDiagram // μ.card = n } ≃ Nat.Partition n where | ||
| toFun μ := toPartition μ μ.2 | ||
| invFun p := ⟨ofPartition p, card_ofPartition p⟩ | ||
| left_inv := fun ⟨_, h⟩ => Subtype.mk_eq_mk.mpr (ofPartition_toPartition h) | ||
| right_inv := fun _ => toPartition_ofPartition | ||
|
|
||
| end YoungDiagram | ||
|
|
||
| namespace Nat.Partition | ||
|
|
||
| /-- Conjugate a partition (equivalent to transposing its Young diagram). -/ | ||
| def conjugate {n : ℕ} (p : Partition n) : Partition n := | ||
| (YoungDiagram.ofPartition p).transpose.toPartition (by | ||
| rw [YoungDiagram.card_transpose, YoungDiagram.card_ofPartition] | ||
| ) | ||
|
|
||
| /-- Conjugation is an involution. -/ | ||
| @[simp] | ||
| theorem conjugate_conjugate {n : ℕ} (p : Partition n) : p.conjugate.conjugate = p := by | ||
| ext | ||
| simp [conjugate] | ||
|
|
||
| end Nat.Partition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or is that protected/ambiguous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The abbreviation is protected (L181).