# An interesting combinatorics problem

$A$ is a set containing $n$ elements. A subset $P_1$ of $A$ is chosen. The set is reconstructed by replacing the elements of $P_1$. Then a subset $P_2$ is chosen and again the set is reconstructed by replacing the elements of $P_2$. In this way $m$ subsets $P_1,......,P_m$ are chosen where $m>1$. Find the number of ways of choosing $P_1,.......,P_m$ such that no two of them are pairwise disjoint.

I don't have any clue how to start this problem I tried a lot of things but couldn't even get close to a conclusion.

Edit: An equivalent (and hopefully simpler and neater) way of putting it.

Given a set $A$ with $n$ elements, let $B=(P_1,P_2 \cdots, P_m)$ be a tuple of $m$ non-empty subsets of $A$, $P_i \subset A$ such that $P_i \cap P_j \ne \varnothing$. How many different $B$ there are?

• What do you mean "replace"? So each element of $P_1$ is exchanged with an element in $A\setminus P_1$? Or can I "replace" them with themselves or other elements of $P_1$? Can I replace multiple elements of $P_1$ with the same element? What was the point of choosing the subsets if I replaced them afterwards? What are the many things you have tried? – Kevin Long Sep 28 '17 at 21:33
• seems to understand that, upon each extraction of a subset, the set $A$ is ripristinated to the original composition, by refilling it with (a copy) of the elements extracted. Is it so ? – G Cab Sep 28 '17 at 21:37
• @user481779 Please edit G Cab's interpretation into the question. As is it is nearly incomprehensible. – Reinstate Monica Oct 2 '17 at 19:06
• The "number of ways" is sensitive to permutations or not? I mean, $(P_1 P_2 ... )$ and $(P_2,P_1...)$ are distinct? Also: the subsets $P_i$ must be distinct? – leonbloy Oct 6 '17 at 12:28
• Assuming the answer to my questions above are resp. yes and no, I edited the question. – leonbloy Oct 6 '17 at 12:33

Hint: The following reformulation of the problem might be useful:

Consider $(0,1)$-matrices with $m$ rows and $n$ columns. Find the number of $(0,1)$-matrices so that for each two rows there is at least one position $j\ (1\leq j \leq n)$ where both rows have a $1$ at this position.

Here we consider wlog $A=[n]=\{1,2,\ldots,n\}$ and encode the subset $\emptyset\ne P_k\subset A$ with the $k$-th $(1\leq k\leq m)$ row. The position $j$ in the $k$-th row is $1$ iff $j\in P_k$.

Small values:

With the help of a little R code we obtain for small values of $m$ and $n$ the number $S(n,m)$ of admissible matrices as

$$\begin{array}{c|rrrrrrr} m\backslash n&1&2&3&4&5&6&\cdots\\ \hline 1&1&3&7&15&31&63&\cdots\\ 2&1&7&37&175&781&3\,367&\cdots\\ 3&1&15&175&1\,827&17\,791&\cdots\\ 4&1&31&781&17\,887&\cdots\\ 5&1&63&3\,367&\cdots\\ \vdots&\\ \end{array}$$

We find in OEIS the values of $S(n,m)$ for

• $m=1$ as A000225 the number of non-empty subsets with $n$ elements.

\begin{align*} S(n,1)&=(1,3,7,15,31,\ldots)\\ &=(2^n-1)_{n\geq 1} \end{align*}

• $m=2$ as A005061 the number of binary $(2\times n)$-arrays with a path of adjacent $1$'s from top row to bottom row.

\begin{align*} S(n,2)&=(1,7,37,175,781,3\,367,\ldots)\\ &=(4^n-3^n)_{n\geq 1} \end{align*}

• $m=3$ as A051588 the number of binary $(3\times n)$-matrices such that any $2$ rows have a common $1$.

\begin{align*} S(n,3)&=(1,15,175,1\,827,17\,791,\ldots)\\ &=(8^n-3\cdot 6^n+3\cdot5^n-4^n)_{n\geq 1} \end{align*}

• $m=4$ as A051587 the number of binary $(4\times n)$-matrices such that any $2$ rows have a common $1$.

