You are on page 1of 7

TWO REMARKS ON THE POWER OF COUNTING

C h r i s t o s H. Papadimitriou and Stathis K. Zachos


L a b o r a t o r y of C o m p u t e r Science, M . I . T .
C a m b r i d g e , USA

A u g u s t 1982

ABSTRACT

The relationship between the polynomial h i e r a r c h y and Valiant's class AitP is at


present unknown. We show t h a t some low p o r t i o n s of the polynomial h i e r a r c h y ,
namely d e t e r m i n i s t i c polynomial a l g o r i t h m s using an NP oracle at most a l o g a r i t h m i c
n u m b e r of times, can be simulated b y one ~ P c o m p u t a t i o n . We also show t h a t the
class of problems solvable by polynomial-time nondeterministic Turing machines
which accept w h e n e v e r t h e r e is an odd number of accepting computations is idem-
p o t e n t , t h a t is, closed u n d e r usage of oracles from t h e same class.

KEYWORDS: C o u n t i n g p r o b l e m s , oracle c o m p u t a t i o n , polynomial h i e r a r c h y , p a r i t y


p r o b l e m s , machine simulation.
270

1. INTRODUCTION

Counting Turing machines, and t h e class ~t#P of c o u n t i n g problems t h a t can be


solved b y such machines in polynomial time, were f i r s t i n t r o d u c e d and s t u d i e d b y
Valiant [Val]. The r e l a t i o n s h i p of ~/'P w i t h o t h e r c o m p l e x i t y classes has since been
an i n t r i g u i n g open q u e s t i o n . I t is well known t h a t NP is contained in ~ P (we use
the term ~P originally meant f o r a class of f u n c t i o n s , to denote t h e class of
languages which are accepted in polynomial d e t e r m i n i s t i c time w i t h one invocation
of a ~ P computation). Furthermore, Simon [Si] showed some close r e l a t i o n s h i p s
between #~r~p and the p r o b a b i l i s t i c class PP [Gi]o On the o t h e r h a n d , i t was sus-
pected t h a t ~P lies above t h e whole polynomial h i e r a r c h y [St], b u t no p r o o f of
t h i s is known to d a t e . A n g l u i n [An] showed t h a t ~ P a p p r o p r i a t e l y r e i a t i v i z e d , is
more p o w e r f u l than ~2 p.

We were interested in showing that, in the unrelativized case, the class


