Adapted from De Bruijn:
Let $C, D$ be countable sets. We use $C^{D}$ to denote $\{ f: D \to C \}$, the set of all functions from $D$ to $C$.
To each element of $C$ we assign a *weight*. This weight may be a number, a variable, or in general an element of a commutative ring $\mathcal{A}$. The weight assigned to an element $c\in C$ will be called $w(c)$. We define the weight of a function $f\in C^D$ by $W(f)=\prod_{d\in D}w(f(d))$.
---
The inventory of $C^D$ is the sum of all function weights $W(f)$ for $f\in C^D$.
Say, for example, that $D=\{ 1,2,\dots,2025 \}$, which we'll denote $⟦2025⟧$ from here on, and $C=\{ 0,1 \}$. Then a function $f:D\to C$ can be taken to represent the subset of $D$ containing the elements mapped to $1$. If we assign $1$ and $x$, monomials with integer coefficients, as weights to the elements $0$ and $1$ of $C$ respectively, then the weight of $f$ is $x^k$ where $k$ is the number of elements of $D$ that are mapped to $1$ by $f$ which is the size of the subset represented by $f$. Moreover, there are ${2025 \choose k}$ subsets of $D$ of size $k$, so the inventory of $C^D$ is given by $\sum_{k=0}^{2025} {2025 \choose k}x^k$. But we know that this is also $(1+x)^{2025}$. Why?
More generally, we have that the inventory of $C^D$ is just the $\lvert D \rvert$th power of the inventory of $C$, allowing us to exploit the distributive property of our weights: $\text{inventory of $C^{D}$} = \prod_{d\in D} \sum_{c\in C} w(c) $By the inventory of $C$, I mean the sum of weights of elements of $C$ as written above. Too see this, observe that a term in the expansion of the right-hand side expression is a product of one term from each of $|D|$ factors which means selecting a function $f:D\to C$, since there is a one-to-one correspondence between the $|D|$ factors and $D$, and another one-to-one correspondence between the summands in each factor and $C$. The corresponding term to our choice of $f$ is just $\prod_{d\in D}w(f(d))$ which is exactly $W(f)$ showing that the full expansion is exactly the sum of all $W(f)$ for $f\in C^D.$
Now suppose that instead of representing a natural number $k$ as just one symbol, we represent $k$ with $k$ symbols which is perhaps more natural. That is, we take $D=\bigcup_{i=1}^{2025} D_{i}$ where the $D_{i}$ are disjoint sets of $i$ symbols. Then there is a bijection between the set of subsets of $⟦2025⟧$ and the set $S$ of *well-defined* functions $f:D\to C$ i.e. functions that are constant on each $D_{i}$. Using the same weights as before, the weight of well-defined function $f$ is given by $W(f)= \prod_{i=1}^{k}\prod_{d\in D_{i}} w(\phi(\psi(d)))=\prod_{i=1}^k w(\phi(i))^{\lvert D_{i} \rvert }=x^k$where $k$ is the number of $D_{i}$ that are mapped to $1$ by $f$ which is the sum of the elements of the subset represented by $f$. Like this, we see that the coefficient of $x^k$ in the inventory of $S$ will be the number of subsets of $⟦2025⟧$ that sum to $k$. Finally, we observe that this the same as in the expansion of $(1+x)(1+x^2)\cdots(1+x^{2025})$.
More generally, if $D_{1}, D_{2},\dots, D_{k}$ form a partition of $D$ and $S$ is the set of all well-defined functions in $C^D$ then
$\text{inventory of S} = \prod_{i=1}^{k} \sum_{c\in C} [w(c)]^{\lvert D_{i} \rvert }$
The set $S$ should be seen as the set of all function functions $f$ that can be factored as $\phi\circ\psi$ where: $\psi :D \to \{ i \}_{i=1}^{k}$ maps $d\in D$ to the index of the part to which $d$ belongs meaning that $d\in D_{\psi(d)}$; and $\phi:\{ i \}_{i=1}^{k}\to C$ so that $f(d) = \phi(\psi(d))$. Note that such a factorisation is unique and this result is known as *the universal property of quotients*. Now, a term in the expansion of the right-hand side expression above is obtained by a selecting a term in each from each of the $k$ factor, which means selecting a function $\phi:\{ i \}_{i=1}^{k}\to C$. Moreover, this $\phi$ produces the term $\prod_{i=1}^{k} [w(\phi(i))]^{\lvert D_{i} \rvert }$and if $f=\phi\circ\psi$, then this term is exactly $W(f)$ since $[w(\phi(i))]^{\lvert D_{i} \rvert } = \prod_{d\in D_{i}} w(\phi(\psi(d)))$and $\prod_{i=1}^{k}\prod_{d\in D_{i}} w(\phi(\psi(d))) = W(f).$We record this as lemma as it'll be useful for us later on:
> [!NOTE] Lemma
> Let $D_{1}, D_{2},\dots, D_{k}$ be a partition of $D$ and $S$ be the set of all from $D$ to $C$ that are well-defined functions with respect to this partition. Then the inventory of $S$ is given by $\sum_{f\in S} W(f) = \prod_{i=1}^{k} \sum_{c\in C} [w(c)]^{\lvert D_{i} \rvert }.$
Here is another example that demonstrate the usefulness of inventories and this lemma.
**Example**: ...
Note finally that we can make this lemma slightly more general by allowing $C$ and $D$ to be countable sets.
**Example**: For example, let $D=\bigcup_{i=1}^{\infty} D_{i}$ where $D_{i}$ is a set of $i$ letters, disjoint; $C = \mathbb{N}$ and assign weight $x^k$ to $k\in C$. Then the coefficient of $x^k$ in the inventory of $S$ is the number of subsets of $\mathbb{N}$ that sum to $k$. Applying
$\prod_{i=1}^\infty (1+x^k+x^{2k}+ \cdots)$
# References