\begin{align*} S(n,4)&=(1,31,781,17\,887,\ldots)\\ &=(16^n -6\cdot 12^n +12\cdot 10^n -9^n\\ &\qquad-16\cdot 8^n +15\cdot 7^n -6\cdot 6^n +5^n)_{n\geq 1} \end{align*}

• $m=5$ as A051589 the number of binary $(5\times n)$-matrices such that any $2$ rows have a common $1$.

\begin{align*} S(n,5)&=(1, 63, 3\,367, \ldots)\\ &=(32^n - 10\cdot 24^n + 30\cdot 20^n - 5\cdot 18^n + 5\cdot 17^n\\ &\qquad - 70\cdot 16^n - 30\cdot 15^n + 135\cdot 14^n + 30\cdot 13^n\\ &\qquad- 140\cdot 12^n - 2\cdot 11^n + 130\cdot 10^n - 110\cdot 9^n\\ &\qquad+ 45\cdot 8^n - 10\cdot 7^n + 6^n)_{n\geq 1} \end{align*}

Note: We observe that $S(n,m)$ has for $1\leq m\leq 5$ a representation as alternating sum of certain powers of $n$. When we recall that ${n\brace k}$ the Stirling numbers of the second kind gives the number of partitions of $n$ elements into $k$ non-empty subsets and a representation can be given as alternating sum of powers of $n$ \begin{align*} {n\brace k}=\frac{1}{k!}\sum_{j=0}^k(-1)^{k-j}\binom{k}{j}j^n \end{align*} this indicates that a summation formula for $S(m,n)$ including Stirling numbers of the second kind should be within reach.

• If you strengthen the requirements so that each pair of rows must have exactly one position of $1$ in common, you get a balanced incomplete block design. You can't do it with just any size matrix, but you can for a $7\times7$ matrix, a $13\times13$ matrix, a $31\times31$ matrix, and in general a $n^2+n+1$ sided square matrix, where $n$ is prime. – Wildcard Oct 7 '17 at 4:10

1 ) Premise

Consider a $(m \times n)$ binary matrix $\boldsymbol{A}$ as already indicated by Markus.

Each row represents a subset of the set $\{1, \cdots,n\}$, and we shall have that each of the $m$ rows has at least one $'1'$ on the same column with any of the others.
In other words: that no row vector be normal to any of the others, or that $\boldsymbol {AA^T}$ does not contain zero values.

The all zeros vector = empty vector is normal to itself and to any other vector, and shall be accounted carefully.
We follow here the strategy to include it in the computations and elide it at the proper step.

We have $2^n$ possible vectors (empty included), and, since they can be repeated, $2^{nm}$ possible matrices.

2) Normal vectors

Consider a vector with $q$ ones. Clearly all the vectors normal to that shall have $q$ $'0'$s corresponding to the $'1'$s, and whatever value in the remaining positions. $$\bbox[lightyellow] { \begin{array}{c|cccccc} {} & 1 & 2 & 3 & \cdots & {n - 1} & n \\ \hline {\mathbf{V}_{\,q} \;\;:q\;'1'} & 1 & 0 & 1 & \cdots & 0 & 1 \\ {\mathbf{V}_{\,q \bot } : \bot \mathbf{V}_{\,q} } & \text{0} & \text{x} & \text{0} & \cdots & \text{x} & \text{0} \\ \end{array} } \tag{1}$$

There are ${n \choose q}$ vectors with $q$ ones, $2^{n-q}$ vectors normal to each of them , $2^{n}-2^{n-q}$ vectors
not normal.

Since the second vector is repeated, we can sum the above over $q$ to get the number of couples of vectors normal to each other $$\bbox[lightyellow] { H_{\,2} = \sum\limits_{0\, \le \,q\, \le \,n} {\left( \matrix{ n \cr q \cr} \right)2^{\,n - q} } = \sum\limits_{0\, \le \,q\, \le \,n} {\left( \matrix{ n \cr q \cr} \right)2^{\,q} } = \left( {1 + 2} \right)^{\,n} = 3^{\,n} } \tag{2}$$

