How do I count combinations whose elements are drawn from nested sets?

237 Views Asked by At

I have $n$ finite sets. Each set is a strict subset of the next, i.e.,

$$S_1 \subset S_2 \subset S_3 \subset \ldots \subset S_n$$

I want to count the combinations of $n$ unordered elements where one element is drawn from $S_1$, one element is drawn from $S_2$, and so on.

Ideally, I'd like this both for the case where duplicate elements within a combination are allowed and for the case where they are not.

In other words, I want the number of $n$-sets (for the without-duplicate-elements case) or $n$-multisets (for the with-duplicate-elements case) $\{E_1,\cdots,E_n\}$ where $E_x \in S_x$.


For example, let's say I have the following sets.

$$ \begin{align} S_1 &= \{1, 2\} \\ S_2 &= \{1, 2, 3, 4\} \end{align} $$

I can then draw these 5 combinations:

$$ \{1,2\}, \{1,3\}, \{1,4\}, \{2,3\}, \{2,4\} $$

And, depending on whether or not duplicate elements within a combination are allowed, I could also include these two: $$ \{1,1\}, \{2,2\} $$

Note that the combinations $\{3,3\}, \{3,4\}, \{4,4\}$ are not counted. Each of those is impossible to draw in such a way that one element comes from $S_1$ and one element comes from $S_2$.

1

There are 1 best solutions below

3
On

Edited: This is answering a different question; I had misinterpreted the direction of set containment. If the $S_i$'s were shrinking rather than growing... so e.g if $|S_i| = n+1-i$, then there's only one way to choose all the way up.

Imagine choosing in reverse order. Let's write $m_i = |S_i|$, and I'll write $x_i$ for your $E_i$ because I can't stand element variables being capital letters.

Then there are

  • $m_n$ ways to choose $x_n \in S_n$,

  • $m_{n-1} - 1$ ways to choose $x_{n-1} \in S_{n-1}$, distinct from $x_n$

  • $m_{n-2} - 2$ ways to choose $x_{n-2} \in S_{n-2}$, distinct from $x_n$ and $x_{n-1}$

    $\vdots$

  • $m_1 - (n-1)$ ways to choose $x_1 \in S_1$, distinct from all other $x_i$'s.

Your answer (if I've interpreted your question correctly: you want an ordered list $(x_1, \dots, x_n)$ of distinct elements, where each $x_i \in S_i$ and the $S_i$'s are nested) is thus $$ \prod_{i=1}^n \left(|S_i| - (n-i) \right). $$