Contraction of matchgate tensor networks on non-planar graphs Sergey Bravyi∗ February 2,2008 8 0 0 2 Abstract n a A tensor networkisa productof tensorsassociated with verticesof somegraphG such thatevery J edgeofGrepresentsasummation(contraction)overamatchingpairofindexes. Itwasshownrecently 8 1 by Valiant, Cai, and Choudharythat tensor networks can be efficiently contracted on planar graphs if componentsofeverytensorobeyasystemofquadraticequationsknownasmatchgateidentities. Such ] tensors are referred to as matchgate tensors. The present paper provides an alternative approach to h contraction of matchgate tensor networks that easily extends to non-planar graphs. Specifically, it is p - shown that a matchgate tensor network on a graph G of genus g with n vertices can be contracted in nt timeT =poly(n)+O(m3)22gwheremistheminimumnumberofedgesonehastoremovefromGin a ordertomakeitplanar.Ourapproachmakesuseofanticommuting(Grassmann)variablesandGaussian u integrals. q [ 1 v 9 8 9 2 . 1 0 8 0 : v i X r a ∗IBMT.J.WatsonResearchCenter,YorktownHeights,NY10598 1 Contents 1 Introductionandsummaryofresults 3 2 Somedefinitionsandnotations 5 2.1 Tensornetworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Anticommuting variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 Gaussianintegrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3 Matchgatetensors 8 3.1 Basicproperties ofmatchgatetensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2 Describing atensorbyagenerating function . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3 Matchgatetensors haveGaussiangenerating function . . . . . . . . . . . . . . . . . . . . . 11 3.4 Graphtheoretic definitionofmatchgatetensors . . . . . . . . . . . . . . . . . . . . . . . . 13 4 Contraction ofmatchgatetensornetworks 17 4.1 Edgecontractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 Edgecontraction asaconvolution ofgenerating functions . . . . . . . . . . . . . . . . . . . 18 4.3 Contraction ofaplanarsubgraph inoneshot . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.4 Contraction ofmatchgatenetworkswithasinglevertex . . . . . . . . . . . . . . . . . . . . 26 4.5 Themaintheorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2 1 Introduction and summary of results Contraction of tensor networks is a computational problem having a variety of applications ranging from simulation of classical and quantum spin systems [1, 2, 3, 4, 5] to computing capacity of data storage devices[6]. Giventhetremendousamountofapplicationsitisimportanttoidentifyspecialclassesoftensor networks that can be contracted efficiently. For example, Markov and Shi found a linear time algorithm for contraction of tensor networks on trees and graphs with a bounded treewidth [1]. An important class of graphs that do not fall into this category are planar graphs. Although contraction of an arbitrary tensor networkonaplanargraphisahardproblem,ithasbeenknownforalongtimethatthegenerating function ofperfectmatchings knownasthematchingsumcanbecomputed efficientlyonplanargraphsforarbitrary (complex) weights using the Fisher-Kasteleyn-Temperley (FKT) method, see [7, 8, 9]. It is based on the observation that the matching sum can berelated toPfaffianofaweighted adjacency matrix (known asthe Tutte matrix). The FKT method also yields an efficient algorithm for computing the partition function of spinmodelsreducible tothematching sum,mostnotably, theIsingmodelonaplanargraph [10]. Recently theFKTmethodhasbeengeneralized tothematchingsumofnon-planar graphswithabounded genus[11, 12,13]. Computing the matching sum can be regarded as a special case of a tensor network contraction. It is therefore desirable to characterize precisely the class of tensor networks that can be contracted efficiently usingtheFKTmethod. ThisproblemhasbeensolvedbyValiant[14,15]andinthesubsequentworksbyCai andChoudhary [16,17,18]. Unfortunately, itturnedoutthatthematchingsumofplanargraphsessentially provides the most general tensor network in this class, see [16, 18]. Following [16] we shall call such networksmatchgatetensornetworks,orsimplymatchgatenetworks. Asurprisingdiscoverymadein[17]is thatmatchgatetensors canbecharacterized byasimplesystem ofquadratic equations knownasmatchgate identities which does not make references to any graph theoretical concepts. Specifically, given atensor T of rank n with complex-valued components T(x) = T labeled by n-bit strings x ∈ {0,1}n one x1,x2,...,xn callsT amatchgatetensor, orsimplyamatchgate,if T(x⊕ea)T(y⊕ea)(−1)x1+...+xa−1+y1+...+ya−1 = 0 forall x,y ∈ {0,1}n. (1) a:Xxa6=ya Hereeadenotesastringinwhichthea-thbitis1andallotherbitsare0. Thesymbol⊕standsforabit-wise XORofbinarystrings. Forexample,asimplealgebrashowsthatatensorofrankn = 1,2,3isamatchgate iffitiseitherevenorodd1. Furthermore, aneventensorofrank4isamatchgateiff −T(0000)T(1111)+T(1100)T(0011)−T(1010)T(0101)+T(1001)T(0110) = 0. (2) Amatchgatenetworkisatensornetworkinwhicheverytensorisamatchgate. The purpose of the present paper is two-fold. Firstly, we develop a formalism that allows one to per- form partial contractions of matchgate networks, for example, contraction of a single edge combining its endpoints into a single vertex. More generally, the formalism allows one to contract any connected planar subgraph G of the network into a single vertex u(G) by ”integrating out” all internal edges of G. The number ofparameters describing thecontracted tensor assigned tou(G)isindependent ofthesize ofG. It depends only on the number of ”external” edges connecting G to the rest of the network. This is the main distinction of our formalism compared to the original matchgate formalism of Valiant [14]. The ability to implement partial contractions may be useful for designing efficient parallel contraction algorithms. More importantly, we show that it yields a faster contraction algorithm for matchgate networks on non-planar graphs. 1AtensorT iscalledeven(odd)ifT(x)=0forallstringsxwithodd(even)Hammingweight. 3 Ourformalism makesuseofanticommuting (Grassmann) variables suchthatatensor ofranknisrepre- sentedbyagenerating function ofnGrassmannvariables. AmatchgatetensorisshowntohaveaGaussian generating function that depends on O(n2) parameters. The matchgate identities Eq. (1) can be described by a first-order differential equation making manifest their underlying symmetry. Contraction of tensors is equivalent toconvolution oftheirgenerating functions. Contraction ofmatchgatetensors canbeperformed efficiently using the standard Gaussian integration technique. We use the formalism to prove that a tensor satisfiesmatchgateidentitiesifandonlyifitcanberepresentedbythematchingsumonsomeplanargraph. Itreproduces the result obtained earlier by CaiandChoudhary [17,18]. Ourapproach also reveals that the notionofamatchgatetensorisequivalenttotheoneofaGaussianoperatorintroducedin[19]inthecontext ofquantum computation. Secondly, we describe an improved algorithm for contraction of matchgate networks on non-planar graphs. LetΣbeastandard oriented closedsurfaceofgenusg,i.e.,aspherewithg handles. Definition 1. Given a graph G = (V,E) embedded into a surface Σ weshall say that G is contractible if there exists a region D ⊂ Σwith topology of adisk containing all vertices and alledges of G. Asubset of edgesM ⊆ E iscalledaplanarcutofGifagraphG = (V,E\M)iscontractible. M Acontraction valuec(T)ofatensornetworkT isacomplexnumberobtainedbycontracting alltensors ofT. Ourmainresultisasfollows. Theorem 1. Let T be a matchgate tensor network on a graph G = (V,E) with n vertices embedded into a surface of genus g. Assume we are given a planar cut of G with m edges. Then the contraction value c(T)canbecomputedintimeT = O((n+m)6)+O(m3)22g. IfGhasabounded vertexdegree, onecan computec(T)intimeT = O((n+m)3)+O(m3)22g. Ifanetworkhasasmallplanarcut,m ≪ n,thetheoremprovidesaspeedupforcomputingthematching sum and the partition function of the Ising model compared to the FKT method. For example, computing the matching sum of a graph G as above by the FKTmethod would require time T = O(n3)22g since the matching sum is expressed as a linear combination of 22g Pfaffians where each Pfaffian involves a matrix of size n×n, see [11, 12, 13], and since Pfaffian of an n×n matrix can be computed in time O(n3), see Remark2below. Incontrast totheFKTmethod, ouralgorithm isdivided intotwostages. Atthefirststage that requires time O((n+m)6) one performs a partial contraction of the planar subgraph G determined M bythegivenplanarcutM,seeDef.1. Thecontractionreducesthenumberofedgesinanetworkdowntom without changing the genus2. Thefirststage ofthe algorithm yields anewnetwork T′ withasingle vertex and mself-loops such that c(T′) = c(T). Atthesecond stage one contracts the network T′ by expressing the contraction value c(T′) as a linear combination of 22g Pfaffians similar to the FKT method. However eachPfaffianinvolves amatrixofsizeonlyO(m)×O(m). Remark1: Thestatementofthetheoremassumesthatalltensorsarespecifiedbytheirgeneratingfunctions. Thus a matchgate tensor of rank d can be specified by O(d2) parameters, see Section 3 for details. The ordering ofindexes inanytensor mustbeconsistent withtheorientation ofasurface. SeeSection2.1fora formaldefinitionoftensornetworks. Remark2: RecallthatPfaffianofann×nantisymmetric matrixAisdefinedas 0 if nisodd, Pf(A) = 1 sgn(σ)A A ···A if niseven. (cid:26) 2nn! σ∈Sn σ(1),σ(2) σ(3),σ(4) σ(n−1),σ(n) where S is the symmetric gProup and sgn(σ) = ±1 is the parity of a permutation σ. One can efficiently n compute Pfaffian up to a sign using an identity Pf(A)2 = det(A). However, in order to compute a linear 2Iftheinitialnetworkrepresentsamatchingssum,thefirststageofthealgorithmwouldrequireonlytimeO((n+m)3). 4 combination of several Pfaffians one needs to know the sign exactly. One can directly compute Pf(A) usingthecombinatorial algorithmbyMahajanetal[20]intimeO(n4). Alternatively, onecanuseGaussian eliminationtofindaninvertiblematrixU suchthatUT AU isblock-diagonalwithallblocksofsize2×2. It requirestimeO(n3). ThenPf(A)canbecomputedusinganidentityPf(U AUT) = det(U) Pf(A). This method yields O(n3) algorithm although it is less computationally stable compared to the combinatorial algorithm of[20]. 2 Some definitions and notations 2.1 Tensor networks Throughout this paper a tensor of rank d is a d-dimensional complex array T in which the indexes take values 0 and 1. Given a binary string of indexes x = (x x ...x ) we shall denote the corresponding 1 2 d component T asT(x). x1x2...xd Atensor network isaproduct oftensors whose indexes are pairwise contracted. Morespecifically, each tensor is represented by a vertex of some graph G = (V,E), where V is a set of vertices and E is a set of edges. The graph may have self-loops and multiple edges. For every edge e ∈ E one defines a variable x(e) taking values 0 and 1. Abit string xthat assigns a particular value to every variable x(e) is called an index string. A set of all possible index strings will be denoted X(E). In order to define a tensor network on G one has to order edges incident to every vertex. We shall assume that G is specified by its incidence list, i.e.,foreveryvertex uonespecifies anordered listofedges incident touwhichwillbedenoted E(u). ThusE(u) = {eu,...,eu }whereeu ∈ E forallj. Hered(u) = |E(u)| isthedegree ofu. Ifavertexu 1 d(u) j hasoneorseveral self-loops, weassumethat everyself-loop appears inthelistE(u)twice(because itwill represent contraction oftwoindexes). Forexample, avertexwithoneself-loop andnootherincident edges hasdegree 2. Atensor networkonGisacollection oftensors T = {T } labeled byvertices ofGsuch u u∈V thatatensorT hasrankd(u). Acontraction valueofanetworkT isdefinedas u c(T) = T (x(eu)...x(eu )). (3) u 1 d(u) x∈X(E)u∈V X Y Thusthecontractionvaluecanbecomputedbytakingatensorproductofalltensors{T }andthencontract- u ing those pairs of indexes that correspond to the same edge of the graph. By definition, c(T)is a complex number(tensor ofrank0). ItwillbeimplicitlyassumedthroughoutthispaperthatatensornetworkisdefinedonagraphGembedded intoaclosedorientedsurfaceΣ. Werequirethattheorderofedgesincidenttoanyvertexumustagreewith the order in which the edges appear if one circumnavigates u counterclockwise. Thus the order on any set E(u) is completely specified by the choice of the first edge eu ∈ E(u). If the surface Σ has genus g we 1 shallsaythatGhasgenusg (itmayormaynotbetheminimalgenusforwhichtheembeddingofGintoΣ ispossible). 2.2 Anticommuting variables In this section we introduce notations pertaining to the Grassmann algebra and anticommuting variables (see the textbook [21] for more details). Consider a set of formal variables θ = (θ ,...,θ ) subject to 1 n multiplication rules θ2 = 0, θ θ +θ θ = 0 forall a,b. (4) a a b b a 5 TheGrassmann algebra G(θ)isthealgebra ofcomplex polynomials invariables θ ,...,θ factorized over 1 n theidealgeneratedbyEq.(4). Equivalently, G(θ)istheexterioralgebraofthevectorspaceCn,whereeach variableθ isregardedasabasisvectorofCn. Moregenerally, thevariablesθ maybelabeledbyelements a a ofanarbitraryfinitesetX (inourcasethevariableswillbeassociated withedgesorverticesofagraph). A linear basis of G(θ) is spanned by 2n monomials in variables θ . Namely, for any subset M ⊆ {1,...,n} a defineanormallyorderedmonomial θ(M)= θ (5) a a∈M Y wheretheindexesincreasefromthelefttotheright. IfthevariablesarelabeledbyelementsofsomesetX, onecandefinethenormallyorderedmonomialsθ(M),M ⊆ X bychoosingsomeorderonX. Letusagree thatθ(∅) = I. Thenanarbitraryelementf ∈G(θ)canbewrittenas f = f(M)θ(M), f(M)∈ C. (6) M⊆{1,...,n} X Weshallusenotationsf andf(θ)interchangeably meaningthatf canberegardedasafunctionofanticom- muting variables θ = (θ ,...,θ ). Accordingly, elements of the Grassmann algebra will be referred to as 1 n functions. In particular, I is regarded as a constant function. A function f(θ)is called even (odd) if it is a linearcombinationofmonomialsθ(M)witheven(odd)degree. Evenfunctions spanthecentralsubalgebra ofG(θ). We shall often consider several species of Grassmann variables, for example, θ = (θ ,...,θ ) and 1 n η = (η ,...,η ). It is always understood that different variables anticommute. For example, a function 1 k f(θ,η) must be regarded as an element of the Grassmann algebra G(θ,η), that is, a linear combination of monomialsinθ ,...,θ andη ,...,η . 1 n 1 k Apartialderivativeoveravariableθ isalinearmap∂ : G(θ) → G(θ)definedbyrequirement∂ ·I = 0 a a a andtheLeibnizrule ∂ ·(θ f)= δ f −θ (∂ ·f). a b a,b b a Moreexplicitly,givenanyfunctionf ∈ G(θ),representitasf(θ)= f +θ f ,wheref ,f ∈ G(θ)donot 0 a 1 0 1 depend on θ . Then ∂ f = f . It follows that ∂ ·θ = I, ∂ θ = −θ ∂ , ∂ ∂ = −∂ ∂ for a 6= b and a a 1 a a a b b a a b b a ∂2 = 0. a Alinearchangeofvariablesθ = n U θ˜ withinvertiblematrixU inducesanautomorphismofthe a b=1 a,b b algebraG(θ)suchthatf(θ)→ f(θ˜). Thecorresponding transformation ofpartialderivativesis P n ∂ = (U−1) ∂˜ . (7) a b,a b b=1 X 2.3 Gaussianintegrals Let θ = (θ ,...,θ ) be a set of Grassmann variables. An integral over a variable θ denoted by dθ is 1 n a a alinearmapfromG(θ ,...,θ )toG(θ ,...,θˆ ,...,θ ),whereθˆ meansthatthevariableθ isomitted. To 1 n 1 a n a a R defineanintegral dθ f(θ),representthefunctionf asf = f +θ f ,wheref ,f ∈ G(θ ,...,θˆ ,...,θ ). a 0 a 1 0 1 1 a n Then dθ f(θ) = f . Thus one can compute the integral dθ f(θ) by first computing the derivative a 1 a R ∂ ·f(θ)andthenexcluding thevariable θ fromthelistofvariables off. a a R R Givenanordered setofGrassmannvariablesθ = (θ ,...,θ )weshalluseashorthand notation 1 n Dθ = dθ ··· dθ dθ . n 2 1 Z Z Z Z 6 Thus Dθ can be regarded as alinear functional on G(θ), or as a linear mapfrom G(θ,η) to G(η), and so on. Theactionof Dθ onthenormallyordered monomialsisasfollows R R 1 if M = {1,2,...,n}, Dθθ(M) = (8) 0 otherwise. Z (cid:26) Similarly,ifoneregards Dθ asalinearmapfromG(θ,η)toG(η)then R η(K) if M = {1,2,...,n}, Dθθ(M)η(K) = 0 otherwise. Z (cid:26) Althoughthisdefinitionassumesthatbothvariablesθ,η haveanormalordering, theintegral Dθdepends onlyontheordering ofθ. R One can easily check that integrals over different variables anticommute, dθ dθ = − dθ dθ a b b a fora6= b. Moregenerally, ifθ = (θ ,...,θ )andη = (η ,...,η )then 1 n 1 k R R R R Dθ Dη = (−1)nk Dη Dθ. (9) Z Z Z Z Underalinearchangeofvariables θ = n U η theintegraltransformsas a b=1 a,b b P Dθ = det(U) Dη. (10) Z Z In the rest of the section we consider two species of Grassmann variables θ = (θ ,...,θ ) and η = 1 n (η ,...,η ). Givenanantisymmetric n×nmatrixAandanyn×k matrixB,definequadratic forms 1 k n n k θT Aθ = A θ θ , θT Bη = B θ η . a,b a b a,b a b a,b=1 a=1b=1 X XX GaussianintegralsoverGrassmannvariablesaredefinedasfollows. 1 1 I(A) d=ef Dθ exp θT Aθ and I(A,B) d=ef Dθ exp θT Aθ+θT Bη . (11) 2 2 Z (cid:18) (cid:19) Z (cid:18) (cid:19) Thus I(A) is just a complex number while I(A,B) is an element of G(η). Below we present the standard formulasfortheGaussianintegrals. Firstly, I(A) = Pf(A). (12) Secondly, ifAisaninvertible matrixthen 1 I(A,B) = Pf(A) exp ηT BTA−1Bη . (13) 2 (cid:18) (cid:19) Assume now that A has rank m for some even3 integer 0 ≤ m ≤ n. Choose any invertible matrix U such thatAU haszerocolumnsm+1,...,n. (ThisisequivalenttofindingabasisofCnsuchthatthelastn−m basisvectorsbelong tothezerosubspace ofA.) Then A 0 UT AU = 11 , 0 0 (cid:20) (cid:21) 3Notethatantisymmetricmatricesalwayshaveevenrank. 7 for some invertible m×m matrix A . Introduce also matrices B , B of size m×k and (n−m)×k 11 1 2 respectively suchthat B UT B = 1 . B 2 (cid:20) (cid:21) Performing a change of variables θ = Uθ˜ in Eq. (11) and introducing variables τ = (τ ,...,τ ) and 1 m µ = (µ ,...,µ )suchthatθ˜= (τ,µ)onegets 1 n−m 1 I(A,B) = det(U) Dτ exp τT A τ +τT B η Dµexp µT B η . 11 1 2 2 Z (cid:18) (cid:19) Z (cid:0) (cid:1) Herewehavetakenintoaccount Eqs.(9,10). ApplyingEq.(13)tothefirstintegralonegets 1 I(A,B) = Pf(A ) det(U) exp ηT BT(A )−1B η Dµexp µT B η . (14) 11 2 1 11 1 2 (cid:18) (cid:19) Z (cid:0) (cid:1) Onecaneasilycheckthat Dµexp µT B η = 0iftherankofB issmallerthanthenumberofvariables 2 2 inµ,thatis,n−m. SinceB hasonlyk columnsweconclude that 2 R (cid:0) (cid:1) I(A,B) = 0 unless m ≥ n−k. Therefore inthenon-trivial caseI(A,B) 6= 0thematricesBT(A )−1B andB specifying I(A,B)have 1 11 1 2 size k ×k and k′ × k for some k′ ≤ k. It means that I(A,B) can be specified by O(k2) bits. One can compute I(A,B) in time O(n3 + n2k). Indeed, one can use Gaussian elimination to find U, compute det(U) and Pf(A ) in time O(n3). The matrix A−1 can be computed in time O(n3). Computing the 11 1,1 matricesB ,B requirestimeO(n2k). 1 2 TheformulaEq.(14)willbeourmaintoolforcontraction ofmatchgatetensornetworks. 3 Matchgate tensors 3.1 Basicproperties ofmatchgate tensors Although the definition ofa matchgate tensor interms ofthe matchgate identities Eq. (1)is very simple, it is neither very insightful nor very useful. Twoequivalent but more operational definitions will be given in Sections3.3,3.4. Herewelistsomebasic properties ofmatchgatetensors thatcanbederiveddirectly from Eq. (1). In particular, following the approach of [17], we prove that a matchgate tensor of rank n can be specifiedbyameanvectorz ∈ {0,1}n andacovariance matrixAofsizen×n. Proposition 1. Let T be a matchgate tensor of rank n. For any z ∈ {0,1}n a tensor T′ with components T′(x) = T(x⊕z)isamatchgatetensor. Proof. Indeed, makeachangeofvariables x→ x⊕z,y → y⊕z inthematchgateidentities Let T be a non-zero matchgate tensor of rank n. Choose any string z such that T(z) 6= 0 and define a newtensorT′ withcomponents T(x⊕z) T′(x) = , x∈ {0,1}n, T(z) suchthatT′ isamatchgateandT′(0n) = 1. Introduce anantisymmetric n×nmatrixAsuchthat T′(ea ⊕ab) if a< b, A = −T′(ea ⊕ab) if a> b, a,b 0 if a= b. 8 Proposition 2. Foranyx∈ {0,1}n Pf(A(x)) if xhasevenweight T′(x) = , 0 if xhasoddweight (cid:26) whereA(x)isamatrixobtained fromAbyremovingallrowsandcolumnsasuchthatx = 0. a Proof. Let us prove the proposition by induction in the weight of x. Choosing x = 0n and y = ea in the matchgate identities Eq. (1) one gets T′(ea) = 0 for all a. Similarly, choosing x = eb and y = ea with a < bonegetsT′(ea ⊕eb) = A = Pf(A(ea ⊕eb)). Thustheproposition istruefor|x| = 1,2. Assume a,b itistrueforallstrings xofweight≤ k. Foranystringxofweightk+1andanyasuchthatx = 0apply a thematchgateidentities Eq.(1)withxandy = ea. Aftersimplealgebraonegets b−1 T′(x⊕ea)= A T′(x⊕eb)(−1)η(a,b), η(a,b) = x . a,b j b:Xxb=1 Xj=a Notingthatx⊕eb hasweightk andapplying theinduction hypothesis onegets T′(x⊕ea) = A Pf(A(x⊕eb))(−1)η(a,b) a,b b:Xxb=1 forevenk andT′(x⊕ea)= 0foroddk. ThusT′(y) = 0foralloddstrings ofweightk+2. Furthermore, letnon-zero bitsofx⊕eb belocated atpositions j < j < ... < j . NotethatthesignofA (−1)η(a,b) 1 2 k a,b coincides with the parity of a permutation that orders elements in a set [a,b,j ,j ,...,j ]. Therefore, by 1 2 k definitionofPfaffianonegetsT′(x⊕ea)= Pf(A(x⊕ea)). Thusonecanregardthevectorz andthematrixAaboveasanalogues ofameanvectorandacovariance matrix for Gaussian states of fermionic modes, see for instance [19]. Although Proposition 2 provides a concise description of a matchgate tensor, it is not very convenient for contracting matchgate networks becausethemeanvectorz andthecovariance matrixAarenotuniquely defined. Corollary 1. Anymatchgatetensoriseitherevenorodd. Proof. Indeed, the proposition above implies that if a matchgate tensor T has even (odd) mean vector it is aneven(odd)tensor. 3.2 Describing a tensor by agenerating function Let θ = (θ ,...,θ ) be an ordered set of n Grassmann variables. For any tensor T of rank n define a 1 n generating function T ∈ G(θ)according to T(θ)= T(x)θ(x). x∈{0,1}n X Hereθ(x) = θx1···θxn isthenormallyorderedmonomialcorresponding tothesubsetofindexesx= {a : 1 n x = 1}. Let us introduce a linear differential operator Λ acting on the tensor product of two Grassmann a algebras G(θ)⊗G(θ)suchthat n Λ= θ ⊗∂ +∂ ⊗θ . (15) a a a a a=1 X 9 Lemma1. AtensorT ofranknisamatchgateiff Λ·T ⊗T = 0. (16) Proof. Foranystrings x,y ∈ {0,1}n onehasthefollowingidentity: 0 if x = y , (θ ⊗∂ +∂ ⊗θ )·θ(x)⊗θ(y)= a a a a a a (−1)x1+...+xa−1+y1+...+ya−1θ(x⊕e )⊗θ(y⊕e ) if x 6= y . a a a a (cid:26) ExpandingbothfactorsT inEq.(16)inthemonomialsθ(x),θ(y),usingtheaboveidentity,andperforming achange ofvariable x → x⊕e and y → y ⊕e for every aone gets alinear combination of monomials a a θ(x)⊗θ(y)withthecoefficientsgivenbytherighthandsideofEq.(1). ThereforeEq.(16)isequivalentto Eq.(1). Lemma 1 provides an alternative definition of a matchgate tensor which is much more useful than the originaldefinitionEq.(1). Forexample,itisshownbelowthattheoperatorΛhasalotofsymmetrieswhich canbetranslated intoagroupoftransformations preserving thesubsetofmatchagate tensors. Lemma2. Theoperator Λisinvariant underlinearreversible changesofvariables θ = n U θ˜. a b=1 a,b b Proof. Indeed, let∂˜ bethepartialderivativeoverθ˜ . UsingEq.(7)onegets P a a n n n θ ⊗∂ +∂ ⊗θ = U (U−1) (θ˜ ⊗∂˜ +∂˜ ⊗θ˜) = (θ˜ ⊗∂˜ +∂˜ ⊗θ˜). a a a a a,b c,a b c c b b b b b a=1 a,b,c=1 b X X X Lemmas 1,2 imply that linear reversible change of variables T(θ) → T(θ˜), where θ = n U θ˜ a b=1 a,b b mapmatchgates tomatchgates. P Corollary 2. Let T be a matchgate tensor of rank n. Then a tensor T′ defined by any of the following transformations isalsomatchgate. (Cyclicshift): T′(x ,x ,...,x ) = T(x ,...,x ,x ), 1 2 n 2 n 1 (Reflection): T′(x ,x ,...,x ) = T(x ,...,x ,x ), 1 2 n n 2 1 (Phaseshift): T′(x) =(−1)x·zT(x),wherez ∈{0,1}n. Proof. Letǫ = 0ifT isaneventensorandǫ = 1ifT isanoddtensor,seeCorollary1. Thetransformations listedabovearegenerated bythefollowinglinearchangesofvariables: Phaseshift : θ → (−1)zaθ , a= 1,...,n. a a Cyclicshift : θ → θ a= 2,...,n, and θ → (−1)ǫ+1θ . a a−1 1 n Reflection : θ → iθ . a n−a Indeed, letθ(x)bethenormally ordered monomial wherex = (x ,x ,...,x ). Letx′ = (x ,...,x ,x ) 1 2 n 2 n 1 for the cyclic shift and x′ = (x ,...,x ,x )for the reflection. Then thelinear changes ofvariables stated n 2 1 above map θ(x) to (−1)z·xθ(x) for the phase shift, to θ(x′) for the cyclic shift, and to iǫθ(x′) for the reflection. Therefore, inallthreecasesT′ isamatchgatetensor. 10