This problem is somehow related to multiplication circuits
Input: $N$ bits, integer $K$
- Output: a propositional formula that is satisfiable if and only if the sum of the bits, K shift right mode 2 equals 1
Example:
- N = {1,0,1,1}, K = 1 -> output = 1
- N = {1,1,1,1}, K = 1 -> output = 0
- N = {1,1,1,1}, K = 2 -> output = 1
If your formula can contain additional helper propositional variables, it can be reduced to a polynomial length relatively easily.
In addition to the inputs $i_1,i_2,\ldots, i_n$ we are going to use $(n+1)^2$ helper variables named $\Sigma_{f,t}$ with $f$ and $t$ ranging between $0$ and $n$ (inclusive). Our formula will be a long conjunction of four types of expressions (where $\bar{x}$ denotes negation):
The variables $\Sigma_{f,t}$ represent the statements: $\sum\limits_{k=1}^f i_k = t$ and the first three bullet-points determine their truth-values completely based on the assignment of $\{i_k\}$. The fourth point then makes the formula satisfiable if and only if the sum of all $n$ values satisfies the shift-right-by-k-modulo-2-equals-1 condition.
Of course, some of the variables are completely useless (such as those with $t>f$, since the sum of first $f$ terms cannot exceed $f$). Also, if $k$ was small enough, we could avoid computing the full sum but only get its value modulo $2^{k+1}$; instead of $0\leq t\leq n$, we would only have $0\leq t<2^{k+1}$ (which would actually make the expressions a little more uniform).