3

I do have $n\times m$ objects $o_{ij}$. I'm looking for the number of possible groupings these objects. A valid grouping must not have any two object of the same row in one group. For example in the case $3\times 2$, a valid grouping is $\{\{o_{11}, o_{22}, o_{31}\}, \{o_{12}, o_{32}\}, \{o_{21}\}\}$. An invalid grouping is $\{\{o_{11}, o_{12}, o_{31}\}, \{o_{22}, o_{32}\}, \{o_{21}\}\}$, since $o_{11}$ and $o_{12}$ must not be in the same group. What is the number of valid groupings of $n\times m$ such objects?

Michael
  • 155
  • This appears to be a "non-flat" partition. See this answer https://mathematica.stackexchange.com/questions/200646/non-flat-partitions-of-a-set/200650, and also Chapter 4 of G. Peccati and M. Taqqu. Wiener Chaos: Moments, Cumulants and Diagrams: A survey with Computer Implementation. Bocconi & Springer Series. Springer, 2011. – apg Aug 30 '19 at 12:54

2 Answers2

2

This is a case of Power Group Enumeration with the group acting on the slots being the trivial group containing the identity permutation on $n\times m$ elements and the symmetric group acting on the values going into the slots being the symmetric group $S_q.$ Here a slot receives as its value the number of the set it goes into and the set identifiers are being permuted by the symmetric group and we obtain set partitions into at most $q$ sets.

We evidently require a classification of the permutations in $S_q$ by the number of fixed points. We do the case $m=1$ first and should get Bell numbers. Observe that the combinatorial class of permutations with fixed points marked is

$$\def\textsc#1{\dosc#1\csod} \def\dosc#1#2\csod{{\rm #1{\small #2}}} \textsc{SET}(\mathcal{U}\times\textsc{CYC}_{=1}(\mathcal{Z}) + \textsc{CYC}_{=2}(\mathcal{Z}) + \textsc{CYC}_{=3}(\mathcal{Z}) + \textsc{CYC}_{=4}(\mathcal{Z}) + \cdots).$$

This gives the generating function $$G(z, u) = \exp\left(uz + \frac{z^2}{2} + \frac{z^3}{3} + \frac{z^4}{4} + \frac{z^5}{5} + \cdots\right)$$

which is $$G(z, u) = \exp\left((u-1)z + \log\frac{1}{1-z}\right) \\ = \frac{\exp((u-1)z)}{1-z} = \exp(uz) \frac{\exp(-z)}{1-z}.$$

Therefore the number of permutations in $S_q$ having $p$ fixed points is given by

$$q! [z^q] \frac{z^p}{p!} \frac{\exp(-z)}{1-z} = \frac{q!}{p!} [z^{q-p}] \frac{\exp(-z)}{1-z} = \frac{q!}{p!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}.$$

Write it like this

$${q\choose p} (q-p)! \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}$$

to see immediately that we choose the $p$ fixed points from the $q$ possibilities and combine them with a derangement of the rest.

Now in the Power Group Construction we place copies of cycles from the group permuting the values on the cycles of the group permuting the slots, consisting of fixed points only in the present example. If a permutation from $S_q$ contains $p$ fixed points we get a contribution of $p^{n\times m}$ which is $p^n.$ This yields (the term for $p=0$ produces a zero value and may be omitted; the $q!$ was canceled by the average from the cycle index $Z(S_q)$)

$$\sum_{p=1}^q \frac{p^n}{p!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}.$$

Continuing with the sanity check we should get Bell numbers when we put $n=q$ (partition of $[q]$ into at most $q$ sets). We get

$$\sum_{p=1}^q \frac{p^q}{p!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}$$

which yields

$$1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975, 678570, \\ 4213597, 27644437, 190899322, \ldots$$

which is indeed OEIS A000110, the sequence of Bell numbers.

Continuing with PGE we now treat the general case where the $m$ values in the $n$ rows may not occur together for a contribution of (we choose a set of unique fixed points -- no duplicates -- from the $p$ available ones and place them on the cycles, also fixed points, of the single slot permutation corresponding to that row, the $n\times m$ slots having been divided into $n$ blocks of size $m$):

$$\bbox[5px,border:2px solid #00A000]{ m!^n \sum_{p=1}^{n\times m} {p\choose m}^n \frac{1}{p!} \sum_{k=0}^{n\times m-p} \frac{(-1)^k}{k!}.}$$

We get e.g. for $m=2$ the sequence

$$1, 7, 87, 1657, 43833, 1515903, 65766991, \\ 3473600465, 218310229201, 16035686850327, \ldots$$

which is OEIS A020556 and for $m=3$ we obtain

$$1, 34, 2971, 513559, 149670844, 66653198353, 42429389528215, \\ 36788942253042556, 41888564490333642283, 60862147523250910055785, \ldots$$

which is OEIS A069223 and has highly relevant data.

Remark. We use the follwing method for the proof that we get Bell numbers when $m=1$: starting from

$$\sum_{k=0}^n {n\brace k} x^{\underline{k}} = x^n$$

we find

$$\sum_{p=1}^q \frac{p^q}{p!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!} = \sum_{p=1}^q \frac{1}{p!} \sum_{r=0}^q {q\brace r} {p\choose r} r! \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}.$$