~2 p = pNP is contained in ~P. What we were able to show is t h a t a p o r t i o n of
z~2PI namely t h e class p N P [ I o g ] of problems solvable b y p o l y n o m i a l - t i m e a l g o r i t h m s
using a l o g a r i t h m i c n u m b e r of calls to an NP oracle, is indeed contained in /~P.
This class c o n t a i n s , f o r example, the problem of t e s t i n g w h e t h e r a g i v e n u n d i r e c t -
ed g r a p h has a u n i q u e optimum c l i q u e [Pal ( i t is not k n o w n , h o w e v e r , w h e t h e r
this problem is complete f o r pPN[Iog]). I t also contains the class D p [PY] of
languages t h a t are t h e i n t e r s e c t i o n of a language in NP and one in coNP. F u r t h e r -
more, t h e r e is a whole h i e r a r c h y of classes of languages d e f i n a b l e as NP p r e d i c a t e s
combined b y Boolean connectives. The ith level of this h i e r a r c h y consists of all
languages t h a t can be e x p r e s s e d as the union of i languages in D p, The limit of
this hierarchy turns o u t to be identical to t h e class of languages recognized b y
polynomial a l g o r i t h m s using a bounded n u m b e r of calls to an NP oracle, and thus
is also a subset of ~ P , b y o u r r e s u l t .

The t e c h n i q u e used in the p r o o f of this theorem employs a simple way of en-


coding a computation w i t h oracle b r a n c h i n g s into the n u m b e r of accepting computa-
tions of a s i n g l e n o n d e t e r m i n i s t i c c o m p u t a t i o n , which can then be computed b y a
c o u n t i n g T u r n i n g machine, and then decoded. This t e c h n i q u e seems to be useful in
simulations b y c o u n t i n g machines. Using a v a r i a n t of t h i s t e c h n i q u e , we show an
i n t e r e s t i n g p r o p e r t y of t h e class OP of problems t h a t can be solved b y T u r i n g ma-
chines which accept if t h e n u m b e r of accepting computations is o d d . A typical
( c o m p l e t e ) problem in ~P is t h e set of all g r a p h s t h a t have an odd number of
Hamilton c i r c u i t s . OP can be considered as a more moderate v e r s i o n of t h e c o u n t -
ing idea. The r e l a t i o n s h i p between ®P and NP is not k n o w n , a l t h o u g h i t is sus-
pected t h a t NP is w e a k e r [ V a 2 ] . What we show is t h a t @P®P = OP, and t h u s ~P
appears to behave d i f f e r e n t l y from NP. T h i s f a c t had been p r o v e d i n d e p e n d e n t l y
by Valiant [Va2].
271

2. DEFINITIONS

For basic T u r i n g machine d e f i n i t i o n s see [GJ~ L P ] . All computation paths of a


nondeterministic Turing machine on a p a r t i c u l a r input ( o r the computations from
any g i v e n c o n f i g u r a t i o n ) form a t r e e . We do not i n s i s t t h a t all leaves of this t r e e
have the same d e p t h ( t h i s can be achieved b y a v a r i e t y of p a d d i n g t e c h n i q u e s ) .
We shall need to d e f i n e c e r t a i n n o t a t i o n f o r m a n i p u l a t i n g n o n d e t e r m i n i s t i c c o m p u t a -
tion t r e e s . I f C 1 , . . . , C k are c o n f i g u r a t i o n s of a T u r i n g machine ( e q u i v a l e n t l y , t h e
computation trees starting from these c o n f i g u r a t i o n s ) / then CHOOSE(CI~...,Ck)
denotes the computation t r e e c o n s i s t i n g of a new rootp which has n o n d e t e r m i n i s t i c
branches to all these computations. Alsot APPEND(CI~C 2) denotes t h e computation
t r e e consisting of t h e computation t r e e of C 1 w i t h a copy of C 2 h a n g i n g from each
accepting leaf of C 1. Finally, DUPL n denotes a computation t r e e which has e x a c t l y
n accepting leaves.

tf M is a n o n d e t e r m i n i s t i c T u r i n g machine, we let C O U N T ( M , x ) denote t h e


n u m b e r of accepting computations of M on i n p u t x . Thus, NP can be defined as
the class of languages L f o r which t h e r e is a n o n d e t e r m i n i s t i c T u r i n g machine M
such t h a t L = {x I COUNT(M,x)>0}. ~P is the class of languages t h a t can be
recognized b y a d e t e r m i n i s t i c p o l y n o m i a l - t i m e a l g o r i t h m which uses o n l y once an
oracle c o m p u t i n g COUNT. pNP[tog]~ a subclass of ~2 p = p N P is t h e set of p r o b -
lems solvable b y d e t e r m i n i s t i c p o l y n o m i a l - t i m e a l g o r i t h m s which use an oracle in NP
a n u m b e r of times which is at most p r o p o r t i o n a l to the l o g a r i t h m of t h e l e n g t h of
t h e i n p u t of t h e a l g o r i t h m . Finallyr 4~P is t h e class of all languages L, f o r which
there exists a nondeterministic Turing machine M such t h a t L = { x I C O U N T ( M , x )
mod 2 = 1}.

3. THE MAIN THEOREM

In t h i s Section we p r o v e the f o l l o w i n g :

THEOREM 1: p N P [ t o g ] c ~qfP.

PROOF: Suppose t h a t L is a language recognized b y a d e t e r m i n i s t i c T u r i n g ma-


chine M w i t h an oracle in NP, so t h a t at most p ( I x l ) steps, and at most I o g ( I x l )
oracle steps are used in t h e computation on i n p u t x . Assume w i t h o u t loss of gene-
r a l i t y t h a t t h e oracle q u e r i e s are of t h e form ( M ' , x ~ ) r asking w h e t h e r a n o n d e t e r -
ministic Turing machine M' accepts an i n p u t x ' in time p ( I x l ) . We also assume t h a t
272

M always asks e x a c t l y LLoglxlJ q u e r i e s . We shall design a d e t e r m i n i s t i c polynomial


a l g o r i t h m which decides L b y using one computation of COUNT.

The idea is t h e f o l l o w i n g : By m u l t i p l y i n g t h e n u m b e r of ~eaves in d i f f e r e n t


s u b t r e e s of t h e computation t r e e of M b y e x o r b i t a n t l y large n u m b e r s , we can u n -
a m b i g u o u s l y encode t h e outcomes of all the oracle calls along all possible computa-
tion paths of M. (Notice t h a t M, a l t h o u g h d e t e r m i n i s t i c , has a polynomial n u m b e r
of computation p a t h s , due to t h e oracle s t e p s . )

The algorithm first constructs, based on M and x , a nondeterministic Turing


machine N, as f o l l o w s . N is programmed basically like M, e x c e p t in t h e q u e r y con-
figurations. If t h e q u e r y ( M ' , x ' ) is the ith q u e r y asked b y M, and M goes to con-
f i g u r a t i o n C 1 i f t h e answer is " y e s " , and C o if " n o " , then N executes t h e nonde-
t e r m i n i s t i c p r o g r a m shown below:

CHOOSE(IDo(M',x'),APPEND(DUPLk(I),Cl),APPEND(DUPLk(i)Co)),
2,
where IDo(M',x') denotes t h e i n i t i a l c o n f i g u r a t i o n of t h e machine M' on i n p u t x ' ,
and t h e k(i)'s are i n t e g e r s to be defined l a t e r . In w o r d s , N nondeterministically
chooses among t h r e e p o s s i b i l i t i e s : e i t h e r to simulate M' on x ' and stop; o r to as-
sume t h e answer is " y e s " and a m p l i f y the s u b s e q u e n t computation b y a f a c t o r of
k(i); o r f i n a l l y to assume the a n s w e r is " n o " , in which case t h e a n s w e r is ampli-
fied b y k ( i ) 2 (see t h e f i g u r e below f o r a p i c t o r i a l p r e s e n t a t i o n of t h e c o n s t r u c t i o n
using computation t r e e s ) .

Computation Tree of N

~
Computation Tree of M

query

ith q u e r y : Does T have an A c c e p t i n g Leaf ?


273

T h e f u l l a l g o r i t h m is t h e f o l l o w i n g :

ALGORITHM A;
BEGIN
c o n s t r u c t N as d e s c r i b e d a b o v e ;
n ~ COUNT(N,x);
i÷1;
WHILE n > 1 DO
BEGIN
IF n MOD k ( i ) = 0 THEN n ~ n DIV k ( i ) 2
ELSE n ~ ( n MOD k ( i ) 2) DIV k ( i ) ;
i÷i+l
END;
IF n = 1 T H E N accept E L S E reject
END.

T h e k(i)~s a r e d e f i n e d b y t h e f o l l o w i n g e q u a t i o n s :

k([~glxlj) = 2p ( I x l )
k ( i ) = k ( i + 1) 4

Thus, k(i) increases r a p i d l y as i decreases ( o r , e q u i v a l e n t l y , as we p r o c e e d f r o m


l a t e r to z e a r l i e r queries). T h e maximum v a l u e of k ( i ) is k ( 1 ) , w h i c h is
~p(txl)txF/4 .
. Notice t h a t t h i s n u m b e r is o f l e n g t h p o l y n o m i a l in I x l , and t h e r e f o r e
our construction produces a nondeterministic Turing machine N w h i c h still o b e y s a
p o l y n o m i a l b o u n d on t h e d e p t h of all c o m p u t a t i o n s . It is t h i s g r o w t h o f t h e k(i)~s,
a necessary ingredient for our arguments, which limits t h e a p p l i c a b i l i t y of o u r
p r o o f t o t h e case o f l o g a r i t h m i c a l l y m a n y q u e r i e s .

We shall a r g u e t h a t t h e a l g o r i t h m a b o v e accepts x i f f M does. We shall show,


b y i n d u c t i o n on i, t h a t t h e n u m b e r n in t h e b e g i n n i n g of t h e i t h i t e r a t i o n of t h e
main loop o f t h e a l g o r i t h m A d e n o t e s t h e n u m b e r o f a c c e p t i n g leaves o f t h e c o m p u -
t a t i o n s u b t r e e o f N, w h i c h c o r r e s p o n d s to t h e c o m p u t a t i o n s u b t r e e o f M s t a r t i n g a t
t h e ith q u e r y . T h i s c e r t a i n l y holds f o r i = 1. Assume now t h a t i t holds a f t e r t h e
first i-1 i t e r a t i o n s . Suppose t h a t t h e ith q u e r y has a n s w e r " n o " . T h i s means t h a t
t h e r e is no a c c e p t i n g p a t h o f M' on t h e q u e r i e d x ' . Since such p a t h s a r e t h e o n l y
p a t h s in t h e s u b t r e e o f N w h i c h a r e n o t m u l t i p l i e d b y a m u l t i p l e o f k ( i ) , and since
t h e n u m b e r of such p a t h s c a n n o t e x c e e d k ( i ) ~ l , this is e q u i v a l e n t to s a y i n g t h a t
t h e v a l u e o f n b e f o r e t h e i t h i t e r a t i o n ( b y i n d u c t i o n h y p o t h e s i s t h e t o t a l n u m b e r of
such paths) is d i v i s i b l e e x a c t l y by k(i). Thus t h e THEN branch o f t h e t e s t is
taken, and t h e new v a l u e o f n is n DIV k ( i ) 2, w h i c h is e x a c t l y t h e n u m b e r o f ac-
274

c e p t i n g c o m p u t a t i o n s in t h e s u b t r e e of N c o r r e s p o n d i n g to C o . T h i s is because t h e
growth of t h e k ( i ) l s is such t h a t t h e t o t a l n u m b e r of leaves in t h e s u b t r e e o f N
c o r r e s p o n d i n g to C O ( o r f o r t h a t m a t t e r to C1) is less t h a n k ( i ) . S i m i l a r l y , if t h e
answer to the ith query is " y e s " , t h e n t h e ELSE b r a n c h is t a k e n , and n becomes
t h e n u m b e r o f a c c e p t i n g leaves in a s u b t r e e of N t h a t c o r r e s p o n d s t o C 1. T h e i n -
d u c t i o n is c o m p l e t e .

Therefore, after the last execution of the loop, the value of n is the number
of accepting computations of M after the last oracle step. This number is of course
1 or 0, depending on whether x is accepted by M or not. QED.

Notice t h a t we can p r o v e t h e same w a y a s t r o n g e r r e s u l t , namely that P can


simulate a l o g a r i t h m i c n u m b e r of q u e r i e s from PP. PP is d e f i n e d as t h e class of
l a n g u a g e s L f o r w h i c h t h e r e is a n o n d e t e r m i n i s t i c T u r i n g machine M such t h a t all
c o m p u t a t i o n s of M on i n p u t x h a v e l e n g t h e x a c t l y p ( I x l ) f o r some p o l y n o m i a l p ( . ) ,
and L = { x I C O U N T ( M , x ) > 2p(Ixl)'t}." PP is k n o w n to c o n t a i n NP [ G I ] .

4. PARITY COUNTING

A v a r i a n t of t h e p r o o f t e c h n i q u e o f t h e p r e v i o u s section can be used t o show t h e


following result:

eP
THEOREM 2: OP = OP •

PROOF: Let L be a l a n g u a g e r e c o g n i z e d b y a p a r i t y machine M w h i c h uses as an


oracle another parity machine M'. We shall design a parity machine N w h i c h ac-
cepts L with no o r a c l e s . N is p r o g r a m m e d e x a c t l y l i k e M, except in t h e o r a c l e
steps. S u p p o s e t h a t M is a t an o r a c l e s t e p w i t h q u e r y ( M ' , x ' ) , and l e t C t be t h e
configuration corresponding to a "yes" answer, and Co t o "no". At this query
s t e p , N does t h e f o l l o w i n g :

CHOOSE(APPEN D( I D o ( M ' , x ' ) , C 1 ) , APPEN D( C HOOSE( I D o ( M ' , x ' ) , a c c e p t ) , C o ) ) .

In w o r d s , t h e n u m b e r o f a c c e p t i n g leaves of C 1 is m u l t i p l i e d b y t h e n u m b e r of
a c c e p t i n g leaves of M' on x ' , w h e r e a s t h e n u m b e r of a c c e p t i n g leaves of C O is m u l -
t i p l i e d b y t h a t of M' on x ' p l u s o n e .
275

We now claim t h a t N accepts x i f f M does. To see t h i s , notice t h a t each leaf of the


computation of M c o r r e s p o n d s to a number of leaves in the computation of N which
is t h e p r o d u c t of as many numbers as t h e r e are oracle steps i r the computation
leading to the leaf. If t h e path leading to t h e leaf c o r r e s p o n d s to t h e c o r r e c t
a n s w e r to t h e q u e r y , then t h e m u l t i p l i c a n t is o d d , o t h e r w i s e i t is even. So, the
leaf c o n t r i b u t e s an odd n u m b e r to t h e total c o u n t (and t h u s i t is t a k e n i n t o ac-
c o u n t as an a c c e p t i n g c o m p u t a t i o n ) i f f i t c o r r e s p o n d s to c o r r e c t answers t o all t h e
q u e r i e s asked along t h e p a t h . It follows t h a t t h e total n u m b e r of leaves of N is
odd i f f t h e total n u m b e r of leaves of M, c o r r e s p o n d i n g t o c o r r e c t sequences of
oracle answers - t h a t is, t h e leaves of M t h a t are f i n a l l y counted - is o d d . QED.

REFERENCES

[An] D. A n g l u i n "On c o u n t i n g problems and the p o l y n o m i n a l - t i m e h i e r a r -


chy", T h e o r e t i c a l C o m p u t e r Science 12 (1980), p p . 161-173

[GJ] M.R. Garey, D.S. Johnson Computers and I n t r a c t a b i l i t y : A Guide


to t h e T h e o r y of NP-completeness, Freeman, 1979.

[Gi] J. Gill "Computational c o m p l e x i t y of p r o b a b i l i s t i c T u r i n g machines",


SIAM J. Computing 6 (1977), p p . 675-695.

[LP] H . R . Lewis, C . H . Papadimitriou Elements of the T h e o r y of Compu-


t a t i o n , P r e n t i c e - H a l l , 1981.

[Pa] C . H . Papadimitriou " T h e c o m p l e x i t y of unique s o l u t i o n s " , Proc. 13th


FOCS Conference, 1982, to a p p e a r .

[PY] C.H. Papadimitriou, M. Y a n n a k a k i s " T h e c o m p l e x i t y of facets (and


some facets of c o m p l e x i t y " , Proc. 14th STOC, p p . 255-260, 1982.
Also to a p p e a r in JCSS.

[Si] J. Simon "On t h e d i f f e r e n c e between one and many" Proc. 4th


I n t e r n . Colloquium on Automata1 Lan~luages and Programming ,
p p . 480-491, 1977.

[st] L.J. Stockmeyer "The polynamiat-time hierarchy", T h e o r e t i c a l Com-


p u t e r Science, 3 (1977), p p . 1-22.

[Val ] L . G . V a l i a n t " T h e c o m p l e x i t y of c o m p u t i n g t h e p e r m a n e n t " , Theore-


tical C o m p u t e r Science, 8 (1979), p p . 181-201.

[Va2] L.G. Valiant, p r i v a t e communication, A u g u s t 1982.

You might also like