Is there an explicit construction of this bijection?

Solution 1:

Yes, there is! In fact, here's $(n-1)!$ of them!

I wish to thank user Phylliida for both the algorithm and the python psudocode below. The proof is my own (though I've found it hard to write in some standard notation...).

The idea is based on the $k=1$ case. For a set $A = \{a_1, \cdots, a_k \}$ we increase $a_1$ (modulo n) until it's no longer in $A,$ and put that element in $f(A).$ Now we take $a_2$ and increment it until it is no longer in $A$ or an element we've already put in $f(A),$ and declare that to be in $f(A).$ We carry on like this for all the $a_i,$ so that our output has the correct size.

For example, with the set $\{1,3,4,5,9\}$ mod $11,$ we would first increment $1$ up to $2$ and put this into our output, then we move $3$ to $6,$ passing over $4$ and $5$ because they are in the input set. We similarly move $4,5$ and $9$ to $7,8$ and $10$ respectively. Our output is thus $\{2,6,7,8, 10\}.$

It is clear that this will always give us a disjoint set from the input of the right size. However, it is not at all clear that this is well defined (does the order of the $a_i$ matter?) or that it is invertible. It turns out this algorithm is essentially its own inverse, so that if we phrase it with a bit of generality it will suffice to show it's well defined.


So, with more generality now. Fix an $n$-cycle $\pi,$ and a set $A$ as above. Define the multiset $A_1 = A \cup \pi A$ of size $2k.$ We then construct $A_2$ by applying $\pi$ to all but one of each duplicate element in $A_1.$ In general we have $$A_{i+1} = set(A_i) \cup \pi (A_i - set(A_i)) $$

where $set(U)$ denotes the set of elements in a multiset $U,$ multiset difference removes instances (ie, $(1,2,2) - (1,2) = (2)$), and the union is treated as a union of multisets. Note that $A_{i+1} = A_i$ when $A_i$ is a set, that we always have exactly $2k$ elements in $A_{i+1},$ and finally that after $k$ steps we must have an actual set instead of a multiset. So we define $$f_\pi(A) = A_k - A.$$

This is equivalent to the algorithm outlined above when $\pi = (1, \cdots, n).$ We're just incrementing each element (mod n) until they find an unused place. If two elements find the same place, then we leave one of them in the gap and continue incrementing the other.

Now, I claim the inverse to $f_{\pi}$ is $f_{\pi^{-1}}.$ This follows almost immediately if we return to our original presentation of the algorithm: Suppose $a_k$ is incremented to $\pi^j a_k.$ Then we must have $\pi^1 a_k, \pi^2 a_k, \cdots, \pi^{j-1} a_k \in f_\pi(A),$ which implies that $f_{\pi^{-1}}$ will return $\pi^j a_k$ to the first open spot, namely $a_k.$ After performing this move, we're in exactly the same state as $f_\pi$ would be before moving $a_k.$ $f_{\pi^{-1}}$ continues exactly undoing $f_\pi$ if we next consider wherever $a_{i}$ ended up in descending order.

As an example of the inverse direction, if we start with ${2, 6, 7, 8, 10}$ then we would first decrement $10$ to the first open place ($9$), then $8$ would be decreased past $7$ and $6$ down to $5.$ Similarly $6,7$ are moved to $3,4.$ Finally $2$ gets decreased down to $1.$ Note we've moved each number back to where it came from in the original setup.


I conclude with some python code for the bijection.

def rot(bits,inv):
 res = [x for x in bits]
 original = [x for x in bits]
 n = len(bits)
 for i in range(n)[::inv]:
  if original[i] == 1:
   for j in range(1,n+1)[::inv]:
    new = (i + j) % n
    if res[new] == 0 and original[new] == 0:
     res[new] = 1
     res[i] = 0
     break
 return res

res should be an array with a $1$ in the ith place if $i \in A.$ inv should be set to 1 to do the forward direction, -1 to invert. For example

rot([1,0,1,1,1,0,0,0,1,0,0], 1) = [0,1,0,0,0,1,1,1,0,1,0]

Solution 2:

On thinking about this some more, I think at least one construction can be obtained by adapting a construction of Greene and Kleitman giving a symmetric chain decomposition of the poset $2^S$, where $S = \{1, \ldots, n\}$. I'll give a description of the construction here, but I'd still be interested in whether there's a simpler construction I'm missing.

Given a set $t \in 2^S$, or, in particular, $t \in {S \choose k}$, we associate $t$ with an $n$-character string, where the $i$th character is a left-parenthesis if $i \notin t$ or a right-parenthesis if $i \in t$. For example, if $n=5$, we would associate the set $\{3,5\}$ with the string $\texttt{(()()}$. When $t \in {S \choose k}$, the resulting string clearly has exactly $k$ right-parentheses.

Now, some of these parentheses can be "paired up" following the usual rules, and some cannot. For example, in the string for $\{3,5\}$, the leftmost parenthesis cannot be paired with anything, but the remaining $4$ characters form two sets of matched parentheses: $\texttt{(} \color{red}{\texttt{()}} \color{blue}{\texttt{()}}$. Similarly, the string for $\{3,4\}$ can be matched as $\color{red}{\texttt{(}}\color{blue}{\texttt{()}}\color{red}{\texttt{)}}\texttt{(}$.

Now, the Greene--Kleitman construction gives a way to produce a chain of sets in $2^S$ -- that is, a nested family $t_1 \subset t_2 \subset \cdots \subset t_k$ -- that contains the given set, such that $|t_1| + |t_k| = n$. We produce $t_1$ just by taking all unmatched right-parentheses and flipping them to left-parentheses and, given $t_i$, we produce $t_{i+1}$ by flipping the leftmost unmatched left-parenthesis to a right-parenthesis. To use the example given by Greene--Kleitman, if $A = \{1,3,4,8,9\}$ in the set $S = \{1, \ldots, 10\}$, then the corresponding string is $\texttt{)}\color{red}{\texttt{()}}\texttt{)(}\color{blue}{\texttt{(}}\color{orange}{\texttt{()}}\color{blue}{\texttt{)}}\texttt{(}$, so the chain starts at the set corresponding to $\texttt{(}\color{red}{\texttt{()}}\texttt{((}\color{blue}{\texttt{(}}\color{orange}{\texttt{()}}\color{blue}{\texttt{)}}\texttt{(}$, namely $\{3,8,9\}$, and then, flipping one unmatched parenthesis after another, proceeds along to $\{1,3,8,9\}$, $\{1,3,4,8,9\}$, $\{1,3,4,5,8,9\}$, ending at $\{1,3,4,5,8,9,10\}$ corresponding to the string$\texttt{)}\color{red}{\texttt{()}}\texttt{))}\color{blue}{\texttt{(}}\color{orange}{\texttt{()}}\color{blue}{\texttt{)}}\texttt{)}$.

What does this have to do with the stated problem? Given that $t$ is in the chain and $t$ has size $k$, there is also a size-$(n-k)$ set $t'$ in the same chain, with $t \subset t'$. This means that $S - t'$ is a size-$k$ set disjoint from $t$. Furthermore, $t$ is the only size-$k$ set in the chain and $t'$ the only size-$(n-k)$ set, so there's no danger that two distinct sets $t_1, t_2$ can have the same $t'$.

So we can build the desired bijection by starting from the parenthesis-representation of $t$, flipping parentheses until there are exactly $n-k$ right-parentheses, and then taking $f(t)$ to be the set of indices of the left-parentheses in the resulting string (taking left-parentheses instead of right-parentheses models taking the complement of the set $t'$). This is a pretty explicit construction, but a part of me wonders if it is overkill for the somewhat smaller task we've set for ourselves.


I believe it can be shown that, as Artimis Fowl and I speculated in the comments, this construction is equivalent to Artimis Fowl and Phylliida's (henceforth AFP) elegant construction applied to the permutation $\sigma^{-1}$, where $\sigma = (1, \cdots, n)$. That is, it's equivalent to defining $f(t)$ by processing each $a_i \in t$ one at a time, decrementing $a_i$ modulo $n$ until it reaches a value that is not equal to any other $a_j$ or any value previously declared to be in $f(t)$, and declaring that value to be in $f(t)$.

Here's a rough sketch of a proof of that. Let's take it as given that the result of AFP's operation does not depend on the order in which the $a_i$ are processed. Now, given a set $t$, we form its parenthesis-representation. We will apply AFP's function $f$ to $t$ and show that it produces the same result as the Greene--Kleitman construction.

To compute $f(t)$, we start by processing the values $a_i \in t$ that correspond to paired right-parentheses, always choosing an innermost paired parenthesis among the unprocessed ones to process next. By always choosing an innermost parenthesis, we can see that on applying $f$, each paired right-parenthesis will be left-shifted until it reaches the matching left-parenthesis. (Skipping over already-occupied slots means we would skip over the already-matched left-parentheses for any pairs contained within the parentheses being processed.)

Next, consider the unpaired right-parentheses in $t$. All such parentheses must occur to the left of all unpaired right-parentheses in the representation. Thus, on applying $f$, each unpaired right-parenthesis will be shifted left until it "wraps around" to the end of the string, and sent to the position of a rightmost not-yet-occupied unmatched left-parenthesis.

So, in summary, applying $f$ sends each matched right-parenthesis to its matching left-parenthesis, and sends each unmatched right-parenthesis to an unmatched left-parenthesis as close to the end of the string as possible. So $f(t)$ consists of the indices of the matched left parentheses for $t$, as well as a a "rightward-closed" set of unmatched left-parentheses. (That is, if the set has an unmatched left-parenthesis at position $i$, then all unmatched left-parentheses at positions $j > i$ must also be in the set.) This means that the complement of $f(t)$ is a set consisting of all the matched right-parentheses for $t$ as well as a "leftward-closed" set of unmatched right-parentheses.

This means that the complement of $f(t)$ is in the same Greene--Kleitman chain as $t$, so that $f(t) = t'$ where $t \subset t'$ and $|t'| = n-k$. That is, $f(t)$ as defined by AFP, using the permutation $\sigma^{-1}$, is the same function as $f(t)$ as defined in this answer using Greene--Kleitman.