File: Mathlib/Combinatorics/Enumerative/Partition.lean

full_name: Nat.Partition.parts_sum
code: /-- A partition of `n` is a multiset of positive integers summing to `n`. -/
@[ext]
structure Partition (n : ℕ) where
  /-- positive integers summing to `n`-/
  parts : Multiset ℕ
  /-- proof that the `parts` are positive-/
  parts_pos : ∀ {i}, i ∈ parts → 0 < i
  /-- proof that the `parts` sum to `n`-/
  parts_sum : parts.sum = n
goal: self.parts.sum = n

full_name: Nat.Partition.parts
code: /-- A partition of `n` is a multiset of positive integers summing to `n`. -/
@[ext]
structure Partition (n : ℕ) where
  /-- positive integers summing to `n`-/
  parts : Multiset ℕ
  /-- proof that the `parts` are positive-/
  parts_pos : ∀ {i}, i ∈ parts → 0 < i
  /-- proof that the `parts` sum to `n`-/
  parts_sum : parts.sum = n
goal: Multiset ℕ

full_name: Nat.Partition
code: /-- A partition of `n` is a multiset of positive integers summing to `n`. -/
@[ext]
structure Partition (n : ℕ) where
  /-- positive integers summing to `n`-/
  parts : Multiset ℕ
  /-- proof that the `parts` are positive-/
  parts_pos : ∀ {i}, i ∈ parts → 0 < i
  /-- proof that the `parts` sum to `n`-/
  parts_sum : parts.sum = n
goal: Type

full_name: Nat.Partition.parts_pos
code: /-- A partition of `n` is a multiset of positive integers summing to `n`. -/
@[ext]
structure Partition (n : ℕ) where
  /-- positive integers summing to `n`-/
  parts : Multiset ℕ
  /-- proof that the `parts` are positive-/
  parts_pos : ∀ {i}, i ∈ parts → 0 < i
  /-- proof that the `parts` sum to `n`-/
  parts_sum : parts.sum = n
goal: i ∈ self.parts → 0 < i

full_name: Nat.Partition.decidableEqPartition
code: instance decidableEqPartition {n : ℕ} : DecidableEq (Partition n) 
goal: DecidableEq n.Partition

full_name: Nat.Partition.ofComposition
code: /-- A composition induces a partition (just convert the list to a multiset). -/
@[simps]
def ofComposition (n : ℕ) (c : Composition n) : Partition n 
goal: n.Partition

full_name: Nat.Partition.ofComposition_parts
code: /-- A composition induces a partition (just convert the list to a multiset). -/
@[simps]
def ofComposition (n : ℕ) (c : Composition n) : Partition n 
goal: (Nat.Partition.ofComposition n c).parts = ↑c.blocks

full_name: Nat.Partition.ofComposition_surj
code: theorem ofComposition_surj {n : ℕ} : Function.Surjective (ofComposition n) 
goal: Function.Surjective (Nat.Partition.ofComposition n)

full_name: Nat.Partition.ofSums
code: /-- Given a multiset which sums to `n`, construct a partition of `n` with the same multiset, but
without the zeros.
-/
@[simps]
def ofSums (n : ℕ) (l : Multiset ℕ) (hl : l.sum = n) : Partition n 
goal: n.Partition

full_name: Nat.Partition.ofSums_parts
code: /-- Given a multiset which sums to `n`, construct a partition of `n` with the same multiset, but
without the zeros.
-/
@[simps]
def ofSums (n : ℕ) (l : Multiset ℕ) (hl : l.sum = n) : Partition n 
goal: (Nat.Partition.ofSums n l hl).parts = Multiset.filter (fun x => x ≠ 0) l

full_name: Nat.Partition.ofMultiset
code: /-- A `Multiset ℕ` induces a partition on its sum. -/
@[simps!]
def ofMultiset (l : Multiset ℕ) : Partition l.sum 
goal: l.sum.Partition

full_name: Nat.Partition.ofMultiset_parts
code: /-- A `Multiset ℕ` induces a partition on its sum. -/
@[simps!]
def ofMultiset (l : Multiset ℕ) : Partition l.sum 
goal: (Nat.Partition.ofMultiset l).parts = Multiset.filter (fun x => ¬x = 0) l