To append a third vector normal to the 1st and 2nd we repeat the scheme above: - ${n \choose q_1}$ ways to choose the 1st vector - ${{n-q_1} \choose q_2}$ ways to choose the 2nd vector - $2^{n-q_{1}-q_{2}}$ ways to choose the 3rd vector \bbox[lightyellow] { \eqalign{ & H_{\,3} = \sum\limits_{0\, \le \,q_{\,1} \, \le \,n} {\sum\limits_{0\, \le \,q_{\,2} \, \le \,n} {\left( \matrix{ n \cr q_{\,1} \cr} \right)\left( \matrix{ n - q_{\,1} \cr q_{\,2} \cr} \right)2^{\,n - q_{\,1} - q_{\,2} } } } = \cr & = 2^{\,n} \sum\limits_{0\, \le \,q_{\,1} \, \le \,n} {\left( \matrix{ n \cr q_{\,1} \cr} \right)\left( {\sum\limits_{0\, \le \,q_{\,2} \, \le \,n} {\left( \matrix{ n - q_{\,1} \cr q_{\,2} \cr} \right)2^{\, - q_{\,2} } } } \right)2^{ - q_{\,1} } } = \cr & = 2^{\,n} \left( {1 + 1/2} \right)^n \sum\limits_{0\, \le \,q_{\,1} \, \le \,n} {\left( \matrix{ n \cr q_{\,1} \cr} \right)3^{ - q_{\,1} } } = 3^n \left( {1 + {1 \over 3}} \right)^n = 4^n \cr} }

It is easy to check that we can write the above as \bbox[lightyellow] { \eqalign{ & H_{\,3} (n) = \sum\limits_{0\, \le \,q_{\,1} \, \le \,n} {\sum\limits_{0\, \le \,q_{\,2} \, \le \,n} {\left( \matrix{ n \cr q_{\,1} \cr} \right)\left( \matrix{ n - q_{\,1} \cr q_{\,2} \cr} \right)2^{\,n - q_{\,1} - q_{\,2} } } } = \cr & = \sum\limits_{0\, \le \,q_{\,2} \, \le \,n} {\left( \matrix{ n \cr q_{\,2} \cr} \right)H_{\,2} (n - q_{\,2} )} \cr} } and thus that we can generalize them to get the number of mutually normal $h$-uples $$\bbox[lightyellow] { H_{\,h} = \left( {h + 1} \right)^{\,n} } \tag{3.a}$$ and that their number excluding the empty vector $H_ {* _{\,h}}$ is $$\bbox[lightyellow] { H_{\,h} = \left( {h + 1} \right)^{\,n} = \sum\limits_{0\, \le \,j\, \le \,n} {\left( \matrix{ n \cr j \cr} \right)h^{\,n - j} } \quad \Rightarrow \quad H_{ * _{\,h}} = h^{\,n} } \tag{3.b}$$

Let's now note that for 2 vectors normal to a third are not necessarily mutually normal.
$$\bbox[lightyellow] { \left( {1 \bot 2} \right) \cap \left( {1 \bot 3} \right) \cap \left( {2 \bot 3} \right) \ne \left( {1 \bot 2} \right) \cap \left( {1 \bot 3} \right) }$$ So we need to refer back to the table (1) and imagine to add further rows with $y,z, ..$ etc. in correspondence of the $x$'s, and then refer to (2) to get $$\bbox[lightyellow] { H_{1,\,m} = \left| {\,\left( {1 \bot 2} \right) \cap \left( {1 \bot 3} \right) \cap \cdots \cap \left( {1 \bot m} \right)\,} \right| = \left( {1 + 2^{m - 1} } \right)^n } \tag{4.a}$$

But, when there is not a common vector $$\bbox[lightyellow] { \left| {\,\left( {1 \bot 2} \right) \cap \left( {3 \bot 4} \right)\,} \right| = H_{\,2} ^2 } \tag{4.b}$$

3) $m$-uples with at least one normal couple

At this step we shall compute the number of $m$-uples of vectors that contains one or more couples.

To this scope we can resort to the inclusion-exclusion principle.

