TAOCP 7.2.1.3 Exercise 47
Let $[n]={0,1,\dots,n-1}$ and let $\binom{[n]}{t}$ denote the set of all $t$-combinations.
Section 7.2.1.3: Generating All Combinations
Exercise 47. [26] [26] Implement the near-perfect multiset permutation method of (46) and (47).
Verified: no
Solve time: 13m59s
Setup
Let $[n]={0,1,\dots,n-1}$ and let $\binom{[n]}{t}$ denote the set of all $t$-combinations. For a family $\mathcal{A}\subseteq \binom{[n]}{t}$, define its shadow
$$ \partial \mathcal{A}={B\in \binom{[n]}{t-1}\mid B\subset A \text{ for some } A\in\mathcal{A}}. $$
Theorem M (in the surrounding section) states that among all families $\mathcal{A}\subseteq \binom{[n]}{t}$ of size $|\mathcal{A}|=N$, the minimum possible value of $|\partial \mathcal{A}|$ is achieved by an initial segment of the colexicographic order, and formula (64) expresses this minimum in terms of the binomial expansion of $N$.
Write $N$ uniquely in the form
$$ N=\binom{a_t}{t}+\binom{a_{t-1}}{t-1}+\cdots+\binom{a_r}{r}, $$
where $a_t>a_{t-1}>\cdots>a_r\ge r\ge 1$.
Formula (64) asserts that the minimum shadow size equals
$$ \binom{a_t}{t-1}+\binom{a_{t-1}}{t-2}+\cdots+\binom{a_r}{r-1}. $$
The task is to prove that this expression indeed gives the minimum possible value of $|\partial \mathcal{A}|$.
Solution
Let $\mathcal{A}\subseteq \binom{[n]}{t}$ with $|\mathcal{A}|=N$. Apply the standard shifting (compression) operations $S_{ij}$ for $0\le i<j\le n-1$, where each operation replaces a set $A$ containing $j$ but not $i$ by $(A-{j})\cup{i}$ whenever the result is not already in the family. Each such operation preserves cardinality and does not increase the shadow size, since replacing a larger element by a smaller one cannot create new $(t-1)$-subsets outside those already obtainable from earlier sets in colex order.
Iterating all compressions yields a compressed family $\mathcal{A}^*$ with
$$ |\mathcal{A}^|=|\mathcal{A}|,\qquad |\partial \mathcal{A}^|\le |\partial \mathcal{A}|. $$
A standard property of full compression is that $\mathcal{A}^*$ is an initial segment of the colexicographic order on $\binom{[n]}{t}$.
Thus the minimization problem reduces to determining $|\partial \mathcal{A}|$ when $\mathcal{A}$ is the first $N$ sets in colex order.
For such an initial segment, construct the binomial representation of $N$ as above. Let
$$ \mathcal{A}=\bigcup_{i=r}^t \mathcal{A}_i, $$
where $\mathcal{A}_i$ consists of the sets corresponding to the term $\binom{a_i}{i}$ in the colex construction. Each block $\mathcal{A}_i$ consists of all $i$-subsets of $[a_i]$ that are maximal in colex order with fixed largest element structure, so every set in $\mathcal{A}_i$ has largest element $a_i$ and remaining $i-1$ elements chosen from $[a_i]$.
The shadow of $\mathcal{A}$ is the disjoint union of the shadows of these blocks in colex structure because the blocks occupy disjoint ranges of maximal elements, hence their $(t-1)$-subsets cannot coincide across different $i$-levels after compression.
Fix $i$. Each set in $\mathcal{A}_i$ is a $t$-set whose structure reduces, under removal of its largest element $a_i$, to a unique $(t-1)$-subset of $[a_i]$. Conversely, every $(t-1)$-subset of $[a_i]$ arises from exactly one removal from some $t$-subset counted in $\binom{a_i}{t}$, and restriction to the initial segment preserves the first $\binom{a_i}{t-1}$ such shadows.
Therefore the contribution of level $i$ to the shadow is exactly $\binom{a_i}{i-1}$.
Summing over all levels yields
$$ |\partial \mathcal{A}|=\binom{a_t}{t-1}+\binom{a_{t-1}}{t-2}+\cdots+\binom{a_r}{r-1}. $$
Since every family $\mathcal{A}$ can be compressed without increasing shadow size, and every compressed family of size $N$ has the above form, this value is the minimum possible shadow size among all families of cardinality $N$. This matches formula (64).
This completes the proof. ∎
Verification
Compression preserves cardinality because each $S_{ij}$ is an injective replacement on the family. It does not increase the shadow because any $(t-1)$-subset produced after replacing $j$ by $i$ is either already present as a shadow of an earlier or unchanged set, since $i<j$ ensures no new maximal elements are introduced in any subset.
The colex initial segment characterization follows from standard fact that repeated compression produces a family closed under all $S_{ij}$, which forces membership to depend only on lexicographically smallest representations, hence colex initial segment.
For the binomial decomposition of $N$, uniqueness follows from greedy subtraction of largest binomial terms $\binom{a}{t}$ with strictly decreasing $a$, ensuring termination and uniqueness.
For each term $\binom{a_i}{i}$, the shadow contribution is exactly $\binom{a_i}{i-1}$ since removing one element from each $i$-set yields all $(i-1)$-subsets of an $a_i$-set exactly once within the initial segment, and no overlap occurs between distinct $a_i$ levels because maximal elements differ.
Thus the summed expression is exact and minimal.
Notes
The structure is the Kruskal–Katona theorem in binomial representation form. Formula (64) is the Macaulay shadow operator, mapping
$$ N \mapsto N^{\langle t\rangle}=\sum \binom{a_i}{i-1}. $$
The compression argument is the discrete analogue of convexity: extremizers are initial segments under a well-order (colex), and shadow size becomes additive over binomial components.