full_name: Nat.Partition.ofSym
code: /-- An element `s` of `Sym σ n` induces a partition given by its multiplicities. -/
def ofSym {n : ℕ} {σ : Type*} (s : Sym σ n) [DecidableEq σ] : n.Partition 
goal: n.Partition

full_name: Nat.Partition.ofSym_map
code: @[simp] lemma ofSym_map (e : σ ≃ τ) (s : Sym σ n) :
    ofSym (s.map e) = ofSym s 
goal: Nat.Partition.ofSym (Sym.map (⇑e) s) = Nat.Partition.ofSym s

full_name: Nat.Partition.ofSymShapeEquiv
code: /-- An equivalence between `σ` and `τ` induces an equivalence between the subtypes of `Sym σ n` and
`Sym τ n` corresponding to a given partition. -/
def ofSymShapeEquiv (μ : Partition n) (e : σ ≃ τ) :
    {x : Sym σ n // ofSym x = μ} ≃ {x : Sym τ n // ofSym x = μ} 
goal: { x // Nat.Partition.ofSym x = μ } ≃ { x // Nat.Partition.ofSym x = μ }

full_name: Nat.Partition.indiscrete
code: /-- The partition of exactly one part. -/
def indiscrete (n : ℕ) : Partition n 
goal: n.Partition

full_name: Nat.Partition.instInhabited
code: instance {n : ℕ} : Inhabited (Partition n) 
goal: Inhabited n.Partition

full_name: Nat.Partition.indiscrete_parts
code: @[simp] lemma indiscrete_parts {n : ℕ} (hn : n ≠ 0) : (indiscrete n).parts = {n} 
goal: (Nat.Partition.indiscrete n).parts = {n}

full_name: Nat.Partition.partition_zero_parts
code: @[simp] lemma partition_zero_parts (p : Partition 0) : p.parts = 0 
goal: p.parts = 0

full_name: Nat.Partition.UniquePartitionZero
code: instance UniquePartitionZero : Unique (Partition 0) 
goal: Unique (Nat.Partition 0)

full_name: Nat.Partition.partition_one_parts
code: @[simp] lemma partition_one_parts (p : Partition 1) : p.parts = {1} 
goal: p.parts = {1}

full_name: Nat.Partition.UniquePartitionOne
code: instance UniquePartitionOne : Unique (Partition 1) 
goal: Unique (Nat.Partition 1)

full_name: Nat.Partition.ofSym_one
code: @[simp] lemma ofSym_one (s : Sym σ 1) : ofSym s = indiscrete 1 
goal: Nat.Partition.ofSym s = Nat.Partition.indiscrete 1

full_name: Nat.Partition.count_ofSums_of_ne_zero
code: /-- The number of times a positive integer `i` appears in the partition `ofSums n l hl` is the same
as the number of times it appears in the multiset `l`.
(For `i = 0`, `Partition.non_zero` combined with `Multiset.count_eq_zero_of_not_mem` gives that
this is `0` instead.)
-/
theorem count_ofSums_of_ne_zero {n : ℕ} {l : Multiset ℕ} (hl : l.sum = n) {i : ℕ} (hi : i ≠ 0) :
    (ofSums n l hl).parts.count i = l.count i 
goal: Multiset.count i (Nat.Partition.ofSums n l hl).parts = Multiset.count i l

full_name: Nat.Partition.count_ofSums_zero
code: theorem count_ofSums_zero {n : ℕ} {l : Multiset ℕ} (hl : l.sum = n) :
    (ofSums n l hl).parts.count 0 = 0 
goal: Multiset.count 0 (Nat.Partition.ofSums n l hl).parts = 0

full_name: Nat.Partition.instFintype
code: /-- Show there are finitely many partitions by considering the surjection from compositions to
partitions.
-/
instance (n : ℕ) : Fintype (Partition n) 
goal: Fintype n.Partition

full_name: Nat.Partition.odds
code: /-- The finset of those partitions in which every part is odd. -/
def odds (n : ℕ) : Finset (Partition n) 
goal: Finset n.Partition

full_name: Nat.Partition.distincts
code: /-- The finset of those partitions in which each part is used at most once. -/
def distincts (n : ℕ) : Finset (Partition n) 
goal: Finset n.Partition

full_name: Nat.Partition.oddDistincts
code: /-- The finset of those partitions in which every part is odd and used at most once. -/
def oddDistincts (n : ℕ) : Finset (Partition n) 
goal: Finset n.Partition