So for $m=3$ we get \bbox[lightyellow] { \eqalign{ & Q_{\,3} = \left| {\,\left( {1,2} \right) \cup \left( {1,3} \right) \cup \left( {2,3} \right)\,} \right| = \cr & = \left| {\,\left( {1,2} \right)\,} \right| + \left| {\,\left( {1,3} \right)\,} \right| + \left| {\,\,\left( {2,3} \right)} \right| + \cr & - \left| {\,\left( {1,2} \right) \cap \left( {1,3} \right)\,} \right| - \left| {\,\left( {1,2} \right) \cap \left( {2,3} \right)\,} \right| - \left| {\,\left( {1,3} \right) \cap \left( {2,3} \right)\,} \right| + \cr & + \left| {\,\left( {1,2} \right) \cap \left( {1,3} \right) \cap \left( {2,3} \right)\,} \right| = \cr & = 3H_{\,2} 2^{\,n} - 3H_{\,1,3} + H_{\,3} = 3 \cdot 3^{\,n} \cdot 2^{\,n} - 3 \cdot 5^{\,n} + 4^{\,n} = \cr & = 3\left( {6^{\,n} - 5^{\,n} } \right) + 4^{\,n} \cr} } \tag{5} which includes the null vector.

It returns $1,\, 7,\,49,\,337,\,2296,\,14977,\,97189,\,\cdots\quad|\;n=0,1,\cdots$ which checks with computation.
Interesting to note that, when complemented ($\overline Q _m = 2^{\,m\,n} - Q_m$) it gives $$0,\, 1,\,15,\,175,\,1827,\,17791,\,164955,\,\cdots$$ that is the sequence indicated by Markus, and which is a logical deduction from the inclusion-exclusion principle.

It remains to find a suitable extension of the formula above to general values of $m$, that allows to by-pass the inclusion-exclusion formula, also considering the difficulty introduced with (4.b).

• @G.Cab: Very nice elaboration. (+1) – Markus Scheuer Oct 8 '17 at 6:46
• @MarkusScheuer: thanks Markus. I appreciate your elaboration as well. The proposed connection with Stirling numbers is interesting. – G Cab Oct 8 '17 at 8:33
• @G.Cab: You're welcome. The connection with the Stirling numbers of the second kind indicates the strong relationship with inclusion-exclusion principle. See for instance this question. – Markus Scheuer Oct 8 '17 at 8:39
• @MarkusScheuer: I saw the answer you indicated: very interesting! also for the factor $1/m!$ which stands for the fact that rows can be permuted ... . Have a look to my last add concerning complementation. – G Cab Oct 8 '17 at 10:33
• This was the main reason for my (+1) to your answer. :-) I've checked it against $S(n,3)$ stated in my answer ($m=3$) and then I wrote my comment to you. ... Again: Very nice elaboration :-) – Markus Scheuer Oct 8 '17 at 10:38

As far as I know there is no known general formula for $S(n,m)$, the number of binary $(m\times n)$ matrices with the property that any two rows have a common $1$. In the paper On the number of Boolean functions in the Post classes $F_8^{\mu}$ by V. Jovović and G. Kilibarda (1999) the authors provide $S(n,m)$ for small values of $m$ ($1\leq m\leq 8)$.

Here we consider in some detail the formula for $S(n,4)$ which is given for non-negative integer values $n$ as (see the other answer for references) \begin{align*} \color{blue}{S(n,4)}&\color{blue}{=16^n -6\cdot 12^n +12\cdot 10^n -9^n}\\ &\qquad\color{blue}{-16\cdot 8^n +15\cdot 7^n -6\cdot 6^n +5^n}\tag{1} \end{align*}

Since the representation (1) is not that obvious (for me) I wanted to better understand what's going on. The nice contributions from the others clearly indicate that the inclusion-exclusion principle is a proper technique to attack the problem. But to even better see the details a refined approach using graphs is convenient.

Overview:

We consider binary $(4\times n)$ matrices and denote the four rows with $(P_1,P_2,P_3,P_4)$ in accordance with OPs notation. We represent each matrix as graph. The four rows of a matrix are the four nodes of the graph and an edge connects two nodes if and only if the corresponding rows of the matrix are orthogonal, i.e. they have no common $1$.

A graph with $m$ nodes may have $0$ up to $\binom{m}{2}$ edges so that the number of different graphs is \begin{align*} \sum_{k=0}^{\binom{m}{2}}\binom{\binom{m}{2}}{k}=2^{\binom{m}{2}} \end{align*}

