On the complexity of solving linear congruences and computing nullspaces modulo a constant

We consider the problems of determining the feasibility of a linear congruence, producing a solution to a linear congruence, and finding a spanning set for the nullspace of an integer matrix, where each problem is considered modulo an arbitrary constant k>1. These problems are known to be complete for the logspace modular counting classes {Mod_k L} = {coMod_k L} in special case that k is prime (Buntrock et al, 1992). By considering variants of standard logspace function classes --- related to #L and functions computable by UL machines, but which only characterize the number of accepting paths modulo k --- we show that these problems of linear algebra are also complete for {coMod_k L} for any constant k>1. Our results are obtained by defining a class of functions FUL_k which are low for {Mod_k L} and {coMod_k L} for k>1, using ideas similar to those used in the case of k prime in (Buntrock et al, 1992) to show closure of Mod_k L under NC^1 reductions (including {Mod_k L} oracle reductions). In addition to the results above, we briefly consider the relationship of the class FUL_k for arbitrary moduli k to the class {F.coMod_k L} of functions whose output symbols are verifiable by {coMod_k L} algorithms; and consider what consequences such a comparison may have for oracle closure results of the form {Mod_k L}^{Mod_k L} = {Mod_k L} for composite k.


Introduction
Solving a system of linear equations, or determining that it has none, is the definitive elementary problem of linear algebra over any ring. This problem is the practical motivator of the notions of matrix products, inverses, and determinants, among other concepts; and relates to other computational problems of abelian groups, such as testing membership in a subgroup [1]. Characterizing the complexity of this problem for common number systems, such as the integers, finite fields, or the integers modulo k is therefore naturally of interest.
We are interested in the difficulty of deciding feasibility of linear congruences modulo k (or LCON k ) and computing solutions to linear congruences modulo k (or LCONX k ) for an arbitrary constant k 2. This is a special case of the problem LCON defined by McKenzie and Cook [1], in which k is taken as part of the input, but represented by its prime-power factors p e1 1 p e2 2 · · · p e ; where e j ∈ O(log n) for each j (one says that each factor p ej j is tiny). Setting k to a constant is a natural, if slightly restrictive, special case.
Arvind and Vijayaraghavan [2] recently defined ModL (a logspace analogue the class ModP defined by Köbler and Toda [3]), which is contained in NC 2 . They show that LCON is hard for ModL under P-uniform NC 1 reductions, and contained in L ModL /poly = L #L /poly. This is of course in contrast to the problem of determining integer-feasibility of integer matrix equations, which is at least as hard as computing greatest common divisors over Z; the latter problem is not known to be in NC j for any j 0. Furthermore, Buntrock et al. [4] show -for the special case of k prime -that determining the feasibility of systems of linear equations is complete for coMod k L; where these are the complementary classes to the better known classes Mod k L which generalize ⊕L, corresponding to logspace nondeterministic Turing machines which can distinguish between having a number of accepting paths which are either zero or nonzero modulo k.
The above results suggest that the difficulty of solving linear equations over integer matrices is strongly governed by the presence and the prime-power factorization of the modulus involved, and indicates that LCON k may be particularly tractable. Also implicit in Ref. [4] is that LCON k is coMod k L-hard for all k 2. This suggests the question: for an arbitrary modulus k, what is the precise relationship of the problem LCON k of deciding the feasibility of linear congruences modulo k, to the classes coMod k L?
We show how the analysis of McKenzie and Cook [1] for the problem LCON may be adapted to exhibit a coMod k L algorithm for LCON k . Using techniques similar to those used by Hertrampf, Reif, and Vollmer [5] to show closure of the class Mod p L under oracle reductions for p prime, we describe a function class FUL p which is well-suited for describing oracles which may be simulated in mod-logspace computations. We describe a recursive construction for a FUL p e algorithm (for any fixed prime power p e ) to solve the problem LCONNULLpe of computing a spanning set for a basis of the nullspace of a matrix modulo p e . This allows us to demonstrate that LCON k is coMod k L-complete, and both LCONX k and LCONNULL k are F·coMod k L-complete, for any constant k 2.

