Rational transductions and complexity of counting problems ...

6 downloads 33 Views 829KB Size Report
Tell us about your experience on SpringerLink and you could win a MacBook Pro. Take survey. Download PDF · Mathematical systems theory. September 1995 ...
Math. Systems Theory 28, 437-450 (1995)

Mathematical Systems Theory 9 1995 Springer-Verlag New York Inc.

Rational Transductions and Complexity of Counting Problems* C. Choffrut I and M. Goldwurm 2 1 Laboratoire d'Informatique Throrique et de Programmation, Universit6 Pads VII, UA248, Tour 55-56, 2 Place Jussieu, 75221 Pads Cedex 05, France [email protected] 2 Dipartimento di Scienze dell'Informazione, Universit~ degli Studi di Milano, via Comelico 39, 20135 Milano, Italy [email protected]

This work presents an algebraic method, based on rational transductions, to study the sequential and parallel complexity of counting problems for regular and context-free languages. This approach allows us to obtain old and new results on the complexity of ranking and unranking as well as on other problems concerning the number of prefixes, suffixes, subwords, and factors of a word which belongs to a fixed language. Other results concern a suboptimal compression of finitely ambiguous context-free languages, the complexity of the value problem for rational and algebraic formal series in noncommuting variables, and a characterization of regular and Z-algebraic languages by means of ranking functions. Abstract.

I.

Introduction

Several counting problems defined on formal languages have recently been studied in the literature. We recall the problem of counting the accepting computations in various kinds of nondeterministic machine models [3], [21], [22], the problem of computing the number of words of a given length in a language [7], and the classical ranking problem [13], [15], [17]. These problems are related to several topics of * A preliminary version of this work was accepted for presentation at the 17th Symposium on Mathematical Fotmdations of Computer Science (MFCS '92), Prague, August 24-28, 1992. This research was supported by ESPRIT Working Group ASMICS (CEC Contract No. 3166), PRC Mathrmatiques et Informatique, MURST Project 40% "Algoritmi, modelli di calcolo e strutture informative."

438

c. Choffrutand M. Goldwurm

computational complexity and provide examples of complete functions for interesting complexity classes. Given a language L C_ •*, the ranking problem for L consists of computing, for an input x C Z*, the number of words in L which either have length less than the length of x or, having the same length, precede x lexicographically. The problem is clearly related to determining a succinct and efficiently computable representation of the words of a language and in fact it has been studied as a special case of optimal compression [ 13]. The ranking problem for any language in P belongs to the class #P of functions computing the number of accepting computations of nondeterministic Turing machines working in polynomial time [21]. The problem turns out to be #P-complete for several simple classes of languages included in P and, in particular, for finitely ambiguous contextfree languages [17]. However, the problem is NCl-reducible to integer division in the case of regular languages [6], [18], it belongs to #SAC 1 C NC 2 for unambiguous context-free languages and, more generally, for languages accepted by 1-way Unambiguous Auxiliary PDA [17], [22]. In this work we study the parallel and sequential complexity of ranking and other counting problems in the "easy" case, assuming the log-space uniform families of bounded fan-in Boolean circuits as the model of parallel computation [9]. We refer the reader to [9] and [22] for the definition of the classes NC k and #SAC k, respectively. Concerning the sequential complexity, we consider the RAM model under the logarithmic cost criterion [1]. In this model any arithmetic operation over two n-bit integers can be executed in O(n) time and space, provided that their addresses in the memory of the RAM are polynomially bounded. This amounts to neglecting a factor of log n log log n bit operations when evaluating the time required by product and division. We also observe that all our sequential algorithms execute arithmetic operations over integers of O(n) bits, n being the size of the input. We present an algebraic method, based on rational transductions, to study the sequential and parallel complexity of ranking and other counting problems in the case of regular and context-free languages. This approach allows us to reduce these problems to computing the coefficients of rational and algebraic formal series in noncommuting variables. Intuitively, in order to determine complexity bounds for computing a function f : Z* ~ N, we view it as a formal power series in N((X)) (f(x) is the coefficient of the power series associated with the word x). It just happens, in all our examples, that this power series is the image of an algebraic (resp. rational) formal power series g E N((X)) by a suitable faithful rational transduction r:X* ~ N((X)) (under reasonable conditions rational transductions extend to formal series). Since algebraic (resp. rational) formal power series are preserved by rational transductions, f is itself an algebraic (resp. rational) formal power series. In other words, computingf(x) for an arbitrary word x reduces to computing the coefficient associated with x in the series. For this reason we first study the value problem for formal series r E N((E)) which is the problem of computing the coefficient (r,x) for a given string x C Z*. Interpreting the results in [22], it tunas out that the value problem for any algebraic formal series r E N((Z)) belongs to #SAC 1 and hence lies in NC 2. Moreover, the problem can be solved in O(n 4) time and O(n 3) space on RAM under

Rational Transductionsand Complexityof Counting Problems

439

logarithmic cost criterion and, if r is bounded, the time and space bounds can be reduced to O(n 2 log n) and O(n2), respectively. For rational formal series in N((Z)) the value problem can be solved by a RAM with logarithmic cost, in O(n 2) time and O(n) space. Furthermore, it can be solved by (log-space) uniform families of bounded fan-in Boolean circuits of O(log n log log n) depth and polynomial size. As an application of these considerations to languages, for any L C_ Z*, we consider the following functions:

l. 2. 3. 4. 5. 6.

rankL(X) = #{y E L: y ~r X}. shrankL(x) = #{y E L: lyl = [xl,y i

~x j,

f12(O'i)=

Eo 1 {7iZZ, 0 '

O'i ]

where 1 < i < k. Consider the faithful rational tmnsductions zl, z2, Z3 realized by ~1, #2, J13, respectively, such that 171(2) -= 0 and z2 (2) = "ca @) = Zz*. It is easy to see that 171, z2,173 are unambiguous and satisfy the following relations for every X E Z + : 171(X) -~- {y E zlxl: x _