Quantum Zero-Error Algorithms Cannot be Composed
Harry Buhrman
CWI and U. of Amsterdam
buhrman wi.nl
Ronald de Wolf
CWI
rdewolf wi.nl
Abstra t
Weexhibittwobla k-boxproblems,bothofwhi hhaveaneÆ ientquantumalgorithmwith
zero-error,yetwhose ompositiondoesnothaveaneÆ ientquantumalgorithmwithzero-error.
Thisshowsthat quantum zero-erroralgorithms annot be omposed. Inora leterms,wegive
arelativizedworldwhereZQP ZQP
6=ZQP, while lassi allywealwayshaveZPP ZPP
=ZPP.
Keywords: Analysisofalgorithms. Quantum omputing. Zero-error omputation.
1 Introdu tion
We an denea \zero-error" algorithm of omplexityT intwo dierent butessentially equivalent
ways: either as an algorithm that always outputs the orre t value with expe ted omplexity T
(expe tationtaken overtheinternalrandomnessofthealgorithm),orasanalgorithmthatoutputs
the orre tvaluewithprobabilityatleast1=2,neveroutputsanin orre tvalue,and runsinworst-
ase omplexity T. Expe tation is linear, so we an ompose two lassi al algorithms that have
an eÆ ient expe ted omplexity to get another algorithm with eÆ ient expe ted omplexity. If
algorithm A uses an expe ted numberof a appli ationsof B and an expe ted numberof a 0
other
operations,thenusingasubroutinefor B thathasan expe tednumberofb operationsgivesA an
expe tednumberofab+a 0
operations. In termsof omplexity lasses, we have
ZPP ZPP
=ZPP;
where ZPP is the lass of problems that an be solved by a polynomial-time lassi al zero-error
algorithm. Thisequality learlyrelatives, i.e., itholdsrelative to anyora le A.
Inthispaperweshowthatthisseeminglyobvious ompositionfa tdoesnot holdinthequantum
world. We exhibitbla k-box(query omplexity)problemsg and h thatare botheasy to quantum
omputeintheexpe tedsense,yetwhose ompositionf =g(h;:::;h)requiresaverylargeexpe ted
numberofqueries. In omplexityterms, we exhibitanora le Awhere
ZQP ZQP
A
6=ZQP A
;
where ZQP is the lass of problems that an be solved by a polynomial-time quantum zero-error
algorithm. This result is somewhat surprising, be ause exa t quantum algorithms an easily be
omposed, and so an bounded-error quantum algorithms. Moreover, it is also easy to use a
quantumzero-error algorithmas asubroutineina lassi al zero-erroralgorithm. That is
EQP EQP
=EQP and BQP BQP
=BQP and ZPP ZQP
=ZQP;
relativized aswellasunrelativized.
Partiallyfundedbyproje tsQAIP(IST{1999{11234)andRESQ(IST-2001-37559) oftheIST-FETprogramme
oftheEC.
We assume familiaritywith omputational omplexity theory [9℄ and quantum omputing [8 ℄. In
this se tion we brie y introdu e the \modes of omputation" that we are onsidering. Let f be
some (possibly partial) Boolean fun tion with set of inputs X = X
0 [X
1
, where f(X
0
) = 0 and
f(X
1
)=1. LetP
b
(x)be theprobabilitythatalgorithmAoutputsbitboninputx. Wedenefour
modes of omputation:
1. A isan exa t algorithm forf ifP
1
(x)=1forall x2X
1 and P
0
(x)=1 forallx2X
0
2. A is azero-error algorithm forf ifP
1
(x)1=2 and P
0
(x)=0 for all x2X
1
(assume there
isa thirdpossibleoutput\don't know"), and P
0
(x)1=2 and P
1
(x)=0forall x2X
0
3. A is a bounded-error algorithm forf if P
1
(x) 2=3 forall x 2X
1
, and P
0
(x) 2=3 for all
x2X
0
4. A is a nondeterministi algorithm for f if P
1
(x) > 0 for all x 2 X
1
, and P
1
(x) = 0 for all
x2X
0
Notethatanexa talgorithmisazero-erroralgorithm,andazero-erroralgorithmisabounded-error
algorithm aswellasa non-deterministi algorithm.
In the setting of query omplexity, f is an N-bit Boolean fun tion, so X
0 [X
1
f0;1g N
. We
an only a essthe inputx2f0;1g N
by making queriesto its bits. A query isthe appli ation of
theunitarytransformationO
x
that maps
O
x
:ji;b;zi7!ji;bx
i
;zi;
where i2 [N℄ and b 2 f0;1g. The z-part orresponds to the workspa e, whi h is not ae ted by
the query. A T-queryquantum algorithm has theform A =U
T O
x U
T 1
O
x U
1 O
x U
0
,where the
U
k
arexed unitarytransformationsindependentof x. The nal state Aj0i dependson x via the
T appli ations ofO
x
. The output of thealgorithm is determinedbymeasuring thetwo rightmost
qubitsofthenalstate. Let'ssaythatiftherightmostbitis1thenthealgorithm laimsignoran e
(\don't know"), and if it is 0 then the next-to-rightmost bit is the output bit. We refer to the
survey[3 ℄ formore detailsabout lassi aland quantum query omplexity.
WewilluseQ
E (f),Q
0 (f),Q
2
(f),NQ(f)todenotetheminimalquery omplexityofaquantum
algorithm for f in the four above modes, respe tively. A ordingly, Q
E
(f) is the exa t quantum
query omplexity of f, Q
0
(f) is zero-error quantum query omplexity, Q
2
(f) is bounded-error
quantumquery omplexity,and NQ(f) isnondeterministi quantum query omplexity. Notethat
bydenitionwe immediatelyhave
Q
2
(f)Q
0
(f)Q
E
(f) and NQ(f)Q
0
(f)Q
E (f):
Our proofs willuse the lose onne tion between quantum query omplexity and polynomials [2℄.
An N-variate multilinear polynomial p is a fun tion of the form p(x) = P
S[N℄
a
S x
S
, where a
S
is real and x
S
= Q
i2S x
i
. Its degree deg(p) =maxfjSj :a
S
6=0g is the largest degree among its
monomials. The next lemma [6,11 ℄ onne ts nondeterministi omplexitywithpolynomials:
Lemma 1 Thenondeterministi quantum query omplexityNQ(f) of f equals theminimal degree
among all multilinear polynomials p su h that
1. p(x)6=0 for all x2X
1
0
This lemma improves the query omplexity lower bound by a fa tor of 2, ompared to the
\standard" polynomialmethod [2 ℄.
Thesettingof omputational omplexity anbedenedeitherintermsofTuringma hinesorof
uniform ir uitfamilies. Herewe deneEQP,ZQP,BQP,and NQPto bethe lassesoflanguages
for whi h there exist polynomial-timequantum algorithms in theabove four modes, respe tively.
We restri t attention to algebrai amplitudesforthese lasses.
Forexample,NQP(\quantumNP")istakentobethe lassoflanguagesLforwhi hthereexists
aneÆ ientquantumalgorithmthathaspositivea eptan eprobabilityoninputxix2L[1 ℄. This
lass was shown to be equalto the lassi al ounting lass oC
=
P [5, 12 ℄. There isan alternative
denition of quantum NP based on veri ation of quantum erti ates [7 , Chapter 14℄ whi h we
willnotdis usshere. Wesimilarlydenethe lassesEQP A
,et ., whenwe havea essto anora le
A for some language, and EQP S
=[
A2S EQP
A
,et ., when S is a set of ora les. By denitionwe
immediatelyhave
EQPZQPBQP and EQPZQPNQP;
and these in lusionsalsohold relative to anyora leA.
3 The problem
Letm and n be even numbers. We rst dene thepartialBoolean fun tions g onn bitsand h on
2m bits,and then their ompositionf on N =2mn bits.
The fun tiong isjustthe onstant vs.balan edproblem ofDeuts hand Jozsa [4 ℄. Usingw(x)
to denote theHammingweight ofx2f0;1g n
,wedene:
g(x)= 8
<
:
1; if w(x)=0 ( onstant)
0; if w(x)=n=2(balan ed)
undened otherwise
It is well known that there existsan exa t 1-query quantum algorithm for thisproblem[4℄, while
any lassi aldeterministi orevenzero-error algorithm needsn=2+1queries.
The fun tionh isa zero-error samplingproblem. Let
A
1
= f0 m
x:x2f0;1g m
;m=2w(x)mg
A
0
= fx0 m
:x2f0;1g m
;m=2w(x)mg
h(x) = 8
<
:
1; ifx2A
1
0; ifx2A
0
undened otherwise
Clearly h has a lassi al algorithm that always outputs the orre t answer and whose expe ted
number of queries is small. The algorithm just queries a random point in the rst m bits of its
inputandone inthese ond mbits,andoutputswhereitndsa1(ifitdoesso). Withprobability
1=2 it willindeednda 1,sotheexpe tednumberof repetitionsbeforeterminationis 2.
Letf on 2mnbitsbethepartialBoolean fun tionthatisthe ompositionofg andh. Inother
words,deningtheset of promiseinputsby
X
1
= A
0
A
0
| {z }
ntimes
X
0
= [fA
y1
A
yn
:y=y
1 :::y
n
2f0;1g n
;w(y)=n=2g
f(x)= 8
<
:
1; ifx2X
1
( onstant)
0; ifx2X
0
(balan ed)
undened otherwise
Forlater referen e,we willgivenames to thevariouspartsofthe 2mn-bitinputx:
x=
inputfor g
z }| {
inputfor h
z }| {
x (0;1)
|{z}
mbits x
(1;1)
|{z}
mbits
inputfor h
z }| {
x (0;2)
|{z}
mbits x
(1;2)
|{z}
mbits
input forh
z }| {
x (0;n)
|{z}
mbits x
(1;n)
|{z}
mbits
In words,f ontains ndierent h-fun tions,ea h withits own2m-bit input. Here x (0;i)
and x (1;i)
are two m-bit stringsthat together onstitute the input to the ith h-fun tion. The promise says
that the 2m-bit input x (0;i)
x (1;i)
always lies in A
0 or A
1
. The n bits h(x (0;i)
x (1;i)
), i = 1;:::;n,
oming outofthe nh-fun tionsare thenpluggedinto gto give the value forf. The promisesays
thatthese n bitsareeitherall 0 ( onstant)orhalf 0and half1 (balan ed).
Ourfun tionf isjustthe ompositionoftheproblemsgandh,ea hofwhi hneedsjustasmall
expe tednumberof queries. Yetbelowwe willshowthat anyquantumzero-error algorithm forf
willneedto make many queries. Even stronger,also a nondeterministi quantumalgorithm forf
requires manyqueries.
4 Lower bound for quantum zero-error algorithms
The nextlemma is ourmainte hni altool:
Lemma 2 Let p be a 2mn-variate multilinear polynomial su h that
1. p(x)6=0 for all x2X
1
2. p(x)=0 for all x2X
0
Then deg(p)min(n=2;m=2)+1.
Proof. We use the names for the various subparts of the 2mn-bit input that we introdu ed in
Se tion3. We assumewithoutlossofgeneralitythatforeveryi2[n℄andeverynon-zeromonomial
a
S x
S
inp,thesetS doesnotsimultaneously ontainvariablesfromx (0;i)
andfromx (1;i)
. Sin ethe
promiseon the inputssets either x (0;i)
orx (1;i)
to 0 m
, amonomial ontaining variablesfrom both
x (0;i)
and x (1;i)
evaluatesto 0anyway,soremovingitfromp willnotae t thetwopropertiesofp.
Suppose, byway of ontradi tion, that d = deg(p) min(n=2;m=2). By the rst property of
the lemma, p annot be identi ally zero, so it has to ontain at least one monomial. Consider a
monomial M = a
S x
S
in p with maximaldegree, so jSj = d. Consider some i 2 [n℄ su h that S
ontains variablesfrom x (1;i)
(and hen e, by the above assumption, no variables from x (0;i)
). We
nowxx (0;i)
to0 m
andxallnon-Svariablesinx (1;i)
to1. Sin ethereareatmostm=2S-variables
in total, this already sets at least m=2 bits in x (1;i)
to 1. A ordingly, we have x (0;i)
x (1;i)
2 A
1
for every setting of the S-variables. This for es the ith h-fun tion to value 1, without xing the
S-variables. Similarly we for e the other h-fun tions whose variables interse t with S: if S has
variablesfrom x (1;j)
then we for e the jth h-fun tionto 1, and if S hasvariables from x (0;j)
then
we for e it to 0. Sin e jSjn=2, thisfor es at most n=2 of theh-fun tions. A ordingly,we an
a settingof theoverall2mn-bit inputthat isinX
0
(balan ed),withoutxingtheS-variables.
LetqbetheremainingpolynomialinthedS-variables. NomatterhowwevarytheS-variables,
the overall inputto p remainsin X
0
(balan ed). Hen e q must be zero on all Boolean settings of
itsvariables. It iseasyto seethattheonlypolynomialsatisfyingthis onstraintistheone without
anymonomials. Butq still ontainsthemonomialM,be ause being ofdegree d,M annot an el
against othermonomialswhen we xthenon-S variables. Thisis a ontradi tion. 2
This lemma is exa tly tight. First, there is a polynomial with the above properties of degree
n=2+1. For T a set of n=2+1 variables, ea h from a dierent x (0;i)
, deneq
T
to be the degree-
(n=2+1) polynomial that is the AND of these variables. If x 2 X
0
then q
T
will be 0 for all T,
and if x2X
1
then forat least one T we have q
T
=1. Hen e summing q
T
over all su h T gives a
polynomialpof degree n=2+1 su h thatp(x)=0 forx2X
0
and p(x)>0 forx2X
1 .
Se ond,therealsoisanappropriatepolynomialofdegreem=2+1. Letq
i
bethedegree-(m=2+1)
polynomialthat is the OR of the rst m=2+1 bitsof x (1;i)
. Then q
i
=1 ifx (0;i)
x (1;i)
2A
1 and
q
i
=0ifx (0;i)
x (1;i)
2A
0
. Deningpto bethedegree-(m=2+1) polynomialn=2 P
n
i=1 q
i
,wehave
p(x)=0 forx2X
0
and p(x)=n=2 forx2X
1 .
Combiningthepreviouslemma withLemma1 givesourmaintheorem:
Theorem 1 NQ(f)=min(n=2;m=2)+1.
Sin enondeterministi query omplexitylowerboundszero-error omplexity,wealsoobtainthe
zero-errorlowerboundQ
0
(f)min(n=2;m=2)+1. ThebestupperboundonQ
0
(f)thatweknow,
is min(2n;m) so thelower boundis tight up to small onstant fa tors. First, we know there is a
lassi alzero-error algorithmthat omputes anh-fun tionusingan expe ted numberof 2 queries;
we an use thisto ompute the rst n=2 h-fun tions in an expe ted number of n queries, whi h
suÆ es to omputef. Terminatingthis algorithm after 2n stepsgives usan algorithm that nds
the orre t outputwith probability1=2 (Markov's inequality), and laimsignoran e otherwise.
Se ond, there exists an exa t quantum algorithm for f that uses m queries. By querying the
rstm=2bitsinanh-inputwe ande idewhetherthathtakesvalue0or1. By opyingtheoutput
and reversing the omputationwe an do thisexa t omputation leanly (resetting all workspa e
to 0) usingm queries. PuttingtheDeuts h-Jozsaalgorithm on topofthisgivesan m-queryexa t
quantumalgorithm forf.
Usinga standardtranslationof query omplexityresultsto ora les,we obtain
Theorem 2 There existsan ora le A su h that
EQP ZPP
A
6NQP A
;
hen ein parti ular
ZQP ZQP
A
6ZQP A
:
Proof. For a set A f0;1g
, we use A
=n
to denote the set of all n-bit strings in A, and we
identifythiswithits 2 n
-bit hara teristi ve tor. We will onstru t a setA su h that, forevery n
where2 n
=2m 2
forsome m(i.e. foreveryoddn),A
=n
isa validinputto f (wordof warning: the
`n'used here isnotthe `n'used earlier,but the`m' is;theinputlengthof f is now2m 2
). This A
indu esa language
L=f0 n
j2 n
=2m 2
forsome m andf(A
=n
)=1g:
1 2
bounds (say, M
i
has time bound p
i
(n) = n i
+i). Su h an enumeration exists be ause we an
assume without loss of generality that the ma hines only use algebrai amplitudes[1 , 5, 12 ℄. At
thestartofour onstru tion,A istheemptyset. Goingalongi=1;2;:::,forea h M
i
wewillpi k
aspe i inputlengthn
i
anddeneA
=n
i
insu h awaythatM A
i
willerr on0 n
i
,and hen eit will
nota ept L.
Consider M
i
. Itsrunningtimeis boundedby thepolynomialp
i
(n) intheinputlength. Letn
i
be thesmallestinputlength su h that (1) 2 n
i
=2m 2
for some m, (2)p
i (n
i
)m=2, and (3)n
i is
solargethatforallj <iwehavep
j (n
j )<n
i .
1
Sin eM
i
makesatmostp(n
i
)<m=2+1=NQ(f)
queriestothebitsofx=A
=n
i
,Theorem1impliesthatM
i
annotbeanondeterministi algorithm
for f. Hen e there exists some x 2 X
0 [X
1
where M
i
errs: either x 2 X
0
whileM
i
has positive
a eptan e probability when A
=n
=x; or x 2X
1
whileM
i
has zero a eptan e probabilitywhen
A
=n
i
=x. Dene A
=n
i
to bethatx. Thisensures thatM A
i
doesnota ept L.
Doing thisforallM
i
andllingtheyet-undenedlevels A
=n
byarbitrary promise-inputsto f,
we now have a language L that is a epted bynone of the M A
i
, hen e L 62NQP A
. On the other
hand, theDeuts h-Jozsa algorithmimpliesL2EQP ZPP
A
, sowe have ourseparation. 2
5 Con lusion
We proved thatthe ompositionof two problems thatare easy forzero-error quantum omputing
need not be easy itself. This ontrasts strongly with the ase of lassi al algorithms, and shows
thatour lassi alintuition aboutexpe ted runningtimedoesnot arry over verywellto quantum
algorithms. The probleminusinga zero-error algorithm asa subroutine ina quantum algorithm
seems to be thatwe annot reverse the omputation to obtainan answer withoutadditionalnon-
zero workspa e. This remaining non-zero workspa e then messes up later quantum interferen e
in the main program. Being able to ompose zero-error algorithms is a desirable property that
obviously holdsinthe lassi al world. Unfortunately,thispropertydoes nothold inthequantum
world.
Referen es
[1℄ L.M. Adleman,J. Demarrais,and M. A.Huang. Quantum omputability. SIAM Journal on
Computing, 26(5):1524{1540, 1997.
[2℄ R. Beals, H. Buhrman, R. Cleve, M. Mos a, and R. de Wolf. Quantum lower bounds by
polynomials. InPro eedings of 39th IEEE FOCS, pages352{361, 1998. quant-ph/9802049.
[3℄ H. Buhrman and R.de Wolf. Complexity measures and de ision tree omplexity: A survey.
Theoreti al Computer S ien e, 288:21{43, 2002.
[4℄ D.Deuts handR.Jozsa. Rapidsolutionofproblemsbyquantum omputation.InPro eedings
of the Royal So iety of London, volumeA439, pages 553{558, 1992.
1
Thisthird onditionensuresthatwhenwedeneA
=n
i
tothwartMi,thebehaviorofearlierMjsoninputlength
nj won'tbe hanged(be auseMjoninputlengthnj doesn't haveenoughtimetoquerystringsoflengthni).
quantum omputation is hard forthe polynomialhierar hy. In Pro eedings of the 6th Italian
Conferen eon Theoreti al Computer S ien e,pages 241{252, 1998. quant-ph/9812056.
[6℄ P. Hyer and R. de Wolf. Improved quantum ommuni ation omplexity bounds for dis-
jointness and equality. In Pro eedings of 19th Annual Symposium on Theoreti al Aspe ts of
Computer S ien e(STACS'2002), volume 2285 of Le ture Notes in Computer S ien e, pages
299{310. Springer,2002. quant-ph/0109068.
[7℄ A.Kitaev, A. Shen, and M. Vyalyi. Classi al and Quantum Computation. Ameri an Mathe-
mati alSo iety,2002.
[8℄ M.A.NielsenandI.L.Chuang.QuantumComputationandQuantumInformation.Cambridge
UniversityPress, 2000.
[9℄ C.H. Papadimitriou. Computational Complexity. Addison-Wesley,1994.
[10℄ R.deWolf.Chara terizationofnon-deterministi quantumqueryandquantum ommuni ation
omplexity.InPro eedingsof15thIEEEConferen eonComputationalComplexity,pages271{
278,2000. s.CC/0001014.
[11℄ R.deWolf. Nondeterministi quantumqueryandquantum ommuni ation omplexity. SIAM
Journal on Computing, 2002. Journalversionof partsof [10℄and [6 ℄.To appear.
[12℄ T.YamakamiandA.C-C.Yao.NQP
C
= o-C
=
P.InformationPro essingLetters,71(2):63{69,
1999. quant-ph/9812032.