This becomes

$$\sum_{r=0}^q {q\brace r} \sum_{p=r}^q \frac{1}{(p-r)!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!}.$$

We have it if we can show the coefficient on ${q\brace r}$ is one. We get

$$\sum_{p=r}^q \frac{1}{(p-r)!} \sum_{k=0}^{q-p} \frac{(-1)^k}{k!} = \sum_{p=0}^{q-r} \frac{1}{p!} \sum_{k=0}^{q-p-r} \frac{(-1)^k}{k!} = \sum_{p=0}^l \frac{1}{p!} \sum_{k=0}^{l-p} \frac{(-1)^k}{k!}$$

with $l$ a positive number. Continuing

$$\sum_{p=0}^l \frac{1}{p!} [z^{l-p}] \frac{\exp(-z)}{1-z} = \sum_{p=0}^l \frac{1}{p!} [z^l] z^p \frac{\exp(-z)}{1-z} = [z^l] \sum_{p=0}^l \frac{1}{p!} z^p \frac{\exp(-z)}{1-z}$$

As we are extracting the coefficient on $[z^l]$ we may extend the sum to infinity without any additional contributions and get

$$[z^l] \sum_{p\ge 0} \frac{1}{p!} z^p \frac{\exp(-z)}{1-z} = [z^l] \frac{\exp(-z)}{1-z} \exp(z) = [z^l] \frac{1}{1-z} = 1$$

as claimed.

The following Maple code was used to investigate these numbers (somewhat optimized).

X :=
proc(n, m)

    (m!)^n*add(binomial(p,m)^n
               *1/p!*add((-1)^k/k!, k=0..n*m-p),
               p=1..n*m);
end;

ENUM :=
proc(n, m)
    option remember;
    local src, recurse, res; 

    src :=
    [seq(seq([A[p], B[q]], q=1..m), p=1..n)];

    res := 0;

    recurse :=
    proc(pos, spart, len)
        local idx, nxt, var;

        if pos > n*m then
            res := res + 1;
            return;
        fi;

        nxt := src[pos]; var := op(1, nxt) * op(2, nxt);

        for idx to len do
            if degree(spart[idx], op(1, nxt)) = 0 
            then
                spart[idx] := spart[idx] * var;

                recurse(pos + 1, spart, len);

                spart[idx] := spart[idx] / var;
            fi;
        od;

        spart[len + 1] := var;
        recurse(pos + 1, spart, len + 1);
        spart[len + 1] := 1;
    end;

    recurse(1, Array([seq(1, q=1..n*m)]), 0);

    res;
end;

CHECK :=
proc()
    {seq(ENUM(n, 1) - X(n, 1), n=1..10),
     seq(ENUM(n, 2) - X(n, 2), n=1..6),
     seq(ENUM(n, 3) - X(n, 3), n=1..4),
     seq(ENUM(n, 4) - X(n, 4), n=1..3),
     seq(ENUM(n, 5) - X(n, 5), n=1..2)};
end;

PGE recently appeared at this MSE link I and this MSE link II.

Addendum. Here is the code with some superfluous variables optimized out.

ENUM :=
proc(n, m)
    option remember;
    local src, recurse, res; 

    src :=
    [seq(seq(A[p], q=1..m), p=1..n)];

    res := 0;

    recurse :=
    proc(pos, spart, len)
        local idx, nxt;

        if pos > n*m then
            res := res + 1;
            return;
        fi;

        nxt := src[pos];

        for idx to len do
            if degree(spart[idx], nxt) = 0 
            then
                spart[idx] := spart[idx] * nxt;
                recurse(pos + 1, spart, len);
                spart[idx] := spart[idx] / nxt;
            fi;
        od;

        spart[len + 1] := nxt;
        recurse(pos + 1, spart, len + 1);
        spart[len + 1] := 1;
    end;

    recurse(1, Array([seq(1, q=1..n*m)]), 0);

    res;
end;
Marko Riedel
  • 61,317
  • This will take some time to digest, but this is an excellent answer. – Michael Mar 01 '17 at 10:15
  • Could you potentially explain further the opening paragraph? E.g. what are the slots. You mean you have the set and groups, and there is a set of functions between them? – apg Aug 31 '19 at 13:24
  • 1
    In PGE we have two groups, one of them acting on a sequence of slots permuting the slots and another acting on the objects that are distributed into these slots. We seek the count of the orbits. In the present case the $n\times m$ slots are not being permuted at all so the group contains the identity only. The objects going into the slots are the $n\times m$ identifiers of the possible sets, which have the symmetric group acting on them with cycle index $Z(S_{n\times m}).$ – Marko Riedel Aug 31 '19 at 23:25
  • 1
    (...) We then cover the $n$ rows with fixed points in the terms of $Z(S_{n\times m})$, choosing for a permutation with $p$ fixed points $m$ unique values per row because these may not be in the same set. – Marko Riedel Aug 31 '19 at 23:25
