2.1 Partition basics
2.1.1 Definitions
(a) An (integer) partition means a (finite) weakly decreasing tuple of positive integers – i.e., a finite tuple \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{m}\right) \) of positive integers such that \(\lambda _{1}\geq \lambda _{2}\geq \cdots \geq \lambda _{m}\).
Thus, partitions are the same as weakly decreasing compositions. Hence, the notions of size and length of a partition are automatically defined, since we have defined them for compositions (in Definition 1.291).
(b) The parts of a partition \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{m}\right) \) are simply its entries \(\lambda _{1},\lambda _{2},\ldots ,\lambda _{m}\).
(c) Let \(n\in \mathbb {Z}\). A partition of \(n\) means a partition whose size is \(n\).
(d) Let \(n\in \mathbb {Z}\) and \(k\in \mathbb {N}\). A partition of \(n\) into \(k\) parts is a partition whose size is \(n\) and whose length is \(k\).
A partition of \(n\) has all parts \(\leq n\).
Since parts are positive and sum to \(n\), each individual part is bounded by \(n\).
The partition of \(0\) has no parts (i.e., it is the empty tuple).
By definition.
The length of the partition of \(0\) is \(0\).
Follows from the fact that the partition of \(0\) has no parts.
The cardinality of a multiset of positive naturals is at most its sum.
By induction on the multiset.
A partition of \(n\) has at most \(n\) parts.
Since each part is \(\geq 1\), the number of parts is at most the sum of parts, which is \(n\).
For \(n{\gt}0\), every partition of \(n\) has at least one part.
If a partition of a positive \(n\) had no parts, its sum would be \(0\), a contradiction.
For \(n{\gt}0\), every partition of \(n\) has a positive largest part.
Since the partition has at least one part and all parts are positive, the maximum is positive.
For every \(n\in \mathbb {N}\), we have \(p(n) {\gt} 0\).
The empty partition (for \(n=0\)) or the indiscrete partition \((n)\) (for \(n{\gt}0\)) provides at least one partition.
(a) Let \(n\in \mathbb {Z}\) and \(k\in \mathbb {N}\). Then, we set
(b) Let \(n\in \mathbb {Z}\). Then, we set
This is called the \(n\)-th partition number.
- Nat.Partition.partsLeqCount m n = (Nat.Partition.restricted n fun (x : ℕ) => x ≤ m).card
- Nat.Partition.partsInCount I n = (Nat.Partition.restricted n fun (x : ℕ) => x ∈ I).card
We will use the Iverson bracket notation: If \(\mathcal{A}\) is a logical statement, then \(\left[ \mathcal{A} \right]\) means the truth value of \(\mathcal{A}\); this is the integer \(\begin{cases} 1, & \text{if }\mathcal{A}\text{ is true};\\ 0, & \text{if }\mathcal{A}\text{ is false}. \end{cases} \)
Note that the Kronecker delta notation is a particular case of the Iverson bracket: We have
The Iverson bracket equals \(1\) iff the proposition is true.
By case analysis on whether the proposition is true or false.
The Iverson bracket equals \(0\) iff the proposition is false (assuming \(1 \neq 0\)).
By case analysis on whether the proposition is true or false.
The sum of Iverson brackets equals the cardinality of the filtered set: \(\sum _{x \in s} \left[ p(x) \right] = |s \cap \{ x : p(x)\} |\).
Follows from the definition of the Iverson bracket and the identity \(\sum _{x \in s} \left[ p(x) \right] = |\{ x \in s : p(x)\} |\).
The Iverson bracket is multiplicative for conjunctions: \(\left[ P \wedge Q \right] = \left[ P \right] \cdot \left[ Q \right]\).
By case split on both propositions.
Let \(a\) be a real number.
Then, \(\left\lfloor a\right\rfloor \) (called the floor of \(a\)) means the largest integer that is \(\leq a\).
Likewise, \(\left\lceil a\right\rceil \) (called the ceiling of \(a\)) means the smallest integer that is \(\geq a\).
2.1.2 Simple properties of partition numbers
We agree to say that the largest part of the empty partition \(\left( {}\right) \) is \(0\) (even though this partition has no parts).
The largest part of the partition of \(0\) is \(0\).
The partition of \(0\) has no parts, so the maximum (with default \(0\)) is \(0\).
For a partition of \(n\), the largest part is at most \(n\).
Each part is bounded by \(n\) (by Lemma 2.2).
A partition has largest part \(\leq m\) if and only if all its parts are \(\leq m\).
The largest part is the maximum of all parts, so it is \(\leq m\) iff every part is \(\leq m\).
The set of partitions of \(n\) whose largest part is \(\le m\) equals the set of partitions of \(n\) with all parts \(\le m\).
Follows directly from Lemma 2.20.
Let \(n\in \mathbb {Z}\) and \(k\in \mathbb {N}\).
(a) We have \(p_{k}\left( n\right) =0\) whenever \(n{\lt}0\) and \(k\in \mathbb {N}\).
(b) We have \(p_{k}\left( n\right) =0\) whenever \(k{\gt}n\).
(c) We have \(p_{0}\left( n\right) =\left[ n=0 \right]\).
(d) We have \(p_{1}\left( n\right) =\left[ n{\gt}0 \right]\).
(e) We have \(p_{k}\left( n\right) =p_{k}\left( n-k\right) +p_{k-1}\left( n-1\right) \) whenever \(k{\gt}0\).
(f) We have \(p_{2}\left( n\right) =\left\lfloor n/2\right\rfloor \) whenever \(n\in \mathbb {N}\).
(g) We have \(p\left( n\right) =p_{0}\left( n\right) +p_{1}\left( n\right) +\cdots +p_{n}\left( n\right) \) whenever \(n\in \mathbb {N}\).
(h) We have \(p\left( n\right) =0\) whenever \(n{\lt}0\).
(a) The size of a partition is always nonnegative (being a sum of positive integers). Thus, a negative number \(n\) has no partitions whatsoever. Thus, \(p_{k}\left( n\right) =0\) whenever \(n{\lt}0\) and \(k\in \mathbb {N}\). (In the formalization, \(n\) is a natural number, so this case is vacuous.)
(b) If \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k}\right) \) is a partition, then \(\lambda _{i}\geq 1\) for each \(i\in \left\{ 1,2,\ldots ,k\right\} \) (because a partition is a tuple of positive integers, i.e., of integers \(\geq 1\)). Hence, if \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k}\right) \) is a partition of \(n\) into \(k\) parts, then
Thus, a partition of \(n\) into \(k\) parts cannot satisfy \(k{\gt}n\). Thus, no such partitions exist if \(k{\gt}n\). In other words, \(p_{k}\left( n\right) =0\) if \(k{\gt}n\).
(c) The integer \(0\) has a unique partition into \(0\) parts, namely the empty tuple \(\left( {}\right) \). A nonzero integer \(n\) cannot have any partitions into \(0\) parts, since the empty tuple has size \(0\neq n\). Thus, \(p_{0}\left( n\right) \) equals \(1\) for \(n=0\) and equals \(0\) for \(n\neq 0\). In other words, \(p_{0}\left( n\right) =\left[ n=0 \right]\).
(d) Any positive integer \(n\) has a unique partition into \(1\) part – namely, the \(1\)-tuple \(\left( n\right) \). On the other hand, if \(n\) is not positive, then this \(1\)-tuple is not a partition, so in this case \(n\) has no partition into \(1\) part. Thus, \(p_{1}\left( n\right) \) equals \(1\) if \(n\) is positive and equals \(0\) otherwise. In other words, \(p_{1}\left( n\right) =\left[ n{\gt}0 \right]\).
(e) Assume that \(k{\gt}0\). We must prove that \(p_{k}\left( n\right) =p_{k}\left( n-k\right) +p_{k-1}\left( n-1\right) \).
We consider all partitions of \(n\) into \(k\) parts. We classify these partitions into two types:
Type 1 consists of all partitions that have \(1\) as a part.
Type 2 consists of all partitions that don’t.
Any type-1 partition has \(1\) as a part, therefore as its last part (because it is weakly decreasing). Hence, any type-1 partition has the form \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k-1},1\right) \). If \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k-1},1\right) \) is a type-1 partition (of \(n\) into \(k\) parts), then \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k-1}\right) \) is a partition of \(n-1\) into \(k-1\) parts. Thus, we have a bijection
given by removing the trailing \(1\).
A type-2 partition does not have \(1\) as a part; hence, all its parts are larger than \(1\), and therefore we can subtract \(1\) from each part and still have a partition. If \(\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k}\right) \) is a type-2 partition of \(n\) into \(k\) parts, then \(\left( \lambda _{1}-1,\lambda _{2}-1,\ldots ,\lambda _{k}-1\right) \) is a partition of \(n-k\) into \(k\) parts. This gives a bijection
Since any partition of \(n\) into \(k\) parts is either type-1 or type-2, \(p_{k}\left( n\right) =p_{k}\left( n-k\right) +p_{k-1}\left( n-1\right)\).
(f) Let \(n\in \mathbb {N}\). The partitions of \(n\) into \(2\) parts are
Thus there are \(\left\lfloor n/2\right\rfloor \) of them. In other words, \(p_{2}\left( n\right) =\left\lfloor n/2\right\rfloor \).
(g) Let \(n\in \mathbb {N}\). Any partition of \(n\) must have \(k\) parts for some \(k\in \mathbb {N}\). Thus,
(h) Same argument as for (a).
Helpers for the recurrence (Proposition 2.22 (e))
The recurrence \(p_k(n) = p_k(n-k) + p_{k-1}(n-1)\) requires two bijections. The following definitions and lemmas provide the infrastructure.
Given a partition of \(n\) that contains \(1\) as a part, removing one copy of \(1\) yields a partition of \(n-1\). Conversely, adding one copy of \(1\) to a partition of \(n\) yields a partition of \(n+1\).
Given a partition of \(n\) into \(k\) parts with all parts \({\gt}1\), subtracting \(1\) from each part yields a partition of \(n-k\) into \(k\) parts. Conversely, adding \(1\) to each part of a partition of \(n\) into \(k\) parts produces a partition of \(n+k\) into \(k\) parts.
- p.subtractOneFromEach hk h = Nat.Partition.ofSums (n - k) (Multiset.map (fun (x : ℕ) => x - 1) p.parts) ⋯
- p.addOneToEach hk = Nat.Partition.ofSums (n + k) (Multiset.map (fun (x : ℕ) => x + 1) p.parts) ⋯
The set of partitions of \(n\) into \(k\) parts splits into those containing \(1\) and those not containing \(1\):
By the disjoint union of the two filtered sets.
For \(k{\gt}0\) and \(n{\gt}0\):
The bijection removes/adds a trailing \(1\).
The forward map removes one copy of \(1\); the backward map adds one. Injectivity and surjectivity follow from the fact that removing and adding a trailing \(1\) are mutually inverse operations.
For \(k{\gt}0\):
The bijection subtracts/adds \(1\) from/to each part.
The forward map subtracts \(1\) from each part (valid since all parts \({\gt}1\)). The backward map adds \(1\) to each part. Injectivity uses the fact that subtracting \(1\) from each entry is injective on multisets whose all elements are \({\gt}1\).
Helpers for \(p_2(n) = \lfloor n/2 \rfloor \) (Proposition 2.22 (f))
Every partition of \(n\) into \(2\) parts has the form \(\{ n-b,\, b\} \) for some \(1\le b \le \lfloor n/2\rfloor \).
If the partition has parts \(\{ a, b\} \) with \(b\le a\), then \(a+b = n\) and \(b\ge 1\) (since parts are positive), so \(a = n-b\) and \(2b\le n\).
We have \(p_k(n) = 0\) if and only if \(k {\gt} n\) or (\(k = 0\) and \(n {\gt} 0\)).
The forward direction follows by constructing an explicit partition with \(k\) parts when \(0 {\lt} k \leq n\) (namely \((1, 1, \ldots , 1, n - k + 1)\)). The backward direction uses parts (b) and (c) of Proposition 2.22.
2.1.3 The generating function
In the FPS ring \(\mathbb {Z}\left[ \left[ x\right] \right] \), we have
(The product on the right hand side is well-defined, since multiplying a FPS by \(\frac{1}{1-x^{k}}\) does not affect its first \(k\) coefficients.)
We have
where
It suffices to show that \(\left\vert Q_{n}\right\vert =p\left( n\right) \) for each \(n\in \mathbb {N}\).
We construct a bijection \(\pi :Q_{n}\rightarrow \left\{ \text{partitions of }n\right\} \): for any \(\left( u_{1},u_{2},u_{3},\ldots \right) \in Q_{n}\), define
This is a partition of \(n\). Its inverse map \(\rho \) sends each partition \(\lambda \) of \(n\) to \(\left( \text{\# of }1\text{'s in }\lambda ,\text{ \# of }2\text{'s in }\lambda , \ldots \right) \in Q_{n}\).
Let \(m\in \mathbb {N}\). For each \(n\in \mathbb {N}\), let \(p_{\operatorname {parts}\leq m}\left( n\right) \) be the # of partitions \(\lambda \) of \(n\) such that all parts of \(\lambda \) are \(\leq m\). Then,
This proof is analogous to the proof of Theorem 2.30, using \(m\)-tuples instead of infinite sequences. We have
where \(Q_{n}=\left\{ \left( u_{1},u_{2},\ldots ,u_{m}\right) \in \mathbb {N}^{m} \mid \ 1u_{1}+2u_{2}+\cdots +mu_{m}=n\right\} \). It suffices to show \(\left\vert Q_{n}\right\vert =p_{\operatorname {parts}\leq m}\left( n\right)\). The bijection \(\pi :Q_{n}\rightarrow \left\{ \text{partitions }\lambda \text{ of }n\text{ with all parts }\leq m\right\} \) is analogous to that in Theorem 2.30.
Let \(I\) be a subset of \(\left\{ 1,2,3,\ldots \right\} \). For each \(n\in \mathbb {N}\), let \(p_{I}\left( n\right) \) be the # of partitions \(\lambda \) of \(n\) such that all parts of \(\lambda \) belong to \(I\). Then,
Analogous to the proof of Theorem 2.31, with \(\prod _{k=1}^{m}\) replaced by \(\prod _{k\in I}\) and \(m\)-tuples replaced by essentially finite families \((u_i)_{i\in I}\in \mathbb {N}^{I}\).
2.1.4 Odd parts and distinct parts
Let \(n\in \mathbb {Z}\).
(a) A partition of \(n\) into odd parts means a partition of \(n\) whose all parts are odd.
(b) A partition of \(n\) into distinct parts means a partition of \(n\) whose parts are distinct.
(c) Let
A partition is into odd parts iff all its parts are odd.
By definition.
A partition is into distinct parts iff its parts multiset has no duplicates.
By definition.
A partition is into distinct parts iff each part appears at most once.
This is the characterization of “no duplicates” in terms of counts.
We have \(p_{\operatorname {odd}}\left( n\right) =p_{\operatorname {dist}}\left( n\right) \) for each \(n\in \mathbb {N}\).
Let \(n\in \mathbb {N}\). We construct a bijection
Given a partition \(\lambda \) of \(n\) into odd parts, we repeatedly merge pairs of equal parts in \(\lambda \) until no more equal parts appear. The final result is \(A\left( \lambda \right) \).
More precisely: if the original partition \(\lambda \) contains an odd part \(k\) exactly \(m\) times, and if the binary representation of \(m\) is \(m = \sum _{j=0}^{i} m_j 2^j\) with \(m_j \in \{ 0,1\} \), then the partition \(A(\lambda )\) contains the number \(2^j k\) exactly \(m_j\) times for each \(j\). Since the binary digits \(m_j\) are all \(\leq 1\), the partition \(A(\lambda )\) has distinct parts.
The inverse map \(B\) starts with a partition \(\lambda \) into distinct parts. Each part \(k \cdot 2^i\) (with \(k\) odd and \(i \geq 0\)) is replaced by \(2^i\) copies of \(k\). Equivalently, one repeatedly splits even parts into halves until only odd parts remain. The result \(B(\lambda )\) is a partition into odd parts.
The maps \(A\) and \(B\) are mutually inverse, establishing the bijection. Thus \(p_{\operatorname {odd}}(n) = p_{\operatorname {dist}}(n)\).
In the formalization, this is proved using Glaisher’s theorem from Mathlib, which generalizes this result: for any positive integer \(d\), the number of partitions with parts not divisible by \(d\) equals the number of partitions where no part is repeated \(d\) or more times. Euler’s identity is the special case \(d = 2\).
2.1.5 Partitions with a given largest part
For any partition \(\lambda = (\lambda _1, \lambda _2, \ldots , \lambda _k)\), the conjugate (or transpose) \(\lambda ^t\) is the partition whose Young diagram is obtained by transposing the Young diagram of \(\lambda \). Explicitly, \(\lambda ^t = (\mu _1, \mu _2, \ldots , \mu _p)\) where \(p\) is the largest part of \(\lambda \) and
This satisfies \(|\lambda ^t| = |\lambda |\).
The sum of the new parts equals the original size by a double-counting argument: \(\sum _i \mu _i = \sum _i \# \{ j : \lambda _j \geq i\} = \sum _j \lambda _j = n\).
The transpose preserves size: \(|\lambda ^t| = |\lambda |\), i.e., if \(\lambda \) is a partition of \(n\), then \(\lambda ^t\) is also a partition of \(n\).
This is a restatement of the defining property of the transpose.
The transpose is an involution: \((\lambda ^t)^t = \lambda \) for every partition \(\lambda \).
The proof uses the sorted list representation and the key combinatorial fact that for a sorted decreasing list, the transpose operation is controlled by the count of parts exceeding each threshold (Lemma 2.41). This establishes that applying the Young diagram transpose twice recovers the original partition.
For a sorted decreasing list \(\ell = (\ell _0, \ell _1, \ldots )\), indices \(j {\lt} |\ell |\), and any \(i\in \mathbb {N}\):
This is the key combinatorial lemma underlying the Young diagram transpose involution: it says the number of parts exceeding \(i\) is \({\gt}j\) precisely when the \(j\)-th part itself exceeds \(i\).
Forward: If \(|\{ k : \ell _k {\gt} i\} | \le j\), then \(\ell _j \le i\) (since the sorted property implies all elements from position \(j\) onward are \(\le \ell _j\), so at most \(j\) elements exceed \(i\)). Contrapositive gives the result.
Backward: If \(\ell _j {\gt} i\), then all \(\ell _0, \ldots , \ell _j\) are \({\gt} i\) (by the sorted property), so \(|\{ k : \ell _k {\gt} i\} | \ge j+1 {\gt} j\).
The length of the transpose equals the largest part of the original partition: \(\ell (\lambda ^t) = \) largest part of \(\lambda \).
The transpose has as many parts as there are columns in the Young diagram, which equals the number of boxes in the first row, i.e., the largest part.
For \(i {\lt} \) largest part of \(p\), the set of parts of \(p\) that are \({\gt} i\) is nonempty.
If all parts were \(\le i\), then the largest part would be \(\le i\), contradicting \(i {\lt}\) largest part.
For a partition \(p\), filtering to keep only the positive parts preserves the cardinality (since all parts are already positive).
Every part of a partition is positive, so restricting to positive parts does not change the count.
The largest part of the transpose equals the length of the original partition: largest part of \(\lambda ^t\) = \(\ell (\lambda )\).
The largest part of the transpose is the number of rows in the transposed diagram, which equals the number of rows of the original, i.e., \(\ell (\lambda )\).
Let \(n\in \mathbb {N}\) and \(k\in \mathbb {N}\). Then,
We use the transpose as a bijection between:
partitions of \(n\) with \(k\) parts, and
partitions of \(n\) with largest part \(k\).
For any partition \(\lambda =\left( \lambda _{1},\lambda _{2},\ldots ,\lambda _{k}\right) \), we define the conjugate \(\lambda ^{t}\) by \(\lambda ^{t}=\left( \mu _{1},\mu _{2},\ldots ,\mu _{p}\right) \), where \(p\) is the largest part of \(\lambda \) and \(\mu _{i}=\left( \text{\# of parts of }\lambda \text{ that are }\geq i\right) \) for each \(i\in \left\{ 1,2,\ldots ,p\right\} \). We have \(\left\vert \lambda ^{t}\right\vert =\left\vert \lambda \right\vert \) and \(\left( \lambda ^{t}\right) ^{t}=\lambda \) for each partition \(\lambda \), and the largest part of \(\lambda ^{t}\) equals the length of \(\lambda \). By Lemma 2.45, the transpose sends a partition with \(k\) parts to one whose largest part is \(k\). By Lemma 2.40, the transpose is an involution, hence a bijection. This establishes the result.
Let \(n\in \mathbb {N}\) and \(k\in \mathbb {N}\). Then,
We have
(by Proposition 2.46 applied to each \(i\)). This sum counts partitions of \(n\) whose largest part is \(\leq k\).
Direct from the two referenced results.
Let \(m\in \mathbb {N}\). Then,
For each \(n\in \mathbb {N}\), Corollary 2.47 shows that
where \(p_{\operatorname {parts}\leq m}\left( n\right) \) is defined as in Theorem 2.31. Hence,
(by Theorem 2.31).
2.1.6 Counting partitions by parts and largest part
Let \(k,\ell \in \mathbb {N}\).
\(q_{k,\ell }(n) := |\{ p \vdash n : \ell (p) = k,\; \text{largest part of }p = \ell \} |\).
\(Q(k,\ell ) := \sum _{n=k}^{k\ell } q_{k,\ell }(n)\), the total number of such partitions over all valid sizes.
- Nat.Partition.partsAndLargestCount k ℓ n = {p : n.Partition | p.numParts = k ∧ p.largestPart = ℓ}.card
- Nat.Partition.partsAndLargestCountTotal k ℓ = ∑ n ∈ Finset.Icc k (k * ℓ), Nat.Partition.partsAndLargestCount k ℓ n
For positive integers \(k\) and \(\ell \),
The proof uses a bijection between the disjoint union \(\bigsqcup _{n\in [k, k\ell ]} \{ p \vdash n : \ell (p)=k,\; \text{largest}=\ell \} \) and the set of \((k-1)\)-element multisubsets of \(\{ 0,1,\ldots ,\ell -1\} \), whose cardinality is \(\binom {\ell + (k-1) - 1}{k-1} = \binom {k+\ell -2}{k-1}\) by the stars-and-bars formula.
Forward map: A \((k-1)\)-element multisubset \(\{ a_1,\ldots ,a_{k-1}\} \subseteq \{ 0,1,\ldots ,\ell -1\} \) maps to the partition \((\ell ,\, a_1+1,\, \ldots ,\, a_{k-1}+1)\) sorted in decreasing order. This has \(k\) parts, largest part \(\ell \), and size \(\ell + \sum (a_i+1) \in [k, k\ell ]\).
Backward map: A partition \((\ell , \lambda _2,\ldots ,\lambda _k)\) maps to the multiset \(\{ \lambda _2-1, \ldots , \lambda _k-1\} \subseteq \{ 0,1,\ldots ,\ell -1\} \), since each \(\lambda _i\in \{ 1,\ldots ,\ell \} \).
The maps are mutual inverses: incrementing each element of the multiset by \(1\) after decrementing undoes the decrement on parts \(\ge 1\), and prepending \(\ell \) to the result of erasing \(\ell \) recovers the original multiset.
Properties of the multiset \((\ell , a_1+1, a_2+1, \ldots , a_{k-1}+1)\) for a \((k-1)\)-element multisubset \((a_1, \ldots , a_{k-1})\) of \(\{ 0,1,\ldots ,\ell -1\} \):
All elements are positive (since \(\ell \ge 1\) and each \(a_i+1\ge 1\)).
Cardinality is \(k\) (one \(\ell \) plus \(k-1\) from the multisubset).
Largest part is \(\ell \).
Removing \(\ell \) recovers the remaining parts \((a_1+1, \ldots , a_{k-1}+1)\).
The sum lies in \([k, k\ell ]\).
Each property follows from elementary multiset operations. In particular, (3) uses \(a_i+1\le \ell \) for \(a_i \in \{ 0,1,\ldots ,\ell -1\} \), and (5) uses the bounds \(1\le a_i+1\le \ell \).
2.1.7 Partition number vs. sums of divisors
For any set \(I\subseteq \{ 1,2,3,\ldots \} \) and \(n\in \mathbb {N}\):
Each partition \(p\) of \(n\) has size \(|p| = n\), so the sum of a constant equals the constant times the count.
For any finite set \(s\) of partitions of \(n\) and any \(d\in \mathbb {N}\):
This is the standard identity \(\sum _i f(i) = \sum _{j\ge 1}|\{ i : f(i)\ge j\} |\) applied with \(f(p) = \operatorname {count}(d, p)\), bounded by \(n\) since at most \(n/d\) copies of \(d\) fit in a partition of \(n\).
For any partition \(p\) of \(n\),
By induction on the multiset of parts.
For any partition \(p\) of \(n\) and \(d {\gt} 0\), \(\operatorname {count}(d, p) \leq n/d\).
At most \(n/d\) copies of \(d\) can fit in a partition of \(n\).
If a partition \(p\) of \(n\) contains \(j\) or more copies of a part \(d\), then removing \(j\) copies of \(d\) yields a valid partition of \(n - d \cdot j\). Conversely, adding \(j\) copies of a positive integer \(d\) to a partition of \(m\) yields a partition of \(m + d \cdot j\).
- p.removePartCopies d j _hd hj = { parts := p.parts - Multiset.replicate j d, parts_pos := ⋯, parts_sum := ⋯ }
Removing copies preserves positivity of remaining parts and adjusts the sum. Adding copies preserves positivity since \(d {\gt} 0\).
Let \(I \subseteq \{ 1, 2, 3, \ldots \} \), let \(d \in I\), and let \(d \cdot j \leq n\). Then
The bijection sends a partition \(p\) to the partition obtained by removing \(j\) copies of \(d\), and its inverse adds \(j\) copies of \(d\).
The forward map removes \(j\) copies of \(d\) from the partition. The backward map adds \(j\) copies. Both preserve the property that all parts are in \(I\). Injectivity and surjectivity are verified by showing the maps are mutual inverses.
For any set \(I\) of positive integers, any \(n \in \mathbb {N}\), and any function \(f\):
The bijection is \((k, d) \leftrightarrow (d, j)\) where \(k = d \cdot j - 1\).
The reindexing bijection is \((k, d) \leftrightarrow (d, j)\) where \(k = d \cdot j - 1\). The forward map sends \((k, d)\) to \((d, (k+1)/d)\) and the backward map sends \((d, j)\) to \((d \cdot j - 1, d)\).
Let \(I\) be a subset of \(\left\{ 1,2,3,\ldots \right\} \). For each \(n\in \mathbb {N}\), let \(p_{I}\left( n\right) \) be the # of partitions \(\lambda \) of \(n\) such that all parts of \(\lambda \) belong to \(I\).
For any positive integer \(n\), let \(\sigma _{I}\left( n\right) \) denote the sum of all positive divisors of \(n\) that belong to \(I\).
For any \(n\in \mathbb {N}\), we have
The proof uses a double counting argument. Both sides count weighted pairs.
LHS Analysis:
Swapping the order of summation and using the identity \(\sum _p \operatorname {count}(d, p) = \sum _{j \geq 1} |\{ p : \operatorname {count}(d, p) \geq j\} |\), together with the bijection from Lemma 2.58, gives:
RHS Analysis:
By the reindexing lemma (Lemma 2.59), this equals the same expression.
For any positive integer \(n\), let \(\sigma \left( n\right) \) denote the sum of all positive divisors of \(n\). (For example, \(\sigma \left( 6\right) =1+2+3+6=12\) and \(\sigma \left( 7\right) =1+7=8\).)
For any \(n\in \mathbb {N}\), we have
This is the particular case of Theorem 2.60 for \(I=\left\{ 1,2,3,\ldots \right\} \). We specialize the restricted version with \(I = \{ n \in \mathbb {N} : n {\gt} 0\} \). Since all parts of a partition are positive, the restricted set equals the set of all partitions, so \(p_I(n) = p(n)\). Similarly, \(\sigma _I(n) = \sigma (n)\) since all divisors of a positive integer are positive.
Generating function proof of the recurrence (alternative approach)
The divisor sum recurrence can also be proved via generating functions. Define \(P := \sum _{n\ge 0} p(n) x^n\) and \(S := \sum _{k\ge 1} \sigma (k) x^k\). Then \(X\cdot P' = S\cdot P\), and comparing coefficients gives the result.
The partition generating function \(P := \sum _{n\ge 0} p(n) x^n \in \mathbb {Z}[[x]]\) and the divisor sum generating function \(S := \sum _{k\ge 1} \sigma (k) x^k \in \mathbb {Z}[[x]]\).
- Nat.Partition.P = Nat.Partition.genFun fun (x x_1 : ℕ) => 1
- Nat.Partition.S = PowerSeries.mk fun (n : ℕ) => if n = 0 then 0 else ↑(Nat.Partition.divisorSum n)
The coefficient of \(x^n\) in \(P\) equals \(p(n)\): \([x^n]P = p(n)\).
Immediate from the definition of \(P\).
The coefficient of \(x^n\) in \(X\cdot P'\) equals \(n\cdot p(n)\): \([x^n](X \cdot P') = n \cdot [x^n]P\).
Since \([x^n](X\cdot f') = n\cdot [x^n]f\) for any FPS \(f\).
The coefficient of \(x^n\) in \(S\cdot P\) equals the RHS of the recurrence:
Expand the Cauchy product \([x^n](S\cdot P) = \sum _{i+j=n} [x^i]S\cdot [x^j]P\), noting that \([x^0]S = 0\) so the \(i=0\) term vanishes.
The generating function identity \(X\cdot P' = S\cdot P\) holds as an equality of formal power series in \(\mathbb {Z}[[x]]\).
Comparing coefficients at each \(x^n\): \([x^n](X\cdot P') = n\cdot p(n) = \sum _{k=1}^{n}\sigma (k)\cdot p(n-k) = [x^n](S\cdot P)\), where the middle equality is Theorem 2.61.