Preliminaries
Throughout the following, k 2 is a constant modulus, with a factorization into powers of distinct primes k = p e1 1 p e2 2 · · · p e . When we consider the case of a modulus which is a prime power, we will write p e rather than k, for p some prime and e 1 some positive integer which are independent of the input.
We consider the complexity of the following problems, which are named in analogy to problems considered by McKenzie and Cook [1]: For an m × n integer matrix A and vector y ∈ Z m provided as input, we define the following problems: • LCON k : determine whether Ax ≡ y (mod k) has solutions for x ∈ Z n .
• LCONX k : output a solution to the congruence Ax ≡ y (mod k), or indicate that no solutions exist.
• LCONNULL k : output a set x 1 , . . . , x N of vectors spanning the solution space of the congruence Ax ≡ 0 (mod k).
Without loss of generality, we may suppose m = n by padding the matrix A. We wish to describe the relationship of these problems to the classes coMod k L for k 2, which are the complements of the better known classes Mod k L defined by Buntrock et al. [4].
Definition I. The class coMod k L (respectively Mod k L) is the set of languages L for which there exists ϕ ∈ #L such that x ∈ L if and only if ϕ(x) ≡ 0 (mod k) (respectively, ϕ(x) ≡ 0 (mod k)).
The following results are a synopsis of Ref. [4,Theorem 9]: Proposition 1. We may characterize coMod k L as the class of decision problems which are log-space reducible to verifying matrix determinants mod k, or coefficients of integer matrix products or matrix inverses mod k.
Buntrock et al. also characterize the classes coMod k L in terms of the prime factors of k, and show closure results which will prove useful. The following are implicit in Lemma 5, Theorem 6, and Corollary 7 of Ref. [4]: 1 p e2 2 · · · p e be the factorization of k 2 into prime powers p ej j . Then L ∈ coMod k L if and only if there are languages L j ∈ coMod pj L such that L = L 1 ∩ · · · ∩ L . In particular, coMod k L = coMod p1p2···p L.
Proposition 4 (closure under intersections). For any k 2 and languages L, L ∈ coMod k L, we have L ∩ L ∈ coMod k L.
Proposition 5 (limited closure under complements). For any prime p and e 1, we have coMod p e L = coMod p L = Mod p L = Mod p e L.
A system of linear congruences mod k has solutions if and only if it has solutions modulo each prime power divisor p ej j of k. We then have LCON k ∈ coMod k L if and only if LCONpe ∈ coMod p e L = coMod p L by Proposition 3. (In fact, this suffices to show that LCON k ∈ coMod k L for all square-free integers k 2.) We see from Propositions 2 and 5 that the case of a prime modulus is special. For p prime, Buntrock et al. also implicitly characterize the complexity of LCONXp and LCONNULLp. We may describe the complexity of these function problems as follows. For a function f (x) : Σ * → Σ * and x ∈ Σ * , let |f (x)| denote the length of the representation of f (x); and let f (x) j denote the j th symbol in that representation. Following Hertrampf, Reif, and Vollmer [5], for a function f : Σ * → Σ * on some alphabet Σ, and for some symbol • / ∈ Σ, we may define the decision problem Abusing notation, we write f (x) j = • in case |f (x)| < j. We extend this definition to partial functions f by asserting (x, j, b) ∈ bits(f ) only if x ∈ dom(f ).
Definition II. The class F·coMod k L is the set of (partial) functions f such that |f (x)| ∈ poly(|x|) for all x ∈ Σ * , and for which bits(f ) ∈ coMod k L. (We define the class FMod k L similarly.) Then Ref. [4,Theorem 9] also implicitly shows: Proposition 6. For p prime, the problems LCONXp and LCONNULLp are F·coMod p L-complete.
In Section 3, we describe two additional function classes which are natural when considering modular logspace computation. Relationships between these classes in the case of prime-power modulus will allow us to easily show in Section 4 that in fact LCONXpe , LCONNULLpe ∈ F·coMod p L for all prime powers p e . These results then naturally extend to all moduli k 2, so that LCONX k , LCONNULL k ∈ F·coMod k L, with LCON k ∈ coMod k L following as a corollary.

