k-XORSAT is the problem of deciding whether a Boolean formula $$\bigwedge\_{i \in I} \oplus\_{j=1}^k l\_{s\_{ij}}$$ is satisfiable. Here $\oplus$ denotes the binary [XOR](http://en.wikipedia.org/wiki/Xor) operation, $I$ is some index set, and each clause has $k$ distinct literals $l\_{s\_{ij}}$ each of which is either a variable $x\_{s\_{ij}}$ or its negation.


Equivalently, $k$-XORSAT requires deciding whether a set of linear equations, each of the form $\sum\_{j=1}^k x\_{s\_{ij}}\equiv 1\; (\mod 2)$, has a solution over $\mathbb{Z}\_2 = \mathbb{Z}/2\mathbb{Z}$.


Every decision problem Q has an associated counting problem #Q, which (informally speaking) requires establishing the number of distinct solutions. Such counting problems form the complexity class [#P](http://qwiki.stanford.edu/wiki/Complexity_Zoo%3ASymbols#sharpp). The "hardest" problems in #P are #P-complete, as any problem in #P can be reduced to a #P-complete problem.


The counting problem associated with any NP-complete decision problem is #P-complete. However, many "easy" decision problems (some even solvable in linear time) also lead to #P-complete counting problems. For instance, Leslie Valiant's original 1979 paper [*The Complexity of Computing the Permanent*](http://dx.doi.org/10.1016/0304-3975%2879%2990044-6) shows that computing the permanent of a 0-1 matrix is #P-complete. As a second example, the list of #P-complete problems in the companion paper [*The Complexity of Enumeration and Reliability Problems*](http://dx.doi.org/10.1137/0208032) includes #MONOTONE 2-SAT; this problem requires counting the number of solutions to Boolean formulas in conjunctive normal form, where each clause has two variables and no negated variables are allowed. (MONOTONE 2-SAT is of course rather trivial as a decision problem.)


Andrea Montanari has written about the partition function of $k$-XORSAT in some [lecture notes](http://www.stanford.edu/~montanar/TEACHING/Stat316/handouts/lecture-4.pdf), and his book with Marc Mézard apparently discusses this (unfortunately I do not have a copy available to hand, and the relevant Chapter 17 is not included in Montanari's online draft).


These considerations lead to the following question:



> 
> Is #$k$-XORSAT #P-complete?
> 
> 
> 


Note that the formula in Montanari's notes does not obviously appear to answer this question. Just because there is a nice closed form solution, doesn't mean we can evaluate it efficiently: consider the [Tutte polynomial](http://en.wikipedia.org/wiki/Tutte_polynomial).


Some difficult counting problems in #P can still be approximated in a certain sense, by means of a scheme called an FPRAS. Jerrum, Sinclair, and collaborators have linked the existence of an FPRAS for #P problems to the question of whether $NP = RP$. I would therefore also be interested in the subsidiary question



> 
> Does #$k$-XORSAT have an FPRAS?
> 
> 
> 


*Edit: clarified second question as per comment by Tsuyoshi Ito. Note that Peter Shor's answer renders this part of the question moot.*



Is #k-XORSAT #P-complete?
The solutions for XOR-SAT form an affine subspace of the vector space GF(2)$^n$. You can see this by realizing that if you add three solutions together, you get another solution. The counting problem for XOR-SAT is then that of deciding how many points are in this affine space over GF(2). This is trivial if you know the rank of a generating matrix for this space (the number is $2^r$ for rank $r$). This rank can be figured out by a standard linear algebra algorithm, so the counting problem is in polynomial time.