0

You can use a graph coloring technique. For the $i^{\text{th}}$ row of $o_{ij}$, form a $j$-clique. So for $m=2$, form a collection of $n$ 2-cliques, and call the collection $g$. For $m=2$, this is a ladder rung graph $nP_2$.

Now, with $G$ the number of different groups you wish to use, color the vertices of the disjoint set of cliques with the numbers ${1,2,\dots,G}$, without coloring adjacent vertices the same color.

For $n=2,3,\dots$, the following chromatic polynomial $\chi_g(k,n)$ gives the number of distinct colorings of $nP_2$ with $k$ or fewer colors. The second parameter simply defines the order of the ladder rung graph. These polynomials are:

$$\chi_g(k,2)=k^2-k$$ $$\chi_g(k,3)=k^4-2 k^3+k^2$$ $$\chi_g(k,4)=k^6-3 k^5+3 k^4-k^3$$ $$\chi_g(k,5)=k^4 - 4 k^5 + 6 k^6 - 4 k^7 + k^8$$

and so on for $n>5$. You want to count the number of distinct groupings (topological enumeration), and so, to quote this answer:

Let $S \subseteq \{1,2,3,4\}=S_0$, and let $P_S$ be the number of proper colorings of $G$ that use either $S$ or a subset of $S$. Let $P'_S$ be the number of proper colorings of $S$ that use all of $S$ ie., every color of $S$ is used in the coloring.

Then by Inclusion-Exclusion:

$$P'_{S_0} = P_{S_0} -\sum_{S: |S|=3} P_S + \sum_{S: |S|=2} P_S - \sum_{S: |S|=1} P_S$$

or to use the notation in the statement of the problem, where $P'(G,k)$ is the number of colourings of $G$ that use all $k$ colors:

$$P'(G,4) = P(G,4)-4P(G,3)+6P(G,2)-4P(G,1)$$

Using Mathematica, one can verify this, comparing with the result given by Power Group enumeration (in Marko Riedel's answer). With a ladder rung graph $nP_2$ denoted G[n] (refering to the case $m=2$), and the chromatic polynomial defined as follows:

G[n_] := Graph[Range[n], Table[i <-> i + 1, {i, 1, n, 2}]];
h[k_, n_] := ChromaticPolynomial[G[n], k];

then we have the number of distinct groupings with 4, 3 and 2 groups, given by

1/4! (h[4, 4] - 4 h[3, 4] + 6 h[2, 4] - 4 h[1, 4])
1/3! (h[3, 4] - 3 h[2, 4] + 3 h[1, 4])
1/2! (h[2, 4] - 2 h[1, 4])

which gives

1

4

2

which sum to 7. The next term is

1/6! (h[6, 6] - 6 h[5, 6] + 15 h[4, 6] - 20 h[3, 6] + 15 h[2, 6] - 6 h[1, 6])
1/5! (h[5, 6] - 5 h[4, 6] + 10 h[3, 6] - 10 h[2, 6] + 5 h[1, 6])
1/4! (h[4, 6] - 4 h[3, 6] + 6 h[2, 6] - 4 h[1, 6])
1/3! (h[3, 6] - 3 h[2, 6] + 3 h[1, 6])
1/2! (h[2, 6] - 2 h[1, 6])

1

12

38

32

4

whose sum is 87, which gives the next term in the list.

Also, the next term

1/8! (h[8, 8] - 8 h[7, 8] + 28 h[6, 8] - 56 h[5, 8] + 70 h[4, 8] - 
   56 h[3, 8] + 28 h[2, 8] - 8 h[1, 8])

1/7! (h[7, 8] - 7 h[6, 8] + 21 h[5, 8] - 35 h[4, 8] + 35 h[3, 8] - 
   21 h[2, 8] + 7 h[1, 8])

1/6! (h[6, 8] - 6 h[5, 8] + 15 h[4, 8] - 20 h[3, 8] + 15 h[2, 8] - 
   6 h[1, 8])

1/5! (h[5, 8] - 5 h[4, 8] + 10 h[3, 8] - 10 h[2, 8] + 5 h[1, 8])

1/4! (h[4, 8] - 4 h[3, 8] + 6 h[2, 8] - 4 h[1, 8])

1/3! (h[3, 8] - 3 h[2, 8] + 3 h[1, 8])

1/2! (h[2, 8] - 2 h[1, 8])

1

24

188

576

652

208

8

whose sum is 1657.

The whole sequence is meant to be $$1,7,87,1657,43833,1515903,65766991,3473600465,218310229201,\dots$$

which is given in the OEIS here.

Similarly, this works for $m>2$. For example, $m=3$ gives

$$ 1, 34, 2971, 513559, 149670844, 66653198353, 42429389528215 \dots$$

which is given here.

apg
  • 2,797