number of binary solutions under linear restrictions

I am interested in the following counting problem:

Consider $x_1,\dots,x_n\in\{0,1\}$. How many solutions exist under the restriction that $Ax=b$, where $A$ is a $m\times n$ matrix with binary entries and $b_i\in \{0,\dots,n\}$.

Note that this counting problem might be related to the case where there is only one restriction (see for example How many solutions to $x_1 + x_2 + x_3 + x_4 + x_5 = 21$ given the following restrictions ....). However, I am unable to generalize the ideas used here for the problem described above.

If anyone has an idea how to approach this problem or is able to point me in the direction of a paper which solves something similar, I would appreciate it greatly. Thanks in advance.


Solution 1:

We have a system of $m$ equations:

$$\begin{cases} a_{11}x_1 + \ldots + a_{1n}x_n = b_1 \\ a_{21}x_1 + \ldots + a_{2n}x_n = b_2 \\ \ldots \\ a_{m1}x_1 + \ldots + a_{mn}x_n = b_m \\ \end{cases} $$

We will build a generating function with one variable $z_1, \ldots, z_m$ for each equation. Each $x_i = x_1,...,x_n$ will contribute a factor of this generating function through its coefficients $a_{1i},\ldots,a_{mi}$:

$$g(z_1,\ldots,z_m)=\prod_{i=1}^{n}{\left(1+\prod_{j=1}^{m}{z_j^{a_{ji}}}\right)}$$

Where $1$ counts for $x_i = 0$ and the other addendum for $x_i = 1$. The required number of solutions is then the coefficient of the term $z_1^{b_1} \ldots z_m^{b_m}$ in $g(z_1,\ldots,z_m)$:

$$\bbox[5px,border:1px solid black]{[z_1^{b_1} \ldots z_m^{b_m}]g(z_1,\ldots,z_m)}$$

For example, for:

$$\begin{cases} x1+x2=1 \\ x2+x3=1\\ \end{cases} $$

we have:

$$g(z_1,z_2)=(1+z_1)(1+z_1z_2)(1+z_2)=z_2^2 z_1^2 + z_2 z_1^2 + z_2^2 z_1 + 2 z_2 z_1 + z_1 + z_2 + 1$$

Where the first term is for $x_1$, the second for $x_2$ and the third for $x_3$, and the number of solutions is the coefficient of $z_1z_2$, which is $2$, i.e. $(x_1,x_2,x_3)=(0,1,0)$ and $(x_1,x_2,x_3)=(1,0,1)$.