In the current situation we have $m=4$ and since $\binom{4}{2}=6$ there is a total of \begin{align*} \sum_{k=0}^{6}\binom{6}{k}=2^6=64 \end{align*} graphs which can be divided into $7$ different groups corresponding to graphs with $0$ up to $6$ edges.

The following table lists the $64$ different graphs organised in $7$ groups. We can see a correspondence of graphs with $k\ (0\leq k\leq 6)$ nodes and those with $6-k$ nodes. Note that within a group not all graphs are isomorphic. Graphs within a group which are not isomorphic are separated by dotted lines. We see there are two different types of isomorphic graphs in the group with $2$ and the group with $4$ edges and three different types in the group with $3$ edges.

Results:

We start with the core figures which will be proved in the next section. We select representatives for each of the isomorphic graphs and provide the number of matrices accordingly.

• The table below lists in each row figures for graphs with $k$ edges. This means that there are (at least) $k$ pairs of nodes which are (pairwise) orthogonal. In order to identify different isomorphic graphs within a group with the same $k$ we use a subscript a,b and c where appropriate.

• The number $N_k$ gives the number of different graphs which are isomorphic with the representative (see the calculation below which provides the representatives).

• The number $A_k$ gives the number of different matrices corresponding to the representative.

$$\begin{array}{llccl} k&N_k&&&A_k\\ \hline 0&1&&&16^n\\ 1&6&&&12^n\\ 2_a,2_b&12,3&&&10^n,9^n\\ 3_a,3_b,3_c&4,12,4&&&8^n,8^n,9^n\\ 4_a,4_b&12,3&&&7^n,7^n\\ 5&6&&&6^n\\ 6&1&&&5^n\\ \end{array}$$



Calculation:

$k=0$:

No constraints are given, for each of the nodes $P_i,1\leq i\leq 4$ there are $2^n$ different possibilities. We obtain a total of \begin{align*} \color{blue}{A_0}=2^n2^n2^n2^n\color{blue}{=16^n} \end{align*}

$k=1$:

The representative has an edge connecting $P_1$ and $P_2$. We are looking for the number of matrices where row $P_1$ and row $P_2$ are orthogonal. We obtain \begin{align*} \color{blue}{A_1}&=2^n2^n\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}\\ &=4^n3^n\\ &\color{blue}{=12^n} \end{align*}

$k=2_a$:

The representative has an edge connecting $P_1$ and $P_2$ and another edge connecting $P_1$ with $P_3$. We are looking for the number of matrices where row $P_1$ and row $P_2$ are orthogonal as well as where row $P_1$ and row $P_3$ are orthogonal. We obtain \begin{align*} \color{blue}{A_{2_a}}&=2^n\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}2^{n-q_1}\\ &=2^n\sum_{q_1=0}^n\binom{n}{q_1}4^{n-q_1}\\ &=2^n5^n\\ &\color{blue}{=10^n} \end{align*}

$k=2_b$:

The representative has an edge connecting $P_1$ and $P_2$ and another edge connecting $P_3$ with $P_4$. We are looking for the number of matrices where row $P_1$ and row $P_2$ are orthogonal as well as where row $P_3$ and row $P_4$ are orthogonal. We obtain \begin{align*} \color{blue}{A_{2_b}}&=\left(\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}\right)^2\\ &=\left(3^n\right)^2\\ &\color{blue}{=9^n} \end{align*}

The next calculations are done similarly. An index $q_i$ is used when counting the number of admissible ways of $P_i$.

$k=3_a$:

We obtain \begin{align*} \color{blue}{A_{3_a}}&=2^n\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^n\binom{n-q_1}{q_2}2^{n-q_1-q_2}\\ &=2^n\sum_{q_1=0}^n\binom{n}{q_1}3^{n-q_1}\\ &=2^n4^n\\ &\color{blue}{=8^n} \end{align*}

$k=3_b$:

We obtain \begin{align*} \color{blue}{A_{3_b}} &=\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{n-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}2^{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{n-q_1-q_2}\\ &=2^n\sum_{q_1=0}^n\binom{n}{q_1}3^{n-q_1}\\ &=2^n4^n\\ &\color{blue}{=8^n} \end{align*}

$k=3_c$:

We obtain \begin{align*} \color{blue}{A_{3_c}} &=\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}2^{n-q_1}2^{n-q_1}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}8^{n-q_1}\\ &\color{blue}{=9^n} \end{align*}