Natural function classes for modular logspace
We now introduce two classes for counting classes in logarithmic space: a modular analogue of #L, and a class of function problems which is naturally low for Mod k L and coMod k L. We describe the relationships of these classes to FMod k L and F·coMod k L, and to each other in the case of a prime modulus.
Definition III. The class #L k is the set of functions f : Σ * → Z/kZ such that f (x) = ϕ(x) + kZ for some function ϕ ∈ #L.
Note that #L k inherits closure under addition, multiplication, and constant powers from #L; it is closed under subtraction as well, as M −N ≡ M +(k−1)N (mod k). We may then rephrase Proposition 1 as follows: Proposition 7. Evaluating matrix determinants modulo k, coefficients of products of integer matrices modulo k, and coefficients of inverses modulo k of integer matrices, are complete problems for #L k .
Similar containments hold for each of the problems listed in Ref. [4,Theorem 9]: any decision problem in coMod k L (such as the complete problems listed by Buntrock et al.) consists of comparing some function f ∈ #L k to a constant or an input value. Thus we trivially have: We may adopt the common conflation between equivalence classes a + kZ ∈ Z/kZ and integers 0 a < k, in which case we may instead require f ∈ #L k to satisfy 0 f (x) < k and f (x) ≡ ϕ(x) mod k for some ϕ ∈ #L. This will allow us to consider logspace machines which compute #L k functions on their output tapes. We will be interested in a particular sort of nondeterministic logspace machine which is suitable for performing computations as subroutines of coMod k L machines: the main result of this section is to describe conditions under which it can compute functions in #L k .
Definition IV. A FUL k machine computing a (partial) function f is a nondeterministic logspace Turing machine which (a) for inputs x ∈ dom(f ), computes f (x) on its output tape in some number ϕ(x, f (x)) ≡ 1 (mod k) of its accepting branches, and (b) for each y = f (x) (or for any string y, in the case x / ∈ dom(f )), computes y on its output tape on some number ϕ(x, y) ≡ 0 (mod k) of its accepting branches. We say that f ∈ FUL k if there exists a FUL k machine which computes f .
If we replace the relation of equivalence modulo k with equality in the definition of FUL k above, we obtain a class FUL of functions computable by nondeterministic logspace machines with a single accepting branch. This latter class is analogous to the class UPF described in Ref. [6], which is in effect a class of functions which may be computed by a nondeterministic polynomial time Turing machine as a subroutine without affecting the number of accepting branches of that machine. Modulo k and in logarithmic space, this is the significance of the class FUL k . Note that in many branches (perhaps even the vast majority of them), what is written on the output tape of a FUL k machine U may not be the function f (x) which it "computes"; but any result other than f (x) which U is meant to compute, cannot affect the number of accepting branches modulo k of any machine which simulates U directly, e.g. as a subroutine. These "incorrect results" may therefore be neglected for the purpose of counting accepting branches modulo k, just as if all accepting branches of U (of which there are not a multiple of k) computed the result f (x) on the output tape.
In this sense, the closure result Mod p L ModpL = Mod p L for p prime shown by Hertrampf, Reif, and Vollmer [5] may be interpreted as saying that the characteristic function of any L ∈ Mod p L may be computed by a FUL p machine; and so a Mod p L oracle can be directly simulated by a Mod p L machine, by simulating the corresponding FUL p machine as a subroutine. Our interest in the function class FUL k is for essentially the same reason, i.e. an oracle for computing any function f ∈ FUL k can be substituted with a simulation of the FUL k machine itself in the same manner: The proof is essentially the same as that for the oracle closure result of Ref. [5], of which this Lemma is a natural extension. From simple number-theoretic considerations, the classes FUL k have other properties which are similar to those of coMod k L: Proof. Throughout the following, let κ = p 1 p 2 · · · p be the largest square-free factor of k. We first show FUL κ = FUL p1 ∩ · · · ∩ FUL p . Suppose f ∈ FUL pj for each 1 j , and is computed by some FUL pj machine U j in each case. Let For each prime p j , all of the terms in the right-hand sum are divisible by p j except for the j th term. Then γ is coprime to p j for each j, and so is also coprime to κ. Let β ≡ γ −1 (mod κ), and consider the machine U which performs the following: 1. Nondeterministically write some index 1 j on the work tape.
2. For each such j, nondeterministically select some integer 0 q < βκ/p j .
3. In each branch, simulate U j on the input x, accepting if and only if U j accepts.
For any string y ∈ Σ * different from f (x), the number of branches in which U j accepts is m j p j for some m j ∈ N; and so U has m j βκ branches where j is written on the work tape and y is written on the output tape. Summing over all j, we find that any y = f (x) is written on the output tape in a number of branches which is a multiple of κ. Similarly, for the case y = f (x), the number of branches in which U j accepts is m j p j + 1 for some m j ∈ N; and so U has m j βκ + βκ/p j branches where j is written on the work tape and f (x) is written on the output tape. Summing over all j and neglecting multiples of κ, we have β κ/p 1 + · · · + κ/p ) = βγ ≡ 1 (mod κ) branches in which f (x) is written on the output tape; thus U is an FUL κ machine computing f . The converse containment FUL κ ⊆ FUL pj for each 1 j is trivial.
It remains to show that FUL κ ⊆ FUL k , the reverse containment again being easy. Let U be a FUL κ machine computing a function f : Σ * → Σ * with length bounded above by |f (x)| N (x) ∈ poly(|x|). Suppose N (x) ∈ O(log |x|): we may then construct a FUL k machine U which computes f by simply performing k/κ consecutive independent simulations of U , recording the outcome of each simulation on the work tape. For each 1 j k/κ, in any given computational branch, let ϕ j (x) be the string computed by the j th simulation of U . If any of the simulations produce a different output (i.e. if ϕ h (x) = ϕ j (x) for any 1 h, j k/κ) or if any of the simulations rejected the input,Ū rejects. Otherwise,Ū writes the string ϕ 1 (x) agreed upon by the simulations to the output tape. More generally, if N (x) ∈ ω(log |x|), then fix some L ∈ O(log |x|), and define for each 1 m N (x)/L a machine U m which writes the m th block of L consecutive characters from f (x), padding the end of f (x) with a symbol • / ∈ Σ if necessary. Rather than perform k/κ simulations of U , the machine U performs k/κ simulations of each such U m , again writing their outcomes (excluding any instance of the symbol • / ∈ Σ) to the work tape if and only if each simulation accepts and agrees on their output. Once N (x) symbols have been written to the output tape, U accepts unconditionally.
Let ϕ(x, y) be the number of computational branches in which U accepts with the string y ∈ Σ * written on the tape: by hypothesis, ϕ(x, y) ≡ 0 (mod κ) for each y = f (x), and ϕ(x, f (x)) ≡ 1 (mod κ). Similarly, let ϕ m (x, y (m) ) be the number of branches in which U m accepts with y (m) ∈ Σ L written on the tape for each 1 r N (x)/L, and Φ(x, y) be the number of branches in which U accepts with y ∈ Σ * written on the tape. Let M = N (x)/L for the sake of brevity. If y = y (1) as for each y (m) , the number of branches in which U accepts with y (m) written on the output tape is independent of the other substrings y (j) for j = m, and results from k/κ simulations of U m which each produce the substring y (m) as output.
Note that ϕ m (x, λ m ) is equal to the number of computational branches in which U writes a string σ ∈ Σ * on the output tape in which the m th block is equal to y (m) , which is the sum of ϕ(x, σ) over all strings σ consistent with the substring y (m) . By hypothesis, ϕ(x, σ) is a multiple of κ except for the single . We then observe the following: • The integers which are congruent to 1 modulo κ form a subgroup of order k/κ within the integers modulo k; it then follows that Taking the product over 1 m M , we have Φ(x, y) ≡ 0 (mod k) unless each substring y (m) is consistent with the m th block of f (x), in which case y = f (x) and Φ(x, y) ≡ 1 (mod k). Thus U is an FUL k machine computing f .
The requirement that an FUL k machine have one accepting branch modulo k allows us to easily relate FUL k to the classes FMod k L and F·coMod k L: Lemma 11. For all k 2, we have FUL k ⊆ FMod k L ∩ F·coMod k L.
Proof. Let U be a FUL k machine computing f : Σ * → Σ * . Consider a nondeterministic logspace machine T taking inputs (x, j, b) ∈ Σ * × N × Σ ∪ {•} , and which simulates U, albeit ignoring all instructions to write to the output tape, except for the j th symbol which it writes to the work-tape. (If j > |f (x)|, T instead writes "•" to the work-tape.) Then T compares the resulting symbol f (x) j against b, accepting if they are equal and rejecting otherwise. Then the number of accepting branches is equivalent to 1 modulo k if f (x) j = b, and is a multiple of p otherwise, so that bits(f ) ∈ Mod k L. To show bits(f ) ∈ coMod k L, we may consider a machine T which differs from T only in that it rejects if f (x) j = b, and accepts otherwise. Thus FUL k ⊆ FMod k L ∩ F·coMod k L.
This identifies FUL k as an important subclass of the existing logspace-modular function classes. For prime-power moduli, we may sharpen Lemma 11 to obtain a useful identity: Lemma 12. For any prime p and e 1, FUL p e = FMod p L = F·coMod p L.
Proof. By Proposition 5 and Lemma 10, it suffices to prove FUL p = FMod p L for p prime. For f ∈ FMod p L, we may construct from the Mod p L machine T which decides bits(f ) a family of machines T j,b (for each j ∈ N and b ∈ Σ ∪ {•}), each of which writes b on its output tape and deciding whether (x, j, b) ∈ bits(f ) on an input x ∈ Σ * . Without loss of generality, as in [5, Corollary 3.2] each machine T j,b accepts on a number of branches ϕ(x, j, b) ≡ 1 (mod p) if case f (x) j = b, and ϕ(x, j, b) ≡ 0 (mod p) otherwise.
We form a FUL p machine U j computing f (x) j by taking the "disjunction" of the machines T j,b over all b ∈ Σ ∪ {•}: i.e. U j branches nondeterministically by selecting b ∈ Σ ∪ {•} to write on the work-tape and simulates T j,b , accepting with one branch mod p if and only if b = f (x) j and accepting with zero branches mod p otherwise. Given some upper bound |f (x)| N (x) ∈ poly(|x|), we then construct a FUL p machine U to compute f (x) by simply simulating U j for each 1 j N (x) in sequence, writing the symbols f (x) j individually on the output tape; accepting once it either computes a symbol f (x) j = • (without writing • to the output) or the final iteration has been carried out.
Lemma 12, together with Lemma 9, may be taken as re-iterating the closure result of Ref. [5] explicitly in terms of function classes. The importance of this result to us is in the following consequences, which follow from Proposition 8 and Lemma 9: Corollary 13. For any prime p and e 1, #L p e ⊆ FUL p .
Corollary 14. For any prime p and e 1, coMod p L #L p e = coMod p L.
The former result states that we may explicitly compute functions in #L (albeit up to equivalence modulo p e ) on the work tape, as subroutines in decision algorithms for coMod p L; this allows us to simulate logspace counting oracles modulo p e in coMod p L. In the following section, we use this to describe an algorithm for LCONNULLpe in F·coMod p L by a similar analysis to McKenzie and Cook [1]. By standard techniques, we may then demonstrate containments for LCON k , LCONNULL k , and LCONX k in terms of coMod k L.

