We constantly make use of Kummer's theorem which, in particular, implies that (kn) is odd if and only if k and n−k have ones in different positions in binary. In other words, if S(x) is the set of positions of the digits 1 of x in binary (in which the digit multiplied by 2i is in position i), (kn) is odd if and only if S(k)⊆S(n). Moreover, if we set k<n,S(k) is a proper subset of S(n), that is, ∣S(k)∣<∣S(n)∣.
We start with a lemma that guides us how the permutation should be set.
Lemma 1.
i=0∑t−1∣S(t+i)∣=t+i=0∑t−1∣S(2i)∣.
The proof is just realizing that S(2i)={1+x,x∈S(i)} and S(2i+1)={0}∪{1+x,x∈S(i)}, because 2i in binary is i followed by a zero and 2i+1 in binary is i followed by a one. Therefore
i=0∑t−1∣S(t+i)∣=i=0∑2t−1∣S(i)∣−i=0∑t−1∣S(i)∣=i=0∑t−1∣S(2i)∣+i=0∑t−1∣S(2i+1)∣−i=0∑t−1∣S(i)∣=i=0∑t−1∣S(i)∣+i=0∑t−1(1+∣S(i)∣)−i=0∑t−1∣S(i)∣=t+i=0∑t−1∣S(i)∣=t+i=0∑t−1∣S(2i)∣.
The lemma has an immediate corollary: since t+i>2ai and (2ait+i) is odd for all i,0≤i≤t−1, S(2ai)⊂S(t+i) with ∣S(2ai)∣≤∣S(t+i)∣−1. Since the sum of ∣S(2ai)∣ is t less than the sum of ∣S(t+i)∣, and there are t values of i, equality must occur, that is, ∣S(2ai)∣=∣S(t+i)∣−1, which in conjunction with S(2ai)⊂S(t+i) means that t+i−2ai=2ki for every i,0≤i≤t−1, ki∈S(t+i) (more precisely, {ki}=S(t+i)\S(2ai).)
In particular, for t+i odd, this means that t+i−2ai=1, because the only odd power of 2 is 1. Then ai=2t+i−1 for t+i odd, which takes up all the numbers greater than or equal to 2t−1. Now we need to distribute the numbers that are smaller than 2t−1 (call these numbers small). If t+i is even then by Lucas' Theorem (2ait+i)≡(ait+i)(mod2), so we pair numbers from ⌈t/2⌉ to t−1 (call these numbers big) with the small numbers.
Say that a set A is paired with another set B whenever ∣A∣=∣B∣ and there exists a bijection π:A→B such that S(a)⊂S(π(a)) and ∣S(a)∣=∣S(π(a))∣−1; we also say that a and π(a) are paired. We prove by induction in t that At={0,1,2,…,⌊t/2⌋−1} (the set of small numbers) and Bt={⌈t/2⌉,…,t−2,t−1} (the set of big numbers) can be uniquely paired.
The claim is immediate for t=1 and t=2. For t>2, there is exactly one power of two in Bt, since t/2≤2a<t⟺a=⌈log2(t/2)⌉. Let 2a be this power of two. Then, since 2a≥t/2, no number in At has a one in position a in binary. Since for every number x,2a≤x<t,a∈S(x) and a∈/S(y) for all y∈At,x can only be paired with x−2a, since S(x) needs to be stripped of exactly one position. This takes cares of x∈Bt,2a≤x<t, and y∈At,0≤y<t−2a.
Now we need to pair the numbers from A′={t−2a,t−2a+1,…,⌊t/2⌋−1}⊂A with the numbers from B′={⌈t/2⌉,⌈t/2⌉+1,…,2a−1}⊂B. In order to pair these t−2(t−2a)=2a+1−t<t numbers, we use the induction hypothesis and a bijection between A′∪B′ and B2a+1−t∪A2a+1−t. Let S=S(2a−1)={0,1,2,…,a−1}. Then take a pair x,y,x∈A2a+1−t and y∈B2a+1−t and biject it with 2a−1−x∈B′ and 2a−1−y∈A′. In fact,
0≤x≤⌊22a+1−t⌋−1=2a−⌈2t⌉−1⟺⌈2t⌉≤2a−1−x≤2a−1
and
⌈22a+1−t⌉=2a−⌊2t⌋≤y≤2a+1−t−1⟺t−2a≤2a−1−y≤⌊2t⌋−1.
Moreover, S(2a−1−x)=S\S(x) and S(2a−1−y)=S\S(y) are complements with respect to S, and S(x)⊂S(y) and ∣S(x)∣=∣S(y)∣−1 implies S(2a−1−y)⊂S(2a−1−x) and ∣S(2a−1−y)∣=∣S(2a−1−x)∣−1. Therefore a pairing between A′ and B′ corresponds to a pairing between A2a+1−t and B2a+1−t. Since the latter pairing is unique, the former pairing is also unique, and the result follows.
We illustrate the bijection by showing the case t=23 :
A23={0,1,2,…,10},B23={12,13,14,…,22}.
The pairing is
(1281391410157160171182193204215226),
in which the bijection is between
(1281391410157) and (37261508)→(51627380).