HD = Hamming distance
For a 4-bit string = x, I want to be able to express ALL other binary bit strings in a set that is a multiple of certain HD (in this example say 2) away from x AND at least that certain HD away from each other in the set.
For say "0000", the set would be {1100,0110,0011,1001,0101,1010,1111}
The first 6 bits strings are easy: 4C2 = 6 combinations, but selecting the last bit string {1111} is tricky. If the required HD=2, then the number of elements in the set would be 4C2+4C(2+2)=7; hence multiple of the HD.
The trick is that these elements: {1110,1101,0111,1011} can not be in the above set as they are an HD=1 away from the element {1111}. One of the rules is that all the elements in the set have to be at least the stated HD away from each other. These elements {0001,1000,....} also can't be in the set as they contradict the other rule which is they are HD<2 than 0000.
Again, I want to express this set as a boolean function for n bit strings.
Let $x\in \{0,1 \}^n$ be a binary string of length $n$ and $|x|$ denote the number of nonzero entries in $x$. Take $E= \{ \vec{v}\in \{ 0,1\}^n : |\vec{v}| \equiv 0 \mod 2 \}$ and $E^*=E \setminus \{\vec{0}\}$. We want to construct a function $f: \{0,1\}^n\to \{0,1\} $ such that $f(E^*)=1$ and $f(\{0,1\}^n \setminus E^*)=0$. The following function should do the trick:
$$f(\vec{x})= \bigg(1+\sum_{i=1}^n x_i \bigg) \bigg(1+\prod_{i=1}^n(x_i+1)\bigg)$$
Where addition and multiplication are performed mod $2$.
The first part of acts as indicator of parity of $|x|$.
$$1+\sum_{i=1}^n x_i = \cases{0 \mbox{ when $|x|$ is odd} \\1 \mbox{ when $|x|$ is even}}$$
And the second part acts an indicator of whether $x=\vec{0}$
$$1+\prod_{i=1}^n(x_i+1)=\cases{0 \mbox{ when } x = \vec{0} \\1 \mbox{ when } x\ne \vec{0}}$$