ebook img

Linear-algebraic lambda-calculus PDF

0.16 MB·
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Linear-algebraic lambda-calculus

5 0 λ Linear-algebraic -calculus 0 2 n Pablo Arrighi∗ GillesDowek† a J Abstract 5 2 Witha view towards models of quantum computation and/or the inter- pretationoflinearlogic,wedefineafunctionallanguagewhereallfunctions 1 arelinearoperatorsbyconstruction. Asmallstepoperationalsemantic(and v henceaninterpreter/simulator)isprovidedforthislanguageintheformofa 0 termrewritesystem. Thelinear-algebraicλ-calculusherebyconstructedis 5 linearinadifferent(yetrelated)sensetothat,say,ofthelinearλ-calculus. 1 These various notions of linearity are discussed in the context of quantum 1 programminglanguages. 0 5 0 1 Introduction / h p Quantumcomputationlacksa convenientmodelofcomputation. To thisday its - t algorithmsare expressed in terms of quantumcircuits, but their descriptionsal- n waysseemastonishinglyremotefromthetasktheydoaccomplish[12].Moreover a u universality is only provided via the notion of uniform family of circuits [28]. q QuantumTuring machinessolve this latter point, yet they are even less suitable : as a programming language [6]. Another approach is to enclose quantum cir- v i cuitswithin a classicalimperative-stylecontrolstructure[20] — butwe wish to X avoid this duality, in an attempt to bring programscloser to their specifications. r Functional-style controlstructure, on the other hand, seem to mergewith quan- a tum evolution descriptions in a unifying manner. With a view towards models ofquantumcomputation,wedescribeafunctionallanguageforexpressinglinear operators,andlinearoperatorsonly. Wearecareful,however,nottoburyourpresentationofthislanguageoflinear operatorswithintoomanyquantumcomputation-specificconsiderations.Theaim istoreachanaudienceoflogiciansalso,aswesuspectastrongconnectionwith issuesofcomputationalinterpretationsoflinearlogic. ∗InstitutGaspardMonge, 5BdDescartes, Champs-sur-Marne, 77574Marne-la-Valle´e Cedex2, France,[email protected]. †E´cole polytechnique and INRIA, LIX, E´cole polytechnique, 91128 Palaiseau Cedex, France, [email protected]. Weprovideasemanticforthelanguageintheformofatermrewritesystem [11]. These consist in a finite set of rules l r, each interpreted as follows: −→ “Any term t containing a subterm σl in position p (i.e. t = t[σl] ) should be p rewritten into a term t containingσr in positionp, with all the rest unchanged ′ (i.e. t = t[σr] )”. Here σ denotes a variable substitution. The minimalist in- ′ p terpretationoftherulesmakestermrewritesystems(TRS)extremelysuitablefor describing the behavior of a computer languages unambiguously — so long as theorderinwhichthereductionsoccurdoesnotmattertotheendresult(aprop- ertynamedconfluence). Moreover,becausel r maybeseen asanoriented −→ version of equation l = r, the TRS provides both an operational semantic (an interpreter/simulatorforthelanguage)andanaxiomaticsemantic(anequational theoryinwhichtoprovepropertiesaboutthelanguage). We begin with a simple language for vectors containing constants for base vectors, addition and product by a scalar. On terms of this language we define a rewrite system reducing any term expressing a vector to a linear combination of base vectors [4]. We have also proposed in [4] an extension to a language containingatensorialproductoperation(Section2). Suchalanguagemustrelyonalanguageandrewritesystemforscalars. This raisestheproblemoftheconditionalrewritingrequiredfordivision,whichwecan circumvent,basing quantumcomputationuponthe ring of diadicfloats together with 1 and imaginarynumberi (Section 3). Moregenerally, it should be said √2 thatalanguageoflinearoperatorsdoesnotneeddivision. ModerndaysfunctionallanguagessuchasCaml,Haskelletc. arebasedupon twobasicevaluationmechanisms: matching,whichprovidesconditionalbranch- ingbyinspectionofvalues;andsomeavataroftheλ-calculus. Thefirstmecha- nism is obtainedas we extendthe term rewritesystem to handlelinear maps— themselvesdenotedassuperpositionsofbipartitestates,e.g. (true(cid:3)false+false(cid:3)true) false true. ∗ ∗ −→ Applications are therefore analogous to contractions in tensorial calculus: this approachoffersanelegantparadigmtorepresentquantumoperationsasquantum states(Section4). Thesecondmechanismisobtainedthroughanimplementationofλ-termsviade Bruijn indices, a scheme whereby variablesare encodedas integers referringto theirbinders,e.g. λx.(λy.(x y))isencodedasL(L(var(1) var(0))). ⊗ ⊗ 2 The question of the interpretation of terms such as λx.(x x) is lengthily ad- ⊗ dressedaswedrawadistinctionbetweencloningandcopying. Thesemanticof ourcalculusforbidsonlytheformer,non-linearoperation,byenforcingahigher priorityof the addition’sdistributivity oversubstitution (Section 5). Thisis fol- lowedbyashortexampletakenfromourimplementation(Section6). Erasure on the other hand remains allowed in our calculus, because we do not restrict ourselves to unitary operations. Whilst we discuss possible well- formedness conditions to implement this restriction (a crucial one for quantum computation), the claim here is to have provided a “linear” λ-calculus, in the sense of linear algebra. We discuss the various notions of “linearity” used in quantum programminglanguages, such as the one by Van Tonder [23] (Section 7). 2 Vectorial spaces We seektorepresentquantumprograms,theirinputvectors,theiroutputvectors and their applications as terms of a first-order language. Moreover we seek to providerulessuchthatthetermformedbytheapplicationofaquantumprogram onto its input vector should reduce to its output vector. Several terms may be usedtoexpressoneoutputvector,asaconsequencewemustensurethattheseall reducetooneunique,normalform,uponwhichthereisnothingmoretocompute. Themostnaturalnormalformtoaimforisthatofalinearcombinationofthebase vectors,i.e. thecomputationfinishesoncewehavethecoordinatesoftheoutput vector. We start with the languageof vectorialspaces, i.e. a two-sortedlanguageL havingsortK forscalarsandsortE forvectors—togetherwith: twoconstants 0 and1ofsortK; a constant0 ofsortE; two binarysymbols+ and ofrank × K,K,K ; a binary symbol + (also) of rank E,E,E ; and a binary symbol . h i h i ofrank K,E,E . In[4]wedescribedatermrewritesystemreducinganyterm h i expressing a vector into a linear combination of base vectors. The term rewrite systemdevelops 4.(false+true) 4.false+4.true −→ butfactorizes 4.false+6.false (4+6).false. −→ accordingtotherulesinfigure1. SuchaTRSarisesasweorientsixoftheeight equationsaxiomatizingvectorialspaces. Onlythosetwoaxiomscorrespondingto associativityandcommutativityofvectoradditionareleftaside,becauseweuse 3 rewritingmoduloAC(+). Moreoverwe needto addthreemorerulesforconflu- ence. Figure1: VECTORIALSPACES λ.(u+v) λ.u+λ.v −→ λ.u+µ.u (λ+µ).u −→ λ.(µ.u) (λ µ).u −→ × u+0 u −→ 1.u u −→ 0.u 0 −→ λ.u+u (λ+1).u −→ u+u (1+1).u −→ λ.0 0 −→ with+anACsymbol. Buttheserewriterulesdonottakeintoaccountcomputationonscalars. The lattermustbeaddedbymixinginanotherrewritesystemS,rewritingscalartoa normalform. Definition1 (Scalarrewrite system) A scalar rewrite system is a rewrite system onalanguagecontainingatleastthesymbols+, ,0and1,suchthat: × S isterminatingandgroundconfluent, • forallclosedtermsλ,µandν,thepairofterms • – 0+λandλ, – 0 λand0, × – 1 λandλ, × – λ (µ+ν)and(λ µ)+(λ ν), × × × – (λ+µ)+ν andλ+(µ+ν), – λ+µandµ+λ, – (λ µ) ν andλ (µ ν), × × × × – λ µandµ λ × × 4 havethesamenormalforms, 0and1arenormalterms. • Thefollowingpropositionscanbefoundin[4]. Proposition1 Foranyscalarrewrite systemS,therewrite systemR S ister- ∪ minatingandgroundconfluent. Proposition2 Iftisanormalclosetermwhoseconstantsareamongstx1,...,xn. Thetermtis0orithastheformλ1xi1+...λkxik+xik+1+xik+l wheretheindices i1,...,ik+l aredistinctandtheλk’sareneither0nor1. NotethatthealgorithmdefinedbyRisrelativelycommonincomputing,for presentinganyvectorasalinearcombinationofbasevectors. Butitdoesinfact definevectorialspaces,asanymathematicalstructurevalidatingthealgorithm.In thissensewehaveprovidedacomputationaldefinitionofvectorialspaces. Furthermorenotethatthesupportfortensorproductsiseasilyaddedintothe TRS,throughthesixrulesgiveninfigure2. Proposition1remainstruewhenRis extendedwiththosesixadditionalrules,whilstproposition2nowyieldsnormal formsfortermsinE E oftheform0or ⊗ λ1xi1 ⊗yj1 +...+λkxik ⊗yjk +xik+1 ⊗yjk+1 +...+xik+l ⊗yjk+l, where the pairs of indices i1,j1 ,..., ik+l,jk+l are distinct and the λk’s are h i h i neither0nor1[4]. Figure2: VECTORIALSPACES:TENSORS (u+v) w u w+v w ⊗ −→ ⊗ ⊗ (λ.u) v λ.(u v) ⊗ −→ ⊗ u (v+w) u v+u w ⊗ −→ ⊗ ⊗ u (λ.v) λ.(u v) ⊗ −→ ⊗ 0 u 0 ⊗ −→ u 0 0 ⊗ −→ 5 3 The field of quantum computing Fields are not easily implemented as term rewrite systems, because of the con- ditionalrewritingrequiredforthedivisionbyzero. Inthe previoussectionsuch problems were avoided by simply assuming a TRS for scalars having a certain numberofproperties,butiftheobjectiveistolaythegroundforformalquantum programminglanguages,thenwemustprovidesucha TRS. Thepresentsection brieflyoutlineshowthisisachieved. 3.1 Background Weseektomodelquantumcomputationasaformalrewritesystemuponafinite set of symbols. Since the complexnumbersare uncountable,we musttherefore depart from using the whole of C as the field K of our vectorial space. Such considerations are commonplace in computation theory, and were successfully addressedwith theprovisionofthefirstrigorousdefinitionofaquantumTuring machine[6]. In shortthequantumTuringmachinesarebroughtas anextension ofprobabilisticTuringmachines Q:headstates, Σ:alphabet, h δ:transitionfunction, q ,q :start,endstate o f i whose transition functions are no longer valued over the efficiently computable positivereals(probabilities) δ :Q Σ (Q Σ Left, Right R˜+) × −→ × ×{ }→ butovertheefficientlycomputablecomplexnumbers(amplitudes) δ :Q Σ (Q Σ Left, Right C˜). × −→ × ×{ }→ Inbothcasesδisconstrainedtobeaunitfunction(probabilities/squaredmodulus summingtoone),andforthequantumTuringmachineδ isadditionallyrequired toinduceaunitaryglobalevolution.Awell-knownresultofcomplexitytheoryis thatprobabilisticTuringmachinesremain aspowerfulwhenthe transition func- tion δ is further restricted to take values in the set 0,1,1 . The result in [6] { 2 } is analogous: quantumTuringmachinesremainas powerfulwhenthe transition functionδisfurtherrestrictedtotakevaluesintheset 1, 1 ,0, 1 ,1 .Later {− −√2 √2 } it was shown in [2], and independentlyin [22] that no irrationalnumberis nec- essary,i.e. δ mayberestrictedtotakevaluesintheset 1, 8, 3,0,3,8,1 {− −5 −5 5 5 } withoutlossofpowerforthequantumTuringmachine. 6 Inthecircuitmodelofquantumcomputationtheemphasiswasplacedonthe abilityto approximateanyunitarytransformfroma finite setofgates. Thisline ofresearch(cf. [21][15]tocitea few)hassofarculminatedwith[7],wherethe followingset 1 0 0 0 0 1 0 0 CNOT =  (1) 0 0 0 1  0 0 1 0     1 1  1 0 H = √2 √2 P = 1 1 0 eiπ/4 √2 −√2 ! (cid:18) (cid:19) wasproventobeuniversalintheabovestrictsense. Aweakerrequirementfora setofgatesistheabilitytosimulateanyunitarytransform,anotionwhichisalso referred to as encoded universality — since a computationon n qubits may for instance berepresentedasa computationon n+1 “realbits”, througha simple mapping.Arecentpapershowsthatthegate 1 0 0 0 0 1 0 0 G= , 0 0 a b −  0 0 b a      with either a = b = 1 , or a = 3 and b = 8, has this property [19]. Do √2 5 5 appreciatehowtheresultfallsintolinewiththoseregardingthequantumTuring machine. Definition2 Wecallcomputationalscalars,anddenoteK˜ theringformedbythe additiveandmultiplicativeclosureofthecomplexnumbers 1,1, 1 ,i . {− √2 } Oncewehaveshownthatthecomputationalscalarsarithmeticscanbeperformed byaTRS,itwillbesufficienttoexpressthebasicgates(1)inourformalismtoim- mediatelyobtainthemoretraditionalnotionofquantumcomputationuniversality. Henceourchoice. 3.2 Rules We beginbyimplementingnaturalnumbersandunsignedbinarynumbers. That suchTRScanbemadegroundconfluentandterminatingarenowwell-established results[9][27]. Thisplacesusinapositiontobuildupdiadicfloatsoutofasign, 7 Figure3: DIADICFLOATS fl(s,n::0,S(p)) fl(s,n,p) −→ fl(neg,0,p) fl(pos,0,p) −→ fl(s,0,S(p)) fl(s,0,zeron) −→ . . . fl(pos,m1,e1)timesffl(neg,m2,e2) fl(neg,m1timesbm2,addn(e1,e2)) −→ fl(neg,m1,e1)timesffl(pos,m2,e2) fl(neg,m1timesbm2,addn(e1,e2)) −→ . . . anunsignedbinarynumberandanexponent,e.g. fl(neg,1,S(zeron))istostand for 1,asexemplifiedinfigure3. −2 ReachedthispointitsufficestonoticethatK˜,i.e. diadicfloatstogetherwith imaginary number i and real number 1 , can be viewed as a four-dimensional √2 module upon diadic floats. Indeed any such number could be represented as a linearcombinationoftheform: 1 i α.1+β. +γ.i+δ. . √2 √2 As a consequence we can reuse the results of section 2 to implement computa- tionalscalarsandtheiradditions.Computationalscalarsmultiplicationthenneeds tobedefined,wedosomoduloACinfigure4. Noticethatweoverloadthesym- bol for multiplicationof diadic floats and for multiplicationof computational × scalars. WeconjecturethatthisTRSisgroundconfluentandterminating,buthavenot yetaformalproofforthisassertion. Notice we haveneverdefined a division operation. This is because only the ringpropertiesofthesenumbersarerequiredforexpressinglinearoperations:we placeourselvesupona“module”ratherthatafullvectorialspace. 4 Matching construct Wenowturntothedefinitionofthematchingconstructsinourlanguage. Aswe shallsee,theseconstructsarenothingelsethanareformulationoftherulesforthe 8 Figure4: SCALARMULTIPLICATION 1 v v × −→ 1 1 fl(pos,1,S(zeron)).1 √2 × √2 −→ 1 i i √2 × −→ √2 1 i fl(pos,1,S(zeron)).i √2 × √2 −→ i i fl(neg,1,zeron).1 × −→ i 1 i fl(neg,1,zeron). × √2 −→ √2 i i .. fl(neg,1,S(zeron)).1. √2 × √2 −→ (λ.u) v λ.(u v) × −→ × (t+u) v t v+u v × −→ × × with anACsymbol. × tensorproduct. 4.1 Notations Your typical functional language (Haskell, ML...) will always have “match- ing”constructs(forbranching).Forinstance,hereisapieceofCaml: let rec not b = match b with | false -> true | true -> false ;; We wish to provide such constructs in our linear-algebraic calculus. Strangely enough these matching constructs are very close to the tensorial product con- structs. Mathematicians and physicist in this field would write linear maps instead: NOT = true false + false true. Howeverherethe false and true maybe | ih | | ih | h | h | viewed as patterns, waiting to be compared to the input vector through a scalar 9 product.Thuswechoosetoreconcilebothworldsandwrite: NOT=false(cid:3)true+true(cid:3)false. Anexpression(t(cid:3)u)appliedtoavectorvwillthenreduceinto(t v).u,with thescalarproduct. Inthissense(t(cid:3)u) vdoesreturnuinso far•astoverlap•s ∗ withv. Moreformaljustifications,andformalrewriterulesfollowinthenexttwo subsections. For now we give the reduction steps involvedin the application of thephasegateP uponthevectortrue,asamotivatingexamplefortheserules: 1 1 (false(cid:3)false)+true(cid:3)( +i ).true true √2 √2 ∗ (cid:18) (cid:19) 1 1 (false(cid:3)false) true+ true(cid:3)( +i ).true true ∗ −→ ∗ √2 √2 ∗ (cid:0) 1 1 (cid:1) ∗ (false true).false+(true true). ( +i ).true −→ • • √2 √2 1 1 (cid:0) (cid:1) ∗ 0.false+( +i ).true −→ √2 √2 1 1 ∗ ( +i ).true. −→ √2 √2 Allofthethreegatesformingauniversalsetforquantumcomputationaretrivially expressedastermsinthisnotation: CNOT =(false false)(cid:3)(false false) ⊗ ⊗ +(false true)(cid:3)(false true) ⊗ ⊗ +(true false)(cid:3)(true true) ⊗ ⊗ +(true true)(cid:3)(true false) ⊗ ⊗ 1 1 H = false(cid:3) .(false+true) + true(cid:3) .(false true) √2 √2 − (cid:18) (cid:19) (cid:18) (cid:19) 1 1 P =(false(cid:3)false)+ true(cid:3)( +i ).true . √2 √2 (cid:18) (cid:19) 4.2 Rules Since (cid:3) is just another type of tensor product, bilinearity applies (see figure 5. Noticetheconjugationoftheλscalar,denotedλ,easilyimplementedintheTRS). Otherthanitsleft-hand-sideantilinearity,theparticularityof(cid:3)isthereductionit 10

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.