Partitions #
A partition of a natural number n
is a way of writing n
as a sum of positive integers, where the
order does not matter: two sums that differ only in the order of their summands are considered the
same partition. This notion is closely related to that of a composition of n
, but in a composition
of n
the order does matter.
A summand of the partition is called a part.
Main functions #
p : Partition n
is a structure, made of a multiset of integers which are all positive and add up ton
.
Implementation details #
The main motivation for this structure and its API is to show Euler's partition theorem, and related results.
The representation of a partition as a multiset is very handy as multisets are very flexible and already have a well-developed API.
TODO #
Link this to Young diagrams.
Tags #
Partition
References #
Equations
- x✝.decidableEqPartition x = decidable_of_iff' (x✝.parts = x.parts) ⋯
A composition induces a partition (just convert the list to a multiset).
Equations
- Nat.Partition.ofComposition n c = { parts := ↑c.blocks, parts_pos := ⋯, parts_sum := ⋯ }
Instances For
Given a multiset which sums to n
, construct a partition of n
with the same multiset, but
without the zeros.
Equations
- Nat.Partition.ofSums n l hl = { parts := Multiset.filter (fun (x : ℕ) => x ≠ 0) l, parts_pos := ⋯, parts_sum := ⋯ }
Instances For
A Multiset ℕ
induces a partition on its sum.
Equations
- Nat.Partition.ofMultiset l = Nat.Partition.ofSums l.sum l ⋯
Instances For
An element s
of Sym σ n
induces a partition given by its multiplicities.
Equations
- Nat.Partition.ofSym s = { parts := Multiset.map (fun (a : σ) => Multiset.count a ↑s) (↑s).dedup, parts_pos := ⋯, parts_sum := ⋯ }
Instances For
An equivalence between σ
and τ
induces an equivalence between the subtypes of Sym σ n
and
Sym τ n
corresponding to a given partition.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The partition of exactly one part.
Equations
- Nat.Partition.indiscrete n = Nat.Partition.ofSums n {n} ⋯
Instances For
Equations
- Nat.Partition.instInhabited = { default := Nat.Partition.indiscrete n }
Equations
- Nat.Partition.UniquePartitionZero = { toInhabited := Nat.Partition.instInhabited, uniq := Nat.Partition.UniquePartitionZero.proof_1 }
Equations
- Nat.Partition.UniquePartitionOne = { toInhabited := Nat.Partition.instInhabited, uniq := Nat.Partition.UniquePartitionOne.proof_1 }
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.)
Show there are finitely many partitions by considering the surjection from compositions to partitions.
Equations
The finset of those partitions in which every part is odd.
Equations
- Nat.Partition.odds n = Finset.filter (fun (c : n.Partition) => ∀ i ∈ c.parts, ¬Even i) Finset.univ
Instances For
The finset of those partitions in which each part is used at most once.
Equations
- Nat.Partition.distincts n = Finset.filter (fun (c : n.Partition) => c.parts.Nodup) Finset.univ
Instances For
The finset of those partitions in which every part is odd and used at most once.