$k=4_a$:

We obtain \begin{align*} \color{blue}{A_{4_a}} &=\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{n-q_1-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}2^{n-q_1}3^{n-q_1}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}6^{n-q_1}\\ &\color{blue}{=7^n} \end{align*}

$k=4_b$:

We obtain \begin{align*} \color{blue}{A_{4_b}} &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}\sum_{q_3=0}^{n-q_2} \binom{n-q_2}{q_3}2^{n-q_3}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{q_2}\sum_{q_3=0}^{n-q_2} \binom{n-q_2}{q_3}2^{n-q_2-q_3}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{q_2}3^{n-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}2^{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{q_2}3^{n-q_1-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}2^{q_1}5^{n-q_1}\\ &\color{blue}{=7^n} \end{align*}

$k=5$:

We obtain \begin{align*} \color{blue}{A_{5}} &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}\sum_{q_3=0}^{n-q_1-q_2} \binom{n-q_1-q_2}{q_3}2^{n-q_1-q_3}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{q_2}\sum_{q_3=0}^{n-q_1-q_2} \binom{n-q_1-q_2}{q_3}2^{n-q_1-q_2-q_3}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}2^{q_2}3^{n-q_1-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}5^{n-q_1}\\ &\color{blue}{=6^n} \end{align*}

$k=6$:

We obtain \begin{align*} \color{blue}{A_{6}} &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}\sum_{q_3=0}^{n-q1-q_2} \binom{n-q_1-q_2}{q_3}2^{n-q_1-q_2-q_3}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}\sum_{q_2=0}^{n-q_1}\binom{n-q_1}{q_2}3^{n-q_1-q_2}\\ &=\sum_{q_1=0}^n\binom{n}{q_1}4^{n-q_1}\\ &\color{blue}{=5^n} \end{align*}

Conclusion:

Finally we can put all together and obtain according to the inclusion-exclusion principle from the results of the last section and the values $N_k$ stated in the table above

\begin{align*} \color{blue}{S(4,n)}&=N_0A_0-N_1 A_1+(N_{2_a}A_{2_a}+N_{2_b}A_{2_b})\\ &\qquad-(N_{3_a} A_{3_a}+N_{3_b} A_{3_b}+N_{3_c} A_{3_c})\\ &\qquad+(N_{4_a} A_{4_a}+N_{4_b} A_{4_b})-N_5 A_5+N_6A_6\\ &=16^n-6\cdot 12^n+(12\cdot 10^n+3\cdot 9^n)\\ &\qquad-(4\cdot 8^n+12\cdot 8^n+4\cdot 9^n)\\ &\qquad+(12\cdot 7^n+3\cdot 7^n)-6\cdot 6^n+5^n\\ &\color{blue}{=16^n -6\cdot 12^n +12\cdot 10^n -9^n}\\ &\qquad\color{blue}{-16\cdot 8^n +15\cdot 7^n -6\cdot 6^n +5^n} \end{align*}

and the claim follows.

• @N.Shales: I've added another answer which might be of interest. – Markus Scheuer Oct 15 '17 at 21:35
• Nice! Really, interesting subject. I must take a better look on it in the morning – Djura Marinkov Oct 15 '17 at 23:04
• @N.Shales: Many thanks for your nice comment. Your approach looked so promising to me and I was baffled that you had your answer deleted. It took some effort to look somewhat behind the curtain. – Markus Scheuer Oct 16 '17 at 15:48
• @N.Shales: I suppose this is hardly possible, since otherwise a general formula would have already be known. – Markus Scheuer Oct 16 '17 at 16:12
• @N.Shales: I agree, I have the same impression. – Markus Scheuer Oct 16 '17 at 16:35

For the simplicity I will draw it for m=3 and generalize it along the way by putting it into brackets.

You have to put n elements into $2^3=8$ areas ($2^m$ areas), as on the image bellow. Each goes in one of them. Total ways to do that is $8^n$ ($2^{mn}$). By doing it you define one triplet $P_1,P_2,P_3$ [m-plet $P_1,...,P_m$]

