Injection from binary strings with $i$ bits to $i+1$ bits I want to find an injection $F$ from binary strings length $n$ with $i$ bits turned on to $i+1$ bits turned on, with the condition that if $F(S)=S'$, then $S'$ can be obtained from $S$ by simply turning one additional bit on.
Naturally, it is guaranteed that $i<n/2$, otherwise such an injection cannot exist because there will be more strings with $i$ bits turned on than $i+1$.
Trying some lexicographic ordering injection doesn't work because the maximal/minimal strings will always be mapped to by more than $1$ item.
 A: Assuming OP wants an actual explicit description of the injection, then Extending $k$-element subsets of an $n$-element set to $k+1$ element subsets would not be a satisfying duplicate target. I gave an explicit injection in this answer of mine, but since the question there is not a duplicate of this one, I will reproduce it here.

Let $[n]=\{1,\dots,n\}$, and let $\binom{[n]}k$ denote the set of size-$k$ subsets of $[n]$. Here is how we construct an injection $f:\binom{[n]}{k}\to \binom{[n]}{k+1}$, which satisfies $f(X)\supseteq X$, whenever $k<n/2$.
Given $X\subset [n]$ with $|X|=k$, represent $X$ as a sequence of $k$ ones and $n-k$ zeroes.

*

*Cross out any two entries which are a $1$ followed by a $0$ with only crossed out entries between. Repeat this step until no such entries remain.


*Now, the only entries which are not crossed out will consist of some number of zeroes, followed by some number of ones. (If not, we would not be done with step one).  There must exist a zero which is not crossed out, because there were initially more zeroes than ones, and we crossed out an equal number of each. Find the rightmost such zero, and change it to a one. The resulting sequence is $f(X)$.
It should be clear that $f(X)$ has size $k+1$. To prove that $f$ is injective, imagine that every time a $1$ and a $0$ are crossed out, they are "paired" together. The point is that when you change the leftmost zero to a one, and repeat the crossing-out procedure, you get the same set of pairs, because the changed bit was not in the middle of any pairs. Furthermore, no new pairs are created with the uncrossed-out entries, because we picked the rightmost zero. Therefore, to undo $f$, you do the same crossing out procedure, and instead change the leftmost remaining one into a zero.
Example: Let $n=18,k=8$, and $X=\{1,5,6,8,12,14,15\}$. The zero one vector is
$$
1,0,0,0,1,1,0,1,0,0,0,1,0,1,1
$$
Crossing out all instance of $1$ followed by zero, we get
$$
\not1,\not0,0,0,1,\not1,\not0,\not1,\not0,0,0,\not1,\not0,1,1
$$
We are not done, because crossing out these numbers has created another instance of a $1$ followed by a $0$ (with only crossed-out numbers between), so next we cross that out.
$$
\not1,\not0,0,0,\not1,\not1,\not0,\not1,\not0,\not0,0,\not1,\not0,1,1
$$
Now, among the remaining numbers, each zero occurs to the left of each one, so we are done. We conclude by replacing the rightmost zero with a one.
$$
\not1,\not0,0,0,\not1,\not1,\not0,\not1,\not0,\not0,\boxed{1},\not1,\not0,1,1
$$
Therefore, $f(X)=\{1,5,6,8,\boxed{11},12,14,15\}$
A: I posed this question as a Code Golf SE challenge and got this answer (but at the time with no proof) from user1502040, before Mike's answer was posted. This injection uses the set formulation of the problem: find an injection $f$ from $k$-subsets of $R=\{0,\dots,n-1\}$ to $k+1$-subsets of the same such that $f(S)\supset S$.
To compute $f(S)$, sum all elements of $S$, negate the result and reduce modulo $n-k$ to get a number $i$ from $0$ to $n-k-1$. The element to add to $S$ to produce $f(S)$ is the $i$th smallest element of $R-S$ with zero-based indexing ($i+1$-th smallest with one-based indexing). If this element is $a$, we shall say that $\mathsf{rank}(R - S, a) = i$.
For example, with $n=11$ and $k=5$, the image of $\{1,2,5,7,10\}$ is computed as follows:

*

*The sum of all elements is $25$, and $-25\equiv5\bmod6$.

*The missing elements are $(0,3,4,6,8,9)$. The 6th smallest, i.e. largest, element of this is $9$, so the desired image is $\{1,2,5,7,9,10\}$.

Later on this proof that $f$ is injective was added to the answer over there. Suppose $f$ is not injective, then there exists a $k-1$-subset $C$ and elements $x,y\in R-C$ with $f$ adding $y$ given the input $C\cup\{x\}$ and adding $x$ given the input $C\cup\{y\}$. Assume without loss of generality that $x<y$, then modulo $n-k$:
$$x+\sum C\equiv-\mathsf{rank}(R-(C\cup\{x\}), y)$$
$$y+\sum C\equiv-\mathsf{rank}(R-(C\cup\{y\}), x)$$
$$\implies y-x\equiv \mathsf{rank}(R-(C\cup\{x\}), y)-\mathsf{rank}(R-(C\cup\{y\}), x)$$
The right-hand side $g$ of the last congruence is also the number
of integers between $x$ and $y$ not in $C$, since $y>x$. Let $m$ be the number of integers in $C$ between $x$ and $y$, then
$$m=y-x-1-g\implies m\equiv-1\bmod n-k$$
Therefore $n-k-1\le m\le k-1$ and $k\ge n/2$, but this contradicts the initial assumption that $k<n/2$. Since we initially assumed $f$ was not injective, the truth must be that it is.