Solving congruences and nullspaces mod k
We return to the motivating problems of this article. We let A be an n×n integer matrix and y ∈ Z n which are provided as the input to LCON k or LCONX k ; and for LCONNULL k , we consider an n × n matrix B. Without loss of generality, the coefficients of A and y, or of B, are non-negative and bounded strictly above by k (as reducing the input modulo k can be performed in NC 1 ). We essentially follow the analysis of Ref. [1,Section 8], which reduces solving linear congruences to computing generating sets for nullspaces modulo the primes p j dividing k. The technical contribution of this section is to show that the latter problem can be solved for prime powers via a reduction to matrix multiplication together with modular counting oracles from #L p e for prime powers p e .

Computing nullspaces modulo prime powers
We consider an NC 1 reduction to matrix inversion and iterated matrix products modulo p e , in a machine equipped with a #L p e oracle to compute certain matrix coefficients. As we note in Proposition 7, computing individual coefficients of matrix inverses and matrix products are complete problems for F·coMod p L, and Corollary 14 implies that this class can simulate #L p e oracles. The NC 1 reduction itself is essentially the same as that of McKenzie and Cook [1], which we may summarize as follows.
The prime modulus case. First, consider the case e = 1, which as we note in Section 2 is solved by Buntrock et al. [4,Theorem 9]. For an n × n integer matrix B, we may reduce the problem of computing a basis of null(B) mod p to rank computations and matrix inversion using the techniques of Borodin, von zur Gathen, and Hopcroft [7,Theorem 5]. This involves testing the ranks of a nested collection of sub-matrices of B, to determine a subset of columns forming a basis for img(B); the reduction from nullspaces is a truth-table reduction, which for the ultimate reduction to coMod p L means that we must use Proposition 4 (to enable conjunctive reductions) and Proposition 5 (to allow disjunctive reductions). Computing the rank of a matrix modulo a prime (i.e. in the field F p ) may be reduced to computing characteristic polynomials of matrices in F p (τ ) for a formal indeterminate τ using a result of Mulmuley [8]; this may be reduced to iterated matrix products over F p (τ ) by a construction of Berkowitz [9], where the coefficients of the matrices are all either constants or drawn from the coefficients of the matrix M . By deriving a suitable bound on the degrees of the polynomials over τ involved in these iterated matrix products, one may substitute the polynomial coefficients by polynomial-size Toeplitz matrix blocks [10], thereby reducing the iterated matrix product over F p (τ ) to one over F p .
Recursive reduction for higher powers of primes. Nt over Z/p e Z for the nullspace of B modulo p t . Certainly any solution to Bw ≡ 0 (mod p t+1 ) must also be a solution to Bw ≡ 0 (mod p t ) as well; then we may decompose such w modulo p e as a linear combination of the vectors V (t) j , for someŵ ∈ Z n ; or more concisely, where we define the block matrices p t I and z = u 1 u 2 · · · u Nt ŵ T ∈ Z Nt+n . To consider the additional constraints imposed by Bw ≡ 0 (mod p t+1 ), consider a decomposition B = B t + p tB t , where the coefficients of B t are bounded between 0 and p t . We then have have coefficients divisible by p t by construction, we may simplify to or somewhat more concisely,B where we definē and where z is as we defined it above. To find not just one vector w but a set of generators V Nt+1 over Z/p e Z for null(B) mod p t+1 , it suffices to find a generating set z 1 , . . . , z Nt+1 for the nullspace ofB (t) mod p, and then set V (t+1) h = V (t) z h . Note that the nullspace ofB (t) modulo p over Z/p e Z will contain many vectors which are equivalent mod p, but at most N t +n equivalence classes; we may then without loss of generality select vectors z 1 = pê 1 , z 2 = pê 2 , . . . , z Nt = pê Nt , and choose the remaining vectors z h representing non-trivial vectors in null(B (t) ) mod p to have coefficients bounded between 0 and p. We thus obtain N t+1 2N t +n vectors over Z/p e Z which span null(B) modulo p t+1 . Because LCONNULLp ∈ FUL p e , which is low for coMod p L, we have reduced to computing matrix products involving the matrixB (t) in a coMod p L machine.
Matrix products in oracle models. The natural approach outlined in Buntrock et al. [4] for evaluating the coefficients of an iterated matrix product M 1 M 2 · · · M poly(n) modulo k -i.e. as a #L k function -requires access to individual coefficients at any given step of the algorithm. One simulates a branching program with nondeterministic choices, in which the matrices act as transition functions on the row-positions of a vector v τ ∈ (Z/kZ) n , to obtain a new vector v τ +1 . To evaluate the (h, j)-coefficient of the matrix product, we count the number of computational branches which end at a the h th row, given an initial vector v 0 =ê j : we do this by accepting all branches which end with the row position h, and rejecting all others. This approach requires only non-deterministic selection of row-positions, logarithmic space to record the row-positions, and the ability query individual coefficients of the matrices being multiplied. When the matrices M j are specified as part of the input, or more generally for any problem reduced projectively to matrix products (meaning that the matrices involved have coefficients which are either constants or taken from the input tape), the algorithm to evaluate the matrix products is straightforward; more generally, for any class C which is low for coMod k L (e.g. C = FUL k ), we may compute any matrix product in coMod k L where the coefficients are obtained from the input by may be obtained by queries to C oracles.
We may use these observations to reduce LCONNULLpe to matrix products modulo p e . In the recursive reduction for prime powers outlined above to LCONNULLp, every step is projective except for the matrix multiplications, and the problem of finding null spaces modulo p for the matricesB (t) (which are not themselves part of the input). The columns ofB (t) are either columns ofB t (which are themselves the result of integer division of columns of B by p t , this dividend being bounded by a constant) or are integer vectors of the form BV (t) /p t . The coefficients of BV (t) are computable as a matrix product, and thus may be computed in #L p e from B itself and V (t) ; provided a #L p e oracle, we may then obtain those coefficients and divide them by p t in NC 1 . By Corollary 13, we have #L p e ⊆ FUL p , which is low for coMod p L. We therefore have a coMod p L-reduction from computing a basis for null(B) modulo p t+1 to computing the basis V Nt modulo p t . We may then carry out the recursive reduction to obtain a FUL p e -reduction from LCONNULLpe to iterated matrix products, via LCONNULLp; the number of vectors V (e) j in the generating set will, by induction, be N e n + 2n + · · · + 2 e−1 n p e n ∈ O(n).
An important feature the recursive reduction described above is that the exponent e is itself a constant. The #L p e oracles to compute coefficients of B (e−1) require access to the coefficients of vectors V (e) j , which in turn will require #L p e oracles to compute coefficients ofB (e−2) , and so on. This is a sequential reduction, and the space resources can be described straightforwardly using a stack model of the work tape: each nested #L p e oracle is simulated as a FUL p e subroutine which is allocated O(log |B|) = O(log(n)) space on the tape (where |B| ∈ O(n 2 ) is the size of the input matrix after reduction modulo p e ), and which makes further recursive calls to FUL p e subroutines which do likewise, down depth at most e. The space resources then scale as O(e log(n)); in our setting of a constant modulus, the space requirements are then O(log(n)).
Consider a nondeterministic logspace machine with alphabetΣ = Σ ∪ {•} for Σ = {0, . . . , p e − 1}. Using a FUL p e -reduction to reduce LCONNULLpe for prime powers p e to computing coefficients of matrix products, we may test equality of individual coefficients against some reference value b ∈Σ provided as input. Therefore: Lemma 15. LCONNULLpe ∈ F·coMod p L.