But you have to exclude those distributions of elements when some of the lemons remain empty. Lemons are areas $P_i\bigcap P_j$, I will call them L(i,j).

Similar I will define $L(i_1,...,i_k)=P_{i_1}\cap...\cap P_{i_k}$. Number of simple areas $L(i_1,...,i_k)$ covers is $2^{m-k}$ since it may or may not intersect with m-k other subsets.

To count all the distributions of elements when some of the lemons L(i,j) remain empty can be done by inclusion-exclusion principle.

Let $C(L(i_1,j_1),...,L(i_q,j_q))$ be count of all the distributions of the elements such that each of the lemons remain empty.

We can see that $C(L(i,j))=(2^m-2^{m-2})^n$, $i<j$. From total number of simple ares we subtract lemons number of simple areas...

But for $q>1$ it gets a bit complicated. Let see for $q=2$. It may be $C(L(i,j),L(i,k))$ or $C(L(i,j),L(k,l))$ (notice that for second case m has to be greater than 3)

Number of areas that $L(i,j),L(i,k)$ cover is not same as the number $L(i,j),L(k,l)$ cover.

$C_{2,a}=C(L(i,j),L(i,k))=(2^m-2\cdot 2^{m-2}+2^{m-3})^n$

$C_{2,b}=C(L(i,j),L(k,l))=(2^m-2\cdot 2^{m-2}+2^{m-4})^n$

Lets see distributions when 3 lemons are excluded. It may be:

$C_{3,a}=C(L(i_1,i_2),L(i_1,i_3),L(i_2,i_3))=(2^m-3\cdot 2^{m-2}+3\cdot 2^{m-3}-2^{m-3})^n$

$C_{3,b}=C(L(i_1,i_2),L(i_1,i_3),L(i_1,i_4))=(2^m-3\cdot 2^{m-2}+3\cdot 2^{m-3}-2^{m-4})^n$

$C_{3,c}=C(L(i_1,i_2),L(i_1,i_3),L(i_2,i_4))=(2^m-3\cdot 2^{m-2}+2\cdot 2^{m-3}+2^{m-4}-2^{m-4})^n$

$C_{3,d}=C(L(i_1,i_2),L(i_1,i_3),L(i_4,i_5))=(2^m-3\cdot 2^{m-2}+2^{m-3}+2\cdot 2^{m-4}-2^{m-5})^n$

$C_{3,e}=C(L(i_1,i_2),L(i_3,i_4),L(i_5,i_6))=(2^m-3\cdot 2^{m-2}+3\cdot 2^{m-4}-2^{m-6})^n$

In the end it will be:

$2^{mn}-{m\choose2}C(L(i,j))+{m\choose3}{3\choose1}C_{2,a}+{m\choose4}{4\choose2}C_{2,b}-{m\choose3}C_{3,a}-{m\choose4}{4\choose1}C_{3,b}-{m\choose4}{4\choose1}{3\choose1}C_{3,c}-{m\choose5}{5\choose1}{4\choose2}C_{3,d}-{m\choose6}{6\choose2}{4\choose2}C_{3,e}+...$

Maybe now you find some law how this formulas are generated...

• Interesting work (+1), it contributes to the track traced in the other answers – G Cab Oct 8 '17 at 10:38
• It's not as fine elaborated as yours, but thanks! We are all on the same track but away from goal :). It seems really interesting problem this picking several pairs with various correlations. Someone must have elaborated on this subject already – Djura Marinkov Oct 8 '17 at 11:20

The first step to solving such a problem is to define precisely what we are trying to answer.

For all $n>0,m>0$, let us define $C(n,m)$ as the number of distinct tuples $(P_1, P_2, \cdots P_m)$ where each $P_j$ (with $1\le j\le m$) is a set of natural numbers less than or equal to $n$ (in symbols, $\forall e\in P_j\mid 1\le e\le n$) and no two sets within the same tuple are disjoint; that is, for any tuple being counted $\neg\exists(j,k)\mid\{P_j\cap P_k=\emptyset\}$.

Your question is to compute $C(n,m)$.

First let us note that $C(1,m)=1$ for all $m$.

Likewise, let us note that $C(n,1)=2^n-1$ for all $n$.

(To be continued.)