Computational advantage from quantum-controlled ordering of gates Mateus Araújo,1,2 Fabio Costa,1,2 and Cˇaslav Brukner1,2 1 Faculty of Physics, University of Vienna, Boltzmanngasse 5, 1090 Vienna, Austria 2 Institute for Quantum Optics and Quantum Information (IQOQI), Austrian Academy of Sciences, Boltzmanngasse 3, 1090 Vienna, Austria (Dated: December22,2014) It is usually assumed that a quantum computation is performed by applying gates in a specific order. Onecanrelaxthisassumptionbyallowingacontrolquantumsystemtoswitchtheorderin whichthegatesareapplied. Thisprovidesamoregeneralkindofquantumcomputing,thatallows transformationsonblackboxquantumgatesthatareimpossibleinacircuitwithfixedorder. Herewe showthatthismodelofquantumcomputingisphysicallyrealizable,byproposinganinterferometric setupthatcanimplementsuchaquantumcontroloftheorderbetweenthegates. Weshowthatthis newresourceprovidesareductionincomputationalcomplexity: weproposeaproblemthatcanbe solved usingO(n) blackbox queries, whereas the best known quantum algorithm with fixed order betweenthegatesrequiresO(n2) queries. Furthermore, weconjecturethatsolvingthisproblemin aclassicalcomputertakesexponentialtime,whichmaybeofindependentinterest. 4 1 0 Introduction.—Ausefultooltocalculatethecomplex- tary matrices and the promise that they satisfy one out 2 ity of a quantum algorithm is the blackbox model of of n! specific properties, find which property is satis- c quantum computation. In this model, the input to the fied. The essential resource to solve this problem is the e computationisencodedinaunitarygate–treatedasa quantum control over the order of n blackboxes, first D blackbox – and the complexity of the algorithm is the introduced in Ref. [5]. We show that, by using this re- numberoftimesthisgatehastobequeriedtosolvethe source,theproblemcanbesolvedwithO(n)queriesto 9 1 problem. the blackboxes, while the best known algorithm with Typically, black-box computation is studied within fixedorderrequiresO(n2) queries. Furthermore,while h] the quantum circuit formalism [1]. A quantum circuit both quantum methods of solving the problem run in p consists of a collection of wires, representing quantum polynomial time, the best known classical algorithm to - systems,thatconnectboxes,representingunitarytrans- solve it runs in exponential time, which may be of in- t n formations. In this framework, wires are assumed to dependentinterest. a connect the various gates in a fixed structure, thus the We further discuss a possible interferometric imple- u order in which the gates are applied is determined in mentation of the protocol. For the superposition of the q [ advance and independently of the input states. It was orderofjusttwogates,arealizationwithcurrentquan- first proposed in [2] that such a constraint can be re- tumopticstechniquesispossible. Forahighernumber 3 laxed: onecanconsidersituationswherethewires,and of gates practical implementations become more chal- v 7 thustheorderbetweengates,canbecontrolledbysome lenging. 2 extra variable. This is natural if one thinks of the cir- Algorithm.—The quantum control of the order be- 1 cuit’s wires as quantum systems that can be in super- tween n unitary gates can be formalized by introduc- 8 position. ing the n-switch gate. As in Ref. [5], we consider a . 1 d-dimensional target system, initialized in some state Such “superpositions of orders” allow performing 40 information-theoretical tasks that are impossible in the |ψ(cid:105),andann!-dimensionalcontrolsystem. Let{Ui}0n−1 1 quantum circuit model: it was shown in [3] that it is beasetofunitariesand v: pcoomssmibuletetoordaencitdiceomwhmeuthteerwaitphaairsionfgblelaucksebooxfeuancihtaurnieis- Πx =Uσx(n−1)...Uσx(1)Uσx(0) (1) i X tary,whereasinacircuitwithafixedorderatleastone for some permutation σ , where x = 0,...,n!−1 is a x r oftheunitariesmustbeusedtwice. (Thesametaskwas chosen labelling of permutations1. Then the n-switch a considered in a quantum optics context in [4], where a S is a controlled quantum gate: its effect is to apply n lessefficientprotocolwasfound.) theproductofunitariesΠ tothestate|ψ(cid:105)conditioned x It was not known, however, whether this advantage onthevalueofthecontrolregister |x(cid:105). Insymbols, can be translated into more efficient algorithms for S |x(cid:105)|ψ(cid:105) = |x(cid:105)Π |ψ(cid:105). (2) quantum computing, i.e., if a quantum computer that n x can control the order between gates can solve a com- putational problem with asymptotically less resources thanaquantumcomputerwithfixedcircuitstructure. 1More preciselly, σx(j) is the image of the jth element under the Herewepresentsuchaproblem: givenasetofnuni- permutationx 2 Using this gate we can introduce an algorithm that Usingthepromise Π = ωxyΠ wegetthat x 0 exploits the quantum control of orders to achieve a re- duction in query complexity for the solution of a spe- p = 1 (cid:13)(cid:13)(cid:13)n∑!−1ωx(y−s)Π |ψ(cid:105)(cid:13)(cid:13)(cid:13)2 = δ , (9) cific problem. The algorithm is based on the standard s n!2(cid:13)(cid:13)x=0 0 (cid:13)(cid:13) sy Hadamardtest. Theideaistoinitiatethecontrolsystem in a state corresponding to a uniform superposition of thatis, ifpropertyP istrue, theresultofthemeasure- y all permutations, apply S , and then measure the con- ment is going to be y with probability one, so we can n trol system in the Fourier basis. With a suitable choice find out which property the unitaries have in a single of the unitaries, we can make the result of this mea- runoftheprotocol. surement deterministic and, since there are n! different We should notice that the problem is not trivial, i.e. results, this meansthat wecan differentiate between n! there exist, for every n, infinitely many sets of unitary differentpropertiesof n unitaries. matrices that satisfy each of the n! properties P (see y To be more precise, let ω = ei2nπ!. We say that the set AppendixA)Theproblem,andthecorrespondingpro- ofunitaries {U}n−1 haspropertyP ifitistruethat tocol, can be also modified to tolerate possible experi- i 0 y mental error. This modification is shown in Appendix ∀x Πx = ωxyΠ0, (3) B. Query Complexity.–We are interested in determining for the given y. For example, property P is the prop- erty that Π = Π for all x, i.e., that all0the matrices thenumberoftimesthattheunitariesUi mustbeused x 0 to run the algorithm. Clearly this depends only on commutewitheachother. theimplementationofthen-switchgate,sincetheuni- Note that it is not possible to satisfy property P if 1 taries are not used anywhere else. As proposed in [2], the dimension of the unitaries d is less than n!. To see theswitchcaninprinciplebeimplementedbyadding that, consider x = y = 1, and take the determinant on bothsidesofequation(3): quantum control to the connections between the uni- taries. In such an implementation it is sufficient to use detΠ = ωddetΠ . (4) a single copy of each unitary, while the control system 1 0 determinestheorderinwhichthetargetsystempasses SincedetΠ =detΠ ,itfollowsthatωd =1,andthere- x 0 throughtheunitaries. fore d mustbeatleast n!. Since the implementation with quantum control of The computational problem is defined as follows: the connections between gates is explicitly outside the given a set {Ui}0n−1 of unitary matrices of dimension quantumcircuitformalism,wecannotsimplycalculate d ≥ n!,decidewhichofthepropertiesPy issatisfiedby the number of uses of the unitaries by counting the this set, given the promise that one of these n! proper- number of times they appear in a circuit. Neverthe- tiesissatisfied. less, we can formulate the notion of “gate uses” in a The protocol for solving this problem is the follow- precise, operational, way. Imagine we append, to each ing: weinitializethetargetsysteminanystate |ψ(cid:105),and gate, an additional “flag” quantum system that counts the control system in the state |C(cid:105) which corresponds thenumberoftimesthatgateisused. Thiscanbedone toanequalsuperpositionofallpermutations: inareversibleway: thej-thflagisinitializedinthestate |0(cid:105) and,whenevertheunitaryU isused,itisupdated |C(cid:105)|ψ(cid:105) = √1 n∑!−1|x(cid:105)|ψ(cid:105). (5) thrjoughtheunitarytransformatiojn|f(cid:105) → |f +1(cid:105) . Itis j j n! x=0 easy to see that, after applying the n-switch, the state Then,weapplythe n-switch: of the flags factorizes, with each flag in the state |1(cid:105) . j Accordingtothisdefinition,thetotalnumberofqueries S |C(cid:105)|ψ(cid:105) = √1 n∑!−1|x(cid:105)Π |ψ(cid:105). (6) necessarytorunthealgorithmis n. n x n! x=0 In comparison, the optimal simulation of the n- switch gate with a fixed circuit has query complex- Now we apply the Fourier transform over Zn! to our ity Ω(n2) 2. To see this, first note that one can as- controlqudit sume without loss of generality that all blackbox uni- Fn!Sn|C(cid:105)|ψ(cid:105) = 1 n∑!−1|s(cid:105)ω−xsΠx|ψ(cid:105). (7) ttawroiesblaarcekbaopxpelisedareeaacphpilnieaddiniffperaernaltletilm, weestceapn, sailnwcaeyisf n! x,s=0 introduce a time delay between them, without chang- andmeasurethecontrolquditinthecomputationalba- ing the action of the circuit. More technically, a circuit sis,withoutcomeprobabilities p = 1 (cid:13)(cid:13)(cid:13)n∑!−1ω−xsΠ |ψ(cid:105)(cid:13)(cid:13)(cid:13)2. (8) 2Wesaythat f(n)isΩ(g(n))ifthereexistsaconstant Msuchthat s n!2(cid:13)(cid:13)x=0 x (cid:13)(cid:13) f(n)≥Mg(n)forsufficientlylargen. 3 defines a partial order for its gates, which can always quantum circuit: both run in time O(n) (see Appendix be completed into a total order. Then, let {A }m−1 be C). i 0 the m blackbox unitaries appearing in the circuit, with It is interesting, nevertheless, to compare the time Aj ∈ {Ui}0n−1, queried in the order A0 (cid:22) ··· (cid:22) Am−1. required to solve the problem between quantum and From the Appendix B of Ref. [2], it follows that it is classical computers. If we assume that the unitaries U i only possible to apply the Π to |ψ(cid:105) if the unitaries aredecomposedinapolynomialamountofelementary x U ,...,U arepresentinthecircuitintheorder gates, they can be given as an input of polynomial size σx(0) σx(n−1) definedbyσ . Thelowerboundonthequerycomplex- to a classical algorithm, and it makes sense to compare x ityisthentheminimal mforwhichall n!permutations theclassicalandquantumrunningtimes. of {U0,...,Un−1} are present as subsequences of the As argued above, the problem of determining y re- sequence {A0,...,Am−1}. duces to the problem of calculating the relative phase Itturnsoutthatthisisanopenproblemincombina- between Π and Π , which may differ by the permuta- 1 0 torics [6, 7]. However, it is known that the optimal m tionofasinglepairofunitaries. However,asdiscussed respectsthebounds before, the dimension of the unitaries must be at least (cid:24) (cid:25) n! for this problem to be nontrivial, and it seems un- 7 19 n2−C(cid:101)n7/4+(cid:101) ≤ m ≤ n2− n+ likelythatonecouldextractthephasefromtheseexpo- 3 3 nentiallylargeunitarymatricesonaclassicalcomputer for any (cid:101) > 0, where C(cid:101) is a constant that depends on in polynomial time. On the other hand, the running (cid:101). Thisconcludestheproof. time of the quantum algorithm is clearly polynomial It is also possible to construct a quantum circuit that for unitaries decomposed in a polynomial amount of simulates the n-switch gate from such a sequence. We elementary gates. Therefore we conjecture that for the shall,however,refrainfromdoingso. Instead,forcom- problem presented there is an exponential separation pleteness,wepresentasimplecircuitthatsimulatesthe between classical and quantum complexity, which may n-switch gate using m = n2 queries in the Appendix beofindependentinterest. C. Note that our algorithm is based on the quantum Of course, it might not be necessary to use the n- Fourier transform, as are several algorithms that show switch gate in order to determine which property P y an exponential separation between classical and quan- theunitariessatisfy. Forexample,itispossibletosolve tumcomplexity,buttheredoesnotappeartobeamore the problem by directly measuring the phase obtained direct connection with specific classes of quantum al- when applying the permutation σ . Since Π = ωyΠ , 1 1 0 gorithms,suchasthosethatsolvethehiddensubgroup this is sufficient to determine y. However, this protocol problem(seeAppendixD). can work only if the relative phase is measured with an error smaller than 2π, and for blackbox unitaries Physical implementation.—In Ref. [2] it was proposed n! to apply the superposition principle to the physical this can only be done with an exponential amount of componentsofaquantumcomputerthatdeterminethe queries. order between gates. Since this requires a quantum This is the case, for example, for Kitaev’s phase es- timation algorithm [8]. This algorithm is not usually control over macroscopic systems, it seems outside of the reach of current technology and could be practi- applied to blackbox unitaries, but this can be done us- ingthetechniquesin[9–11]. Inthiscase,tocalculatethe cally unfeasible. Here we propose an implementation ofthen-switchthat,althoughexperimentallychalleng- phasewiththerequiredO(nlogn)bitsofprecision,one ing,mightbefeasible. would need to implement the matrices controlled-U2k, i We first consider an optical implementation of a 2- with k = 1,...,nlogn, which would require an expo- switch for 2×2 unitaries, illustrated in Fig. 1 (this nentialamountofqueriestotheblackboxesU. Evenif i implementation was independently developed in [12]). one assumes that it is possible to apply controlled-U2k i The control system is the polarization of a photon and efficiently – a necessary assumption to make Kitaev’s the target system some internal degree of freedom of algorithmefficient–onewouldneedO(nlogn)queries the same photon, such as space bins, time bins, or an- to each Ui2k oracle. Since there are n unitaries Ui, the gular momentum modes. If the photon is prepared in query complexity would be O(n2logn), which is still a horizontally polarized state |H(cid:105), it is transmitted by lessefficientthansimulatingthe n-switchwithafixed both polarizing beam splitters (PBSs), resulting in the circuit. application of the unitary U first and of U second. A 0 1 Running time.—Instead of query complexity we may photon in a vertically polarized state |V(cid:105) is reflected want to consider the running time of the algorithm. If by both PBSs, thus the two unitaries are applied in we assume that this is dominated by applying the uni- the reversed order. For an arbitrary polarization state taries U, then there is no difference between the im- α|H(cid:105)+β|V(cid:105), the photon exits the interferometer in the i plementation with superposition of orders or the fixed state α|H(cid:105)U U |ψ(cid:105)+β|V(cid:105)U U |ψ(cid:105), which corresponds 1 0 0 1 4 plementationofthen-routeristhatitisnotscalablein U 0 anobviousway,sinceitrequiresencodinganexponen- tial number of degrees of freedom in a single photon (n!forthecontrolsystemand,asarguedbefore,atleast PBS U1 PBS n! for the target system). A scalable implementation could be obtained by encoding the degrees of freedom in O(nlogn) particles, each carrying a constant num- ber of degrees of freedom (e.g., one qubit each). The Figure1. Linearopticalimplementationofthe2-switch. The mainchallengeisthentoimplementarouterthat,con- unitaries U0 and U1 act on internal degrees of freedom of a ditionedonthemultiparticlestate,coherentlydirectsall single photon, such as space bins, time bins, or angular mo- theparticlesinaspecificmode. Thisisinprinciplepos- mentum modes. The polarization state of the photon deter- minestheorderinwhichtheunitariesareapplied. Aphoton sibleiftheparticlesareboundtogether,e.g.asatomsin with polarization |H(cid:105) is transmitted by the polarizing beam amolecule. Recentprogressinmatter-waveinterferom- splitters(PBSs),sothatU0 isappliedbeforeU1. Foraphoton etrysuggeststhatsuchaquantumcontrolofcomposite withpolarization|V(cid:105),reflectedbythePBSs,U isappliedfirst systemscouldbeachievableinthefuture[15,16]. 1 andU0 second. Other realizations of superposition of orders, based on different models of computation, could also be pos- sible. For example, an implementation of the 2-switch withinadiabaticquantumcomputingwasproposedre- cently[17]. Conclusion.—We have shown that extending the quantum circuit model by allowing quantum control of the order between gates provides a reduction in the number of queries needed to solve a computational problem. Furthermore, we have proposed a physically realizable experimental scheme to implement such a Figure 2. Implementation of the n-switch (in the figure, control. n = 3). Both control and target, in state |x(cid:105) and |ψ(cid:105) respec- While the reduction is only polynomial, and thus tively, are encoded in a single (possibly multi-particle) sys- tem. When the system enters the n-routers (Rn) in mode j, doesnotcreateanewcomplexityclass,theresultshows itisredirectedtomodeσx(j)andtheunitaryUσx(j)isapplied that extending the quantum circuit model is possible to |ψ(cid:105). R−1 performs the inverse permutation and sends the and can provide a computational advantage. Besides, n system to mode j+1 of the first router. In this way, a sys- the computational problem introduced has no known tementeringmode0ofthefirstrouter,eventuallyexitsmode efficient solution by a classical algorithm, which may n−1ofthesecondrouterwithtargetinthestateΠx|ψ(cid:105). beofindependentinterest. Other extensions of the quantum circuit model of blackbox computation have been proposed [11]: it was totheoutputofthe2-switch. shown recently [11, 18, 19] that a quantum circuit can- The extension of this scheme to the general case of not apply blackbox gates conditioned on the state of a an n-switch can be obtained with a generalization of control qubit. However, such a control is physically re- the PBS to an element, which we call n-router, with alizable [9, 10] and therefore should be allowed by the n input modes and n output modes (see Fig. 2). If the formalism. It is also intriguing to ask what computa- control system is in a state |x(cid:105), the n-router sends the tional advantages might be achieved once the restric- input mode j to the output mode σx(j). The unitary tionsimposedbythefixedcausalstructureofquantum Uσx(j) is applied to a system in the mode σx(j), which mechanicsarerelaxed[20]. then enters a second router that performs the inverse permutation. Theoutputmode jofthesecondrouteris thendirectedtotheinputmode j+1ofthefirstone. It ACKNOWLEDGMENTS isstraightforwardtocheckthatasystementeringmode 0ofthefirstrouterinthestate|x(cid:105)|ψ(cid:105)exitsmoden−1of This work was supported by the Austrian Science the second router in the state |x(cid:105)Πx|ψ(cid:105). (In Appendix Fund (FWF) (Project W1210 Complex Quantum Sys- E we show how to construct an n-router with O(n2) tems (CoQuS), Special Research Program Foundations binaryrouters.) and Applications of Quantum Science (FoQuS), and This higher-dimensional routing can be achieved, Individual project 24621), the European Commission for example, with orbital angular momentum of light Project RAQUEL, FQXi, and by the John Templeton [13, 14]. However, the main limitation of an optical im- Foundation. 5 [1] D.Deutsch,“QuantumComputationalNetworks,”Proc. “Parallelizedadiabaticgateteleportation,” R.Soc.Lond.A425,73–90(1989). arXiv:1310.4061 [quant-ph]. [2] G.Chiribella,G.M.D’Ariano,P.Perinotti,and [18] A.Soeda,“Limitationsonquantumsubroutine B.Valiron,“Quantumcomputationswithoutdefinite designingduetothelinearstructureofquantum causalstructure,”Phys.Rev.A88,022318(2013), operators,”.TalkatICQIT2013. arXiv:0912.0195 [quant-ph]. [19] J.Thompson,M.Gu,K.Modi,andV.Vedral,“Quantum [3] G.Chiribella,“Perfectdiscriminationofno-signalling Computingwithblack-boxSubroutines,” channelsviaquantumsuperpositionofcausal arXiv:1310.2927 [quant-ph]. structures,”Phys.Rev.A86,040301(2012), [20] O.Oreshkov,F.Costa,andCˇ.Brukner,“Quantum arXiv:1109.5154 [quant-ph]. correlationswithnocausalorder,”Nat.Commun.3,1092 [4] E.Andersson,J.Bergou,andI.Jex,“Comparisonof (2012),arXiv:1105.4464 [quant-ph]. unitarytransformsusingFransoninterferometry,”J. Mod.Opt.52,1485–1494(2005). [5] T.Colnaghi,G.M.D’Ariano,S.Facchini,and AppendixA:Existenceproofofthesetsofunitaries P.Perinotti,“Quantumcomputationwith programmableconnectionsbetweengates,”Phys.Lett.A We need to show that for every y there exists a set 376,2940–2943(2012),arXiv:1109.5987 [quant-ph]. of unitaries that satisfies property P , otherwise the [6] D.KleitmanandD.Kwiatkowski,“Alowerboundon y problem becomes trivial. More specifically, we will thelengthofasequencecontainingallpermutationsas show that for every integer n ≥ 1 and every y ∈ subsequences,”JournalofCombinatorialTheory,SeriesA 21,129–136(1976). {0,...,n!−1} it is possible to find a set of n unitary [7] S.Radomirovic´,“AConstructionofShortSequences matrices {U}n−1 suchthat i 0 ContainingAllPermutationsofaSetasSubsequences,” TheElectronicJournalofCombinatorics19,P31(2012). Πx = ωxyΠ0 (A1) http://www.combinatorics.org/ojs/index.php/eljc/ article/view/v19i4p31. istrueforall x forsomechoiceof y,where [8] A.Y.Kitaev,“QuantummeasurementsandtheAbelian StabilizerProblem,”quant-ph/9511026. Πx =Uσx(n−1)...Uσx(1)Uσx(0), (A2) [9] X.-Q.Zhou,T.C.Ralph,P.Kalasuwan,M.Zhang, A.Peruzzo,B.P.Lanyon,andJ.L.O’Brien,“Adding and ω = ei2nπ!. controltoarbitraryunknownquantumoperations,”Nat. We first present the construction for y = 1. In this Commun.2,413(2011),arXiv:1006.2670 [quant-ph]. case, to each permutation of the matrices corresponds [10] X.-Q.Zhou,P.Kalasuwan,T.C.Ralph,andJ.L.O’Brien, adifferentphase ωx. Westartbyprovingthatthepair- “Calculatingunknowneigenvalueswithaquantum wiserelations algorithm,”NaturePhotonics7,223–228(2013), arXiv:1110.4276 [quant-ph]. U U = ωk!UU for k > j ≥0 (A3) [11] M.Araújo,A.Feix,F.Costa,andCˇ.Brukner,“Quantum k j j k circuitscannotcontrolunknownoperations,” generate all the n! required phases. In order to prove arXiv:1309.7976 [quant-ph]. this, it is convenient to introduce an explicit labeling [12] G.Chiribella,R.Ionicioiu,T.Jennewein,andD.Terno. of the permutations. A generic permutation of the n Privatecommunication. [13] M.Mirhosseini,M.Malik,Z.Shi,andR.W.Boyd, matrices {Un−1,...,U0} is labeled by a sequence of in- “Efficientseparationoftheorbitalangularmomentum tegers (an−1,...,a1), with 0 ≤ ak ≤ k, and is obtained eigenstatesoflight,”Nat.Commun.4,2781(2013), by shifting the matrix Uk to the right ak times, starting arXiv:1306.0849 [quant-ph]. from k = 1. As an example, let us construct the four- [14] G.C.G.Berkhout,M.P.J.Lavery,J.Courtial,M.W. elementpermutationlabeledby(3,1,1). First,weswap Beijersbergen,andM.J.Padgett,“EfficientSortingof U and U (i.e., we shift U one position to the right), 0 1 1 OrbitalAngularMomentumStatesofLight,”Phys.Rev. obtaining U U U U , then we shift U one position to Lett.105,153601(2010). 3 2 0 1 2 the right and obtain U U U U . Finally, we shift U [15] M.Arndt,O.Nairz,J.Voss-Andreae,C.Keller, 3 0 2 1 3 three times to the right and get the desired permuta- G.vanderZouw,andZ.A.,“Wave-particledualityof C60 molecules,”Nature401,680–682(1999). tion, U0U2U1U3. In this procedure, each matrix Uk is [16] S.Eibenberger,S.Gerlich,M.Arndt,M.Mayor,and swapped ak timeswithmatricesUj having j < k. Thus, if the relations (A3) hold, the permutation labeled by J.Tuxen,“Matter-waveinterferencewithparticles selectedfromamolecularlibrarywithmassesexceeding (an−1,...,a1) producesaphase ωx,where 10000amu,”Phys.Chem.Chem.Phys15,14696–14700 [17] K(2.0N13a)k.ago,M.Hajdušek,S.Nakayama,andM.Murao, x =n∑−1akk! (A4) k=1 6 is the expansion of the integer x in the factorial basis This construction saturates the lower bound d ≥ n! we (or factoradic expansion). For the given example, x = presentedinthemaintext. Itisaninterestingpuzzleto 3×3!+1×2!+1×1! =21. findoutwhetherthereexistsaconstructionwithd = n! Weconstructnowasetofnunitarymatricesthatsat- forevery n. isfy the pairwise relations (A3). They are constructed fromthegeneralized X and Z matrices AppendixB:Toleratingexperimentalerror n!−1 X = ∑ |j⊕1(cid:105)(cid:104)j|, (A5a) j=0 In an experimental implementation, no property Py n!−1 can be satisfied exactly, so to run this algorithm one Z = ∑ ωj|j(cid:105)(cid:104)j|, (A5b) needstobeabletotoleratesomedeviationsfromit. To j=0 dothis,noticethatpropertyPy issatisfiedifandonlyif where ⊕ denotes the sum modulo n!. Note that they satisfythecommutatiZonXr=elaωtiXonZ. (A6) n!12d(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)nx∑!=−01ω−xyΠx(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2HS =1, (B1) Thenwedefine Uk = (cid:16)Zk!(cid:17)⊗k⊗X⊗1⊗n−k−1 for k < n−1, wplheecroen(cid:107)s·e(cid:107)qHuSeinscteheoHf tihlbeerfta-cStchthmaitdtthnisornmo.rmThiissidseafisnimed- (cid:16) (cid:17)⊗n through an inner product. We then reformulate the Un−1 = Z(n−1)! , problem such that a set of unitaries satisfies the modi- (A7) fiedpropertyP(cid:48)y if wnh=er4e,twheesaerteoufsuinngitathrieescodnevfiennetdiobnyt(hAat7)Ar⊗ea0d=s 1. For 2 ≤ 1 (cid:13)(cid:13)(cid:13)n∑!−1ω−xyΠ (cid:13)(cid:13)(cid:13)2 ≤1 (B2) U = X⊗1⊗1, 3 n!2d(cid:13)(cid:13)x=0 x(cid:13)(cid:13)HS 0 U1 = Z⊗X⊗1, (A8) for a given y ∈ {0,...,n!−1}. The problem is still U2 = Z2⊗Z2⊗X, to decide which property P(cid:48)y the set of unitaries have, giventhepromisethattheyhaveoneofthem. U = Z6⊗Z6⊗Z6. 3 Note that, in this version of the problem, we cannot Itiseasytocheckthatthematricesgeneratedaccording anymoreuseanarbitrarypurestate |ψ(cid:105) toperformthe to these rules satisfy property (A3). A set of n unitary protocol, since it is not true anymore that the probabil- matrices that satisfies property (A1) for an arbitrary y ities cpalancebeoffoωu.nd by repeating this construction with ωy in p = 1 (cid:13)(cid:13)(cid:13)n∑!−1ω−xsΠ |ψ(cid:105)(cid:13)(cid:13)(cid:13)2 Note that this construction is enough to show that s n!2(cid:13)(cid:13)x=0 x (cid:13)(cid:13) there is an infinity of sets of unitaries satisfying prop- erty (A1), since the choice of basis in the definition of are independent of |ψ(cid:105). In fact, it is possible to have a thematrices X and Z inequation(A5)isarbitrary. setofmatricessuchthatthelhsofEq.(B1)isarbitrarily Thisconstructiongeneratesmatriceswithdimension closeto1,while p forsomestate |ψ(cid:105) isequalto0. y d = n!n−1, which therefore must act on O(n2logn) Instead,wecanusethemaximallymixedstate,since qubits. One can also see that they can be implemented then the outcome probabilities p become directly re- s with a polynomial amount of elementary gates, since latedtotheHilbert-Schmidtnorm,as they are tensor products of a linear amount of X and aZkpOomnlyaentrocicmaensia,lathalsmaotocuganentttohcfeoemnlsestmerluvecnetstioabrnyesigmwatpietlshe.mtehnetecdorwreitcht ps = n!12d(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)nx∑!=−01ωxsΠx(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2HS (B3) phases in lower dimension, which might be interesting and therefore the promise implies that p ≥ 2/3 for for an experimental implementation. For example, for s s = y, and p < 1/3 for s (cid:54)= y. These two conditions n =3,thefollowing6-dimensionalmatricesalsowork: s are the ones necessary for a probabilistic algorithm to U = X, work; they imply that if we run the algorithm k times 0 U = ZX, (A9) and take as our guess for y the most common answer, 1 the probability of making a mistake goes down expo- U = Z2. 2 nentiallywith k. 7 AppendixC:Implementingthen-switchgateinthe Note that when each unitary is applied only once to quantumcircuitmodel the target system, i.e. when |C(cid:105) encodes a permutation or a superposition of permutations, then the ancillæ Here we describe how to simulate the n-switch gate disentangle from the control system at the end of the in the quantum circuit model. The simulation is based circuit(sinceUi isappliedn−1timeson|ai(cid:105),indepen- on the circuit presented on Ref. [5], with the difference dently of |C(cid:105)). This is not the case when |C(cid:105) encodes thatourschemecanbeusedforquantum(andnotonly a more general sequence of unitaries, thus this circuit classical)controloftheorder. cannot be used to implement quantum control of arbi- 3 In the main text we described the control system trarysequencesof n unitaries . |C(cid:105) as encoding the permutation to be applied sim- If the time used by the swap gates is neglected, this ply as a state running from |0(cid:105) to |n!−1(cid:105). Here we circuithasrunningtimen. Itiseasytoseethatacircuit shall use a more convenient representation, expressing with this running time cannot use less than n2 queries: |C(cid:105) = |C (cid:105)...|C (cid:105), where each |C (cid:105) runs from |0(cid:105) to in order to be possible to implement all permutations, 1 n k |n−1(cid:105), and indicates the unitary to be applied in the eachofthenunitariesmustbeavailableineachofthen positionk. Forexample,toencodethepermutationthat timesteps. Itishoweverpossibletoreducethenumber first applies U , then U , and then U , we shall write of queries at the expense of the running time (for the |C(cid:105) = |102(cid:105). 1This rep0resentation re2quires n(cid:100)log n(cid:101) 2-switch,animplementationwithonequerytoU0 and qubits, a small overhead over the (cid:100)log n!(cid:101) qubits t2hat twoqueriestoU1 ispossible,seeRef.[3].) Asshownin are necessary to encode a permutation2 of n elements. the main text, no implementation with less than Ω(n2) We also remark that the conversion between these two queries is possible. Note that this coincides with the representations can be done on a classical computer in definitionof“gateuses”introducedinthemaintext. polynomial time, and therefore we shall note it no fur- ther. AppendixD:Relationshipwithotherquantumalgorithms Thecircuitconsistsofacompositionofninstancesof thefollowingelement,where k goesfrom1to n: We would like to understand the relationship of our |C (cid:105) • • algorithm with other known classes of quantum algo- k rithms; in particular, there are some similarities be- |ψ(cid:105) tween our algorithm and those that solve the (abelian) |a (cid:105) U hidden subgroup problem, and we wanted to explore 0 0 S S howdeeptheyare. . . . . Inthehiddensubgroupproblemoneisgivenagroup . . G and needs to find (a set of generators for) a hidden |an−1(cid:105) Un−1 subgroupH,byusingafunction f(g)thatisconstantin each coset of H, and different on different cosets. One The |ai(cid:105) are ancillæ, and S is a gate that swaps |ψ(cid:105) isgivenaccessto f viaablack-boxunitarythatdoesthe with the ancilla |ai(cid:105) controlled on |Ck(cid:105) = |i(cid:105), leaving mapping theotherancillæinvariant. Thisgateclearlycanbeim- plementedwithalinearamountofelementarygates,so U|x(cid:105)|y(cid:105) = |x(cid:105)|y+ f(x)(cid:105). weshallnotdiscussitsimplementation. Notethateach elementcontainsnunitaries;therefore,sinceweneedn In our problem, one is given as input a set of unitaries of these elements to implement the n-switch, the total {Uj}nj=−01,withthepromisethatitspermutationsΠx act numberofqueriesinthisimplementationis n2. as For example, using this construction for n = 3 gives usthecircuit Sn|x(cid:105)|ψ(cid:105) = |x(cid:105)Πx|ψ(cid:105) = ωxy|x(cid:105)Π0|ψ(cid:105). A first difference is that our unitaries act by apply- |C (cid:105) • • 3 ing a phase, instead of shifting the state of the an- |C (cid:105) • • 2 |C (cid:105) • • cilla. But if one nevertheless considers the function 1 |ψ(cid:105) |a (cid:105) U U U 0 0 0 0 3 Theancillæalsodisentangleforsequencesinwhicheachunitaryis S S S S S S appliedtothetargetafixednumberoftimes. Forexample,when |a1(cid:105) U1 U1 U1 |C(cid:105)isinasuperpositionof|002(cid:105),|020(cid:105),and|200(cid:105)theancillæstill disentangle(ineachcaseU0isappliedtwiceandU2once),butnot |a (cid:105) U U U whenitisasuperpositionof|002(cid:105)and|021(cid:105). 2 2 2 2 8 f(x) = ωxy one can see that it obeys the promise of Instead, because in our case the superposition is not the hidden subgroup problem: it is a periodic func- uniform, one needs an exponential amount of repeti- tion with period r = n!/gcd(y ,n!), and if one takes tions in the worst case. To see that, consider the case 0 the group as G = Z with addition modulo n!, and when g(l) = l mod n!. Then the probability of obtain- n! H = {0,r,2r,...},then f(x) isconstantineachcosetof ing |0(cid:105) whenmeasuringthefirstregisteris H and distinct for distinct cosets. Moreover, our algo- rithm finds y and therefore r, solving the hidden sub- sin2(cid:0)πr(cid:1) n! , groupproblemforthisfunction. r2sin2(cid:0)π(cid:1) n! Canwepushthisanalogyfurther? Morespecifically, can we use our algorithm to find the period of any and this means that, for constant r, one would need to function f(cid:48)(x) thatis constanton eachcosetof thehid- makeO(n!2)measurementstogetanoutcomedifferent den subgroup and different for different cosets? We than |0(cid:105) andanyinformationatallabouttheperiodr. are going to show that this is not the case. Let then For this reason, it seems that the analogy between f(cid:48)(x) = ωg(x) besuchafunction. Westartinthestate our algorithm and the period-finding algorithm (and, therefore, those solving the hidden subgroup problem) 1 n∑!−1 cannot be pushed far. We think the true connection is |C(cid:105)|ψ(cid:105) = √ |x(cid:105)|ψ(cid:105), n! x=0 only at the more basic level that they are both applica- tionsofthequantumFouriertransform. andapplytheswitch: S |C(cid:105)|ψ(cid:105) = √1 n∑!−1|x(cid:105)Π |ψ(cid:105) = √1 n∑!−1ωg(x)|x(cid:105)Π |ψ(cid:105). AppendixE:Decompositionofthen-router n x 0 n! x=0 n! x=0 Now we split the sum into the subgroup H and its We show how an n-router can be constructed us- ingapolynomialnumberofelementaryresources,each cosets: equivalenttoapolarizingbeamsplitter(PBS).Let|x(cid:105)be S |C(cid:105)|ψ(cid:105) = √1 n∑!−1ωg(x)|x(cid:105)Π |ψ(cid:105) a basis element of the control system, and |j(cid:105)in denote n 0 n! x=0 the j-th input mode to the router, with j = 0,...,n−1 (for simplicity, we don’t write explicitly the target sys- = √1 r∑−1 Nr∑−1ωg(l+ar)|l+ar(cid:105)Π |ψ(cid:105). tem). Then the n-router performs the transformation n! l=0 a=0 0 |x(cid:105)|j(cid:105)in (cid:55)→ |x(cid:105)|σx(j)(cid:105)out, where |σx(j)(cid:105)out is the σx(j)- th output mode. In order to decompose this gate in Nowweusethefactthat g(x+r) = g(x), elementaryones,wefirstexpressthecontrolvariablein termsofitsfactoradicrepresentation,introducedinSec- S |C(cid:105)|ψ(cid:105) = √1 r∑−1 Nr∑−1ωg(l)|l+ar(cid:105)Π |ψ(cid:105), tion A: x ↔ (an−1,...,a1), with 0 ≤ ak ≤ k. Then, we n 0 4 n! l=0 a=0 represent each coefficient ak using k bits bk1,...,bkk, with b = 1 for j < a and b = 0 for j ≥ a . For kj k kj k andapplytheinverseFouriertransformonthefirstreg- example,thevaluesof a arerepresentedas 3 ister: Fn!Sn|C(cid:105)|ψ(cid:105) = 1 n∑!−1r∑−1nr∑!−1ωg(l)−y(l+ar)|s(cid:105)Π0|ψ(cid:105) b3a31 == 00 11 21 31 n! s=0 l=0 a=0 b = 0 0 1 1 (cid:32) (cid:33) 32 = 1r r∑−1 r∑−1ωg(l)−knr!l (cid:12)(cid:12)(cid:12)knr!(cid:69)Π0|ψ(cid:105) b33 = 0 0 0 1 k=0 l=0 In this way, we can encode the control quantum sys- The algorithm ends by measuring the first register in tem in n(n−1) qubits, |x(cid:105) → (cid:78)n (cid:78)k |b (cid:105). Now we 2 k=1 j=1 kj the computational basis. At this point, it is useful to can construct the n-router using a controlled binary comparethisstatetotheoneyouwouldgetifyouwere swap of modes for each control qubit |b (cid:105). Recall that kj applyingtheperiod-findingalgorithm. Withit,thestate anarbitrarypermutation|j(cid:105)in (cid:55)→ |σx(j)(cid:105)out isobtained ofthefirstregisterwouldbe shifting each mode k “to the right” by a number a of k √1 r∑−1(cid:12)(cid:12)kn!(cid:69), r (cid:12) r k=0 4Thisencodingisclearlynotoptimal,sinceitrequiresO(n2)bitsto a uniform superposition over the multiples of nr!, and a encodethen!permutations,insteadoftherequiredO(nlogn).We constant amount of repetitions of the algorithm would will however not invest more time to optimize this aspect of the beenoughtodeterminer withhighprobability. problem. 9 positions, i.e. applying the unitary |k(cid:105)in (cid:55)→ |k−ak(cid:105)out, posing the two swaps, we obtain the transformation |j(cid:105)in (cid:55)→ |j+1(cid:105)out for k−ak ≤ j < k. The idea is |3(cid:105) → |1(cid:105), |1(cid:105) → |2(cid:105), |2(cid:105) → |3(cid:105). Since b33 = 0, the to decompose this shift in swaps between neighboring last mode-swap is not applied, the result of the two modes,witheachswapcontrolledbyonecontrolqubit. mode-swaps is therefore the shift of mode 3 by a = 2 3 Explicitly,thecontrolledmode-swapsaredefinedas positionstotheright. Bycomposingthisprocedurefor an arbitrary set of coefficients (an−1,...,a1), the corre- |bkj(cid:105)|k−j(cid:105)in (cid:55)→|bkj(cid:105)|k−j+bkj(cid:105)out (E1) spondingpermutationofmodesisrealized. |bkj(cid:105)|k−j+1(cid:105)in (cid:55)→|bkj(cid:105)|k−j+1−bkj(cid:105)out, The building block of this construction is the con- trolledswapoftwomodes,whichisessentiallyequiva- andidentityfortheothermodes. The n-routeristhen lenttoaPBS(foraPBS,thecontrolqubitisthephoton obtainedbyfirstapplyingthemode-swapcontrolledby polarization). We stress that this element does not cor- |b (cid:105), then the one controlled by |b (cid:105) followed by the respond to any traditional elementary gate of a quan- 11 21 onecontrolledby|b (cid:105)andsoon,applyingsuccessively tum circuit, and it should thus be considered as a new 22 each mode-swap controlled by |b (cid:105) increasing k and, elementaryresource. kj foreach k,increasing j. In Ref. [5], a different approach was proposed for As an example, consider a permutation identified by the scalable realization of the n-switch: a construction the single non-vanishing factoradic coefficient a = 2. was proposed that realizes the n-switch using O(n2) 3 The corresponding control qubits are then in the states 2-switches. This construction, however, is not appli- |b = 1(cid:105)|b = 1(cid:105)|b = 0(cid:105). First we apply the cable to our case, since our definitions differ slightly5. 31 32 33 swapbetweenmodes3and2controlledon|b (cid:105). Since Furthermore, the construction based on the n-router 31 b = 1 this results in the mode-swap |3(cid:105) ↔ |2(cid:105). Then, element is more directly related to the interferometric 31 since b = 1, the modes 2 and 1 are swapped. Com- implementationproposedinthemaintext. 32 5According to the definition from [5], the n-switch orders the n of[5]canbereproducedbya3-switchasdefinedhere, withthe unitariesaccordingtotheprescribedpermutation,butitdoesnot prescriptionthatonlythefirstandlastpositionareswapped,while directlycomposethemtoeachother.Itisthuspossibletoplugad- the position in the middle is fixed and can be used either as an ditionalelementsbetweenanypairsofunitaries,makingthecon- identityortopluginputandoutputofanotherswitch. structionofthen-switchfrom2-switchespossible. The2-switch