Completeness results for arbitrary constant moduli
The above suffices to show that LCON k , LCONX k , and LCONNULL k are complete problems for coMod k L and F·coMod k L, as we now show. We consider nondeterministic logspace machines operating on an alphabetΣ k = Σ k ∪ {•}, where Σ k is the set of integers 0 r < k. For the function problems LCONNULL k and LCONX k , we wish respectively to compute is a sequence of vectors (Z 0 , Z 1 , . . . , Z N −1 ) which generate null(B) in Z/kZ; and • a partial function S k : Σ n 2 +n Σ n such that (A, y) ∈ dom(S k ) if and only if there exists a solution x to the system Ax ≡ y (mod k), in which case S k (A, y) is such a solution.
Following [1, Lemma 5.3], we may reduce LCON k and LCONX k for k 2 to LCONNULL k , as follows. Suppose Ax ≡ y (mod k) has solutions. Consider B = [ A | y ]: then there are solutions to the equation Bx ≡ 0 (mod k). In particular, there will be a solutionsx = x ⊕ x n+1 in which x n+1 = −1, and more generally in which x n+1 is coprime to k. Conversely, if there is such a solutionx to Bx ≡ 0 (mod k), we may take α ≡ −x −1 n+1 (mod k) and obtain A(αx) ≡ −αx n+1 y ≡ y (mod k). To determine whether Ax ≡ y (mod k) has solutions, or to construct a solution, it thus suffices to compute a basis for the nullspace of B, and determine from this basis whether any of the vectors x ∈ null(B) have a final coefficient coprime to k; if so, the remainder of the coefficients ofx may be used to compute a solution to the original system.
In the special case k = p e of a prime power, coprimality to k simply entails that k is not divisible by p. To solve LCONpe and LCONXpe , we compute individually the final coefficients of the vectors (Z 0 , Z 1 , Z 2 , . . .) = N p e (B) for B = [ A | y ], searching for an index 1 h N e for which the dot product e n+1 ·Z h is not divisible by p. Without loss of generality, we select the minimum such h: the search problem can be formulated as a truth-table reduction on divisibility tests of these coefficients by p. Both the reduction and the divisibility test are feasible for coMod p L; we may suppose that this reduction and test are performed by a FUL p oracle so that the outcome is explicitly recorded on the work tape in a single branch mod p. If there is no such index h, we indicate that no solution exists by accepting unconditionally, indicating either a no instance of bits(S k ) or of LCON k on a coMod p L machine. Otherwise, there exists a solution to the linear congruence. To indicate for LCONpe that (A, y) is a yes instance on a coMod p L machine, we reject on all computational branches to make the number of accepting branches zero modulo p. To solve bits(S k ), we compute the minimum index h and the coefficientê T n+1 Z h , which we store on the work tape in binary. We then compute α ≡ −x −1 n+1 (mod p e ), and then obtain the coefficients of αZ h , which we compare to input coefficients, rejecting (to indicate a yes instance) if the coefficients match, and accepting (to indicate a no instance) otherwise. Therefore: Lemma 16. LCONpe ∈ coMod p L and LCONXpe ∈ F·coMod p L.
As we remarked in Section 2, we may solve LCON k for arbitrary moduli k = p e1 1 p e2 2 · · · p e by reduction to the problems LCON p j e j for 1 j ; the same is true for LCONX k and LCONNULL k . Let q j = p ej j for the sake of brevity. For LCON k , we simply have LCON k = LCONq 1 ∩ · · · ∩ LCONq . For LCONNULL k and LCONX k , let congbits(f, qj) be the decision problem of determining for inputs (x, h, b) ∈ Σ * k × N ×Σ k whether x ∈ dom(f ), and (this being granted) whether either f ( • Clearly bits(S k ) is the intersection of the problems congbits(S k , qj) for 1 j . We may show congbits(S k , qj) ∈ coMod qj L for each 1 j , as follows. For b ∈ Σ k , we may expand b in binary on the work tape and evaluate its reduction 0 b < q j modulo a given prime power q j ; for b = • we simply let b = • as well, so that b ∈Σ qj . We perform a similar reduction for each coefficient in (A, y) to obtain an input (A , y ) with coefficients in Σ qj . Then we may simulate a coMod pj L machine to decide whether ((A , y ), h, b ) ∈ bits(Sq j ). Thus bits(S k ) ∈ coMod k L. Nj spanning the nullspace of B modulo q j for each 1 j , the nullspace of B modulo k is spanned over the integers modulo k by the vectors (We omit the vectors kê h included by Ref. [1], as these are congruent to 0 in Z/kZ.) Let Z h be the list of such vectors, for 0 h < N 1 + · · · + N : we define N k for k divisible by more than one prime to produce this sequence of vectors as output. Notice that each Z h is congruent to 0 modulo q j for every j = 1 for 0 h < N 1 , congruent to 0 modulo q j for every j = 2 for N 1 h < N 1 + N 2 , and generally, congruent to 0 modulo q j for every j 1, except for the index j for which M j−1 h < M j , where for the sake of brevity we write M j = j t=1 N t . We may then reduce bits(N k ) to testing the congruence of coefficients of Z h with 0 modulo q j for all prime powers for which h < M j−1 or h M j , and testing congruence with the coefficients of k qj X (qj ) h−Mj +1 otherwise. These congruences modulo each prime power q j can again be evaluated in coMod qj L algorithm for congbitsj(N k ), using the NC 1 reduction to bits(Nq j ) as above.
The above reductions suffice to show: Theorem 17. For all k 2, we have LCONNULL k , LCONX k ∈ F·coMod k L and LCON k ∈ coMod k L.
Finally, note that one may also LCONp j to LCON k , for any prime p j dividing k, by considering the feasibility of the congruence which is equivalent to Ax ≡ y (mod p j ). By Propositions 2-4, all problems in LCON k may be reduced to solving some instances of LCONp j for each 1 j : then LCON k is coMod k L-hard. Similar remarks apply to LCONX k and LCONNULL k . Therefore: Theorem 18. For all k 2, LCON k is coMod k L-complete, and LCONNULL k and LCONX k are F·coMod k L-complete.

Further Remarks
The above analysis was motivated by observing that the reduction of McKenzie and Cook [1] for LCONX and LCONNULL (which take the modulus k as input, as a product of prime powers p ej j ∈ O(n)) was very nearly a projective reduction to matrix multiplication, and that it remained only to find a way to realize the division by prime powers p t involved in the reduction to LCONNULLp. By showing that logspace counting oracles modulo p e could be simulated by a coMod p L machine, using the function class FUL k as a notion of naturally simulatable oracles for the classes Mod k L and coMod k L, the containments of Theorem 17 became feasible.
Extending the definition of bits(f ) to accomodate partial functions in the is crucial to our result that LCONX k ∈ F·coMod k L, in the sense that there is no obvious way to extend the algorithm to decide bits(S k ) for any unambiguous extension of S k to infesible systems of equations, e.g. by accepting on some symbol "!" if and only if there is no solution to a congruence provided as input. Such an algorithm would be a signficant result, as it would follow that LCON k ∈ Mod k L, thereby showing that this class is closed under complements.
In the recursive reduction for LCONNULLpe , the fact that e ∈ O(1) is essential not only for the logarithmic bound on the work tape, but also for the running time on a coMod k L machine to be polynomial. The FUL p machines used to implement the #L p e oracles, from the constructions of Theorem 10 and Lemma 12, implicitly involve many repeated simulations of coMod p L machines (p e /p = p e−1 times each) to decide equality of counting functions with residues 0 r < p e : this contributes to a factor of overhead growing quickly with e. Therefore our results are mainly of theoretical interest, characterizing the complexity of these problems with respect to logspace reductions. It is reasonable to ask if there is an algorithm on a coMod p L machine for LCONNULLpe , whose running time grows slowly with e.
Given the natural role of the class FUL p e in simulating of #L k oracles, one might ask e.g. whether the characteristic function of LCON k is contained in FUL k . It is interesting to consider the difference between such potential containments, and those proven as Theorem 17. We first note an alternative characterization of coMod k L: Proposition 19. For every k 2, L ∈ coMod k L if and only if there exists ϕ ∈ #L such that x ∈ L if and only if ϕ(x) is coprime to k.
Proof. For k = p e1 1 p e2 2 · · · p e as usual, we have L ∈ coMod k L if and only if L = L 1 ∩ L 2 ∩ · · · ∩ L for languages L j ∈ coMod pj L = Mod pj L by Propositions 3 and 5. Let T 1 , . . . , T be nondeterministic logspace machines such that T j accepts on input x with a number of branches not divisible by p j if x ∈ L j , and with zero branches modulo p ej j otherwise. Using a similar construction to that of Lemma 10 for the square-free case, we may obtain a single nondeterministic logspace machine T which accepts on a number of branches not divisible by p j if x ∈ L j , and on a number of branches equivalent to 0 mod p j otherwise. If x ∈ L, then the number of branches on which T accepts is not divisible by any prime p j , which means that it is coprime to k; otherwise, there exists some prime p j which divides the number of accepting branches, so that the number of branches is not coprime to k.
output strings y = f (x) must occur in zero branches mod k and not just in a number of branches which has maximal prime power factors in common with k. Thus, we see that Definition IV does not result in a class which is entirely different in signficance from F·coMod k L, even for k composite.
There is no obvious way to bridge the gap between the definition of FUL k , and the characterization of F·coMod k L given by Proposition 19. Of course, LCON k can be solved in FUL k if and only if FUL k = F·coMod k L. As FUL k is low for coMod k L, this would imply coMod k L is closed under logspace Turing reductions, and that therefore Mod k L = coMod k L. Furthermore, by Proposition 3 and Theorem 10, FUL k = F·coMod k L would imply a surprising collapse of logspace mod classes beneath coMod k L: for any distinct prime divisors p h , p j of k we would have FMod p h L ⊆ FMod k L = FUL k ⊆ FUL pj = FMod pj L, and in particular Mod p h L = Mod pj L. The converse, that Mod p h L = Mod pj L for all primes dividing k only if FUL k = F·coMod k L, is trivial. A similar collapse would occur even if the characteristic function of LCON k could be computed in F·coMod k L; not only would this indicate that coMod k L is closed under containment, but also under oracles, as it would allow simulation of F·coMod k L oracles in a way much similar to the simulation of FUL k oracles by coMod k L machines (where a collection of branches having the same tape-conents are insignificant if the number of branches has prime power divisors in common with k, although not necessarily divisible by k). If we suppose that FUL k , FMod k L, and F·coMod k L are distinct for any k 2 divisible by two or more primes, it would be interesting to characterize FUL k as a subclass of FMod k L ∩ F·coMod k L.