A linear-non-linear model for a computational call-by-value lambda calculus (extended abstract)
We give a categorical semantics for a call-by-value linear lambda calculus. Such a lambda calculus was used by Selinger and Valiron as the backbone of a functional programming language for quantum computation. One feature of this lambda calculus is i…
Authors: Peter Selinger (1), Beno^it Valiron (2) ((1) Dalhousie University, (2) University of Ottawa)
A linear-non-linear mo del for a computational call-b y-v alue lam b da calculus (extended abstract) Peter Selinger 1 and Beno ˆ ıt V aliron 2 1 Dalhousie Universi ty , selinger@ mathstat.dal.ca 2 Universit y of Otta wa, bvali08 7@uottawa.ca Abstract. W e giv e a categorical semantics for a call-by-v alue linear lam b da calculus. Such a lambda calculus wa s used by Selinger and V al- iron as the b ac k b one of a functional programming language for q uantum computation. One feature of this lambda calculus is its linear type sys- tem, which includes a d uplicabilit y op erator “!” as in linear logic. An- other main feature is its call-b y -v alue reduction strategy , together with a side-effect t o mo del probabilistic measurements . The “!” operator gives rise to a comonad, as in the linear logic mo dels of Seely , Bierman, and Bento n . The side-effects give rise to a monad , as in Moggi’s computa- tional lambda calculus. It is this combination of a monad and a comonad that makes the present p aper interes tin g. W e sho w that our categorical seman t ics is sound and complete. 1 In tro duction In the las t few years, there has b een some int erest in the semantics of quan- tum prog ramming languages. [18] gave a denotational semantics for a flow-c ha rt language, but this langua g e did not include higher -order types . Several author s defined quan tum la m b da calculi [21, 19] as w ell as quantum pro cess algebra s [11, 12], which ha d hig her-order features and a well-defined op er a tional se mant ic s , but lack e d denotatio nal semantics. [20 ] g av e a catego rical model for a higher - order quantum lam bda calculus, but o mitted all the no n- linear features (i.e., classical data). Meanwhile, Abr amsky and Co ecke [2, 9] developed catego rical axiomatics for Hilbert s pa ces, but there is no particula r la nguage a s so ciated with these mo dels. In this pap er, we give the first categ orical se mant ic s of an unabridge d q ua n- tum lambda calculus, which is a version o f the la nguage studied in [19]. F or the purp oses of the pr esent pa per , an understanding of the precise me- chanics of q ua n tum c o mputation is not required. W e will focus prima r ily on the type system and language , and not on the structure of the a c tual “built- in” quantum o p er a tions (such as unitary op erato rs and measur e men ts). In this sense, this pap er is ab out the se ma n tics of a generic call-by-v alue linear lambda calculus, which is par a metric on some primitive o per ations that are not further explained. It should b e understo o d, howev er, that the need to supp ort pr imitive quantum op erations motiv ates particular features o f the type sys tem, which we briefly expla in now. The first imp orta n t la nguage feature is linearity . This arises from the well- known no-cloning prop erty of quantum computation, which ass erts that q ua n- tum data cannot b e duplicated [23 ]. So if x : qbit is a v ariable representing a quantum bit, and y : bit is a v ar iable r epresenting a classica l bit, then it is legal to write f ( y , y ), but not g ( x, x ). In o rder to keep tr ack of duplicabilit y at higher- order types w e use a type system ba sed on linea r lo g ic. W e use the duplicabilit y op erator “ !” to mark classical t y pes . In the categorica l s emantics, this o per ator gives rise to a comonad as in the work of [1 6 ] a nd [6]. Another account of mix- ing copy a ble and no n-copy able data is [10 ], where the copy a bilit y is internal to ob jects. A sec o nd feature of quantum computation is its probabilistic nature. Quan- tum ph ysics has an op eration ca lled mea surement, whic h conv erts quantum data to classica l data, and whos e outcome is inher en tly probabilistic. Given a q ua n- tum sta te α | 0 i + β | 1 i , a measurement will yield output 0 with pr o bability | α | 2 and 1 with proba bilit y | β | 2 . T o model this probabilistic effect in o ur call-by-v alue setting, our s emantics requir e s a co mputational monad in the sense of [14 ]. The co existence of the computational monad T a nd the duplicability comona d ! in the same categor y is what makes our sema n tics interesting and novel. It differs from the w o rk of [7], who cons idered a mona d a nd a comonad one tw o different categorie s, arising fro m a sing le adjunction. The computational asp ects of linear logic hav e b een extensively explored by many authors , including [8 , 6, 5, 1, 22]. Howev er, these w o rks contain explicit lambda terms to witness the structur a l rules of linear logic, for ex ample, x : ! A ⊲ derelict( x ) : A . By contrast, in o ur language, structural r ules are implicit a t the term level, so that ! A is regarded as a subtype of A and one writes x : ! A ⊲ x : A . As we have shown in [19 ], linearity information can a utomatically b e inferred by the type chec ker. This allows the progra mmer to pro g ram as in a non-linea r language. This use of subtyping is the main technical co mplica tion in our pro of of well- definedness of the seman tics . This is be cause one has to show that the denotatio n is indep endent of the choice o f a potentially larg e num b er of po ssible deriv ations of a g iven typing judgment. W e ar e fo r ced to introduce a Churc h-s tyle typing system, and to prove that the semantics finally do es not depend on the additional t y pe annota tio ns. Another technical choice we made in our la nguage concerns the rela tion b e- t ween the ex po nen tia l ! and the pairing op eration. Linea r logic only req uires ! A ⊗ ! B ⊲ !( A ⊗ B ) and not the oppos ite implication. How ever, in our pro- gramming languag e setting, we find it natural to identify a classica l pair of v a lues with a pa ir of classica l v alues, and therefore we will hav e an isomorphis m ! A ⊗ ! B ∼ = !( A ⊗ B ). The pla n of the pap er is the following. First, we describ e the lambda calcu- lus and equationa l axioms we wish to consider . Then, we develop a ca tegorica l mo del, called linea r category for duplica tion, which is inspir ed by [8] a nd [14]. W e then show that the la nguage is an internal lang ua ge for the catego ry , thus obtaining s o undness and completeness. 2 The language W e will describ e a linear typed la m b da ca lculus with higher -order functions and pair s. The language is designed to manipulate b oth cla ssical data, which is duplicable, and qua n tum data, whic h is non-duplicable. F or simplicit y , we assume the la ng uage is strictly linear, a nd not affine linear as in [19]. This means duplicable v alues are b oth co p yable and disca rdable, whereas non-duplicable v a lues must b e used o nce, and o nly once. 2.1 The t yp e system The set of types is given as follows: T yp e A, B ::= α | ( A ⊸ B ) | ( A ⊗ B ) | ⊤ | ! A . Here α r anges ov er type c o nstants. While the r emainder o f this pa per do es not dep end on the ch o ice of type co nstants, in our main application [19] this is int ended to include a type qbit of quantum bits, and a t yp e bit of cla ssical bits. A ⊸ B stands for functions from A to B , A ⊗ B for pairs, ⊤ for the unit type, and ! A for duplicable ob jects of types A . W e denote !! · · · ! A with n !’s by ! n A . The intuitiv e definition of ! A is the key to the spir it in which we want the language to be under sto o d: The ! on ! A is under sto o d a s sp ecifying a prop erty , rather than a dditional structure, on the elements of A . Therefor e, we will hav e ! A ∼ = !! A . Whether or not a g iven v alue of type A is als o o f type ! A should b e something that is inferred, rather than sp ecified in the co de. Since a term o f type ! A ca n alwa ys b e seen a s a term of type A , we equip the t y pe system with a subt y ping relation as follows: P rovided th at ( m = 0) ∨ ( n > 1), ! n α < : ! m α ( ax ) , ! n ⊤ < : ! m ⊤ ( ⊤ ) , A < : A ′ B < : B ′ ! n ( A ′ ⊸ B ) < : ! m ( A ⊸ B ′ ) ( ⊸ ) , A < : A ′ B < : B ′ ! n ( A ⊗ B ) < : ! m ( A ′ ⊗ B ′ ) . ( ⊗ ) . This relation encapsula tes the main prop erties terms should sa tisfy with resp ect to duplicabilit y . 2.2 T erms The language consists of the following typed terms, divided into values on the one hand, and genera l ter ms , or c omputations , o n the other. Both share a subset of the v alues, the c or e values . Cor eV alue U ::= x A | c A | ∗ n | λ n x A .M , V alue V , W ::= U | h V , W i | let x A = V in W | let h x A , y B i n = V in W | let ∗ = V in W , T erm M , N ::= U | h M , N i | ( M N ) | let h x A , y B i n = M in N | let ∗ = M in N , where n is an integer, c ranges ov er a set of constan t terms, x ov er a set of term v ar iables and α ov er a set of constant types. W e abbreviate ( λ 0 x A .M ) N by let x A = N in M , λ n x ! m ⊤ . let ∗ = x ⊤ in M b y λ n ∗ m .M a nd we o mit numerical indexes when they are n ull. Note that the ab ove terms carr y Churc h-style t yp e a nnotations, a s w ell as int eg er sup ers cripts; we call these terms indexe d terms . W e also define a notion of u ntyp e d terms as terms with no index: Pur eT erm M , N ::= x | c | ∗ | λx.M | ( M N ) | h M , N i | let h x, y i = M in N | let ∗ = M in N . The erasur e op eratio n Er ase : T erm → Pur eT erm is defined a s the oper ation of removing the types a nd integers attached to a given indexed term. If M = Er ase ( ¯ M ), w e say that ¯ M is a n indexation of M Finally , w e define an α -equiv alence on ter ms, deno ted by = α , in the usual wa y (see for e x ample [3]). 2.3 Duplicable pairs and pairs of dupl i cable elem en ts Before we fo r mally present the t yp e sys tem, let us infor mally motiv ate o ur choice of t y ping rules. One non-o b v ious choice we had to make is for the interaction of pairs and duplicability . Unlik e prev io us works with comonads [8, 5], w e wan t to think of the type !( A ⊗ B ) as a type of pairs of elements o f type A and B : we wan t to use the same op er a tion to acces s the comp onents a s one would use for a pair of t y p e A ⊗ B , without having to use a dereliction o per ation. This immediately raise s a concer n: consider a pair of e lemen ts h x, y i of type !( A ⊗ B ). Are x a nd y duplicable? In the usual linear logic interpretation, they are not. Ha ving a infinite supply of pair of s ho e s does not mean o ne has an infinite supply of right sho es: we cannot discar d the left sho es. On the other hand, in our interpretation of “cla s sical” data a s residing in “classical” memory and therefore being duplicable, if the str ing h x, y i is duplicable, then so sho uld be the elements x and y . In other words, w e want the duplica tion to “p ermeate” the pa ir ing. The choice of such a “pe rmeable” pair ing is mo r e or less forced o n us by our desire to hav e no explicit term s y n ta x for structural rules. Consider the following un type d terms, which can b e t yp ed if t is of type !( A ⊗ !( B ⊗ C )): let h x, u i = t in let h y , z i = u in hh z , y i , x i , (1) let h x, u i = t in h let h y , z i = u in h z , y i , x i . (2) First, w e exp ect thes e tw o terms to b e a xiomatically equa l. T erm (2) should b e of t y pe !(!( C ⊗ B ) ⊗ A ), reg ardless o f the per meability of the pairing: if h y , z i is duplicable, so s hould be h z , y i . No w, consider the term (1 ) with a non-p ermea ble pairing. In the naive t yp e system, u ends up b eing of type B ⊗ C , and the v aria bles y and z in the final recombination end up b eing resp ectively of type B and C . It is not pos sible to make h z , y i of the duplicable type !( C ⊗ B ). W e ther e fore cho ose a p ermeable pairing , which will b e reflected, alb eit sub- tly , in the t yping rule ( ⊗ .I ) and ( ⊗ .E ) in the following section. A < : B ! ∆, x : A ⊲ x B : B ( ax 1 ) A c < : B ! ∆ ⊲ c B : B ( ax 2 ) Γ 1 , ! ∆ ⊲ M : A ⊸ B Γ 2 , ! ∆ ⊲ N : A Γ 1 , Γ 2 , ! ∆ ⊲ M N : B ( app ) ∆, x : A ⊲ M : B ∆ ⊲ λ 0 x A .M : A ⊸ B ( λ 1 ) ! ∆, x : A ⊲ M : B ! ∆ ⊲ λ n +1 x A .M : ! n +1 ( A ⊸ B ) ( λ 2 ) ! ∆ ⊲ ∗ n : ! n ⊤ ( ⊤ .I ) ! ∆, Γ 1 ⊲ M 1 : ! n A 1 ! ∆, Γ 2 ⊲ M 2 : ! n A 2 ! ∆, Γ 1 , Γ 2 ⊲ h M 1 , M 2 i n : ! n ( A 1 ⊗ A 2 ) ( ⊗ .I ) ! ∆, Γ 1 ⊲ M : ⊤ ! ∆, Γ 2 ⊲ N : A ! ∆, Γ 1 , Γ 2 ⊲ l et ∗ = M in N : A ( ⊤ .E ) ! ∆, Γ 1 ⊲ M : ! n ( A 1 ⊗ A 2 ) ! ∆, Γ 2 , x 1 : ! n A 1 , x 2 :! n A 2 ⊲ N : A ! ∆, Γ 1 , Γ 2 ⊲ l et h x A 1 1 , x A 2 2 i n = M in N : A ( ⊗ .E ) T able 1. Typing rules 2.4 T yping judgmen ts A t y ping judgmen t is a tuple ∆ ⊲ M : A , wher e M is an indexed term, A is a type, and ∆ is a typing context. T o each constant term c we ass ign a type ! A c . A valid typing judgment is a t yping judgmen t that can b e der ived from the t y ping rules in T able 1. W e use the no ta tion ! ∆ for a context where all v ariables hav e a type of the fo rm ! A . Fina lly , when we write a co n tex t Γ , ∆ , we assume the co n tex ts Γ and ∆ to b e disjoint. The following lemmas a re prov ed by structura l induction on terms or type deriv ations a s appro priate. Lemma 1. If V is a value such that ∆ ⊲ V : ! A is a valid t yping judgment, then ∆ = ! ∆ ′ for some c ontext ∆ ′ . ⊓ ⊔ Lemma 2. Consider the fol lowing valid t yping judgment: ∆, x : A ⊲ M : B . Then for every fr e e instanc e x A ′ in M , A < : A ′ . ⊓ ⊔ Definition 1. In a t y ping judgment ∆ ⊲ M : A , a term v ar iable x ∈ | ∆ | is called dummy if x 6∈ FV ( M ). Lemma 3. Any dummy variable x in ∆ ⊲ M : B satisfies ∆ ( x ) = ! A , for some A . Conversely, if ∆ ⊲ M : B is valid and if x 6∈ FV ( M ) , then for al l typ es A the typing judgment ∆, x : ! A ⊲ M : B is valid. ⊓ ⊔ Typing deriv ations a re no t unique p er se . How ever for a given v a lid typing judgement ∆ ⊲ M : A tw o typing deriv atio ns will only differ with res pect to the placement o f dummy variables , namely the un us ed v ariables in context. 2.5 T yp e casting and subs titution Lem ma Lemma 4. Supp ose ∆ ⊲ M : A is a valid typing judgment, and supp ose ∆ ′ < : ∆ and A < : A ′ . Then ther e ex ists a c anonic al valid typing judgment ∆ ′ ⊲ M ′ : A ′ such that Er ase ( M ) = Er ase ( M ′ ) . Mor e over, if M is a value, so is M ′ . Pr o of. By induction on M . ⊓ ⊔ W e will denote this M ′ with { ∆ ′ < : ∆ ⊲ M : A < : A ′ } . If ∆ ′ = ∆ or A ′ = A , we omit them for clar it y . ( β λ ) ∆ ⊲ let x = V i n M ≈ ax M [ V /x ] : A ( β ⊗ ) ∆ ⊲ let h x, y i n = h V , W i n in M ≈ ax M [ V /x, W /y ] : A ( β ∗ ) ∆ ⊲ let ∗ = ∗ in M ≈ ax M : A ( η λ ) ∆ ⊲ λ n x A . { V : ! n ( A ⊸ B ) < : A ⊸ B } x A ≈ ax V : ! n ( A ⊸ B ) . ( β 2 λ ) ∆ ⊲ let x A = N i n x A ≈ ax N : A. ( η ⊗ ) ∆ ⊲ let h x A , y B i n = N i n h x ! n A , y ! n B i n ≈ ax N : ! n ( A ⊗ B ) . ( η ∗ ) ∆ ⊲ let ∗ = N in ∗ n ≈ ax N : ! n ⊤ . ( let 1 ) ∆ ⊲ let − 1 = ( let − 2 = M i n N ) in P ≈ ax let − 2 = M i n let − 1 = N in P : A ( let 2 ) ∆ ⊲ let − 1 = V i n let − 2 = W in M ≈ ax let − 2 = W i n let − 1 = V i n M : A ( let app ) ∆ ⊲ let x A ⊸ B = M in let y A = N in xy ≈ ax M N : B ( let λ ) ∆ ⊲ let x D = V i n λ n y A .M ≈ ax λ n y A . let x D = V i n M : ! n ( A ⊸ B ) ( let ⊗ ) ∆ ⊲ let x A = M in let y B = N in h x A , y B i n ≈ ax h M , N i n : ! n ( A ⊗ B ) ( app < : ) { M : ! n ( A ⊸ D ) < : B ⊸ D ′ }{ N : C < : B } ≈ ax {{ M : ! n ( A ⊸ D ) < : A ⊸ D }{ N : C < : A } : D < : D ′ } ( let ⊗ < : ) l et h x A ′ , y B ′ i n ′ = { M : ! n ( A ⊗ B ) < : ! n ′ ( A ′ ⊗ B ′ ) } in N ≈ ax let h x A , y B i n = M in { ∆, x : ! n A, y : ! n B < : ∆, x : ! n ′ A ′ , y : ! n ′ B ′ ⊲ N } ( let x < : ) l et x A ′ = { M : A < : A ′ } in N ≈ ax let x A = M i n { ∆, x : A < : ∆, x : A ′ ⊲ N } ( let ∗ < : ) l et ∗ = { M : ! m ⊤ < : ! n ⊤} in N ≈ ax let ∗ = M in N T able 2. Axiomatic equ iv alence axioms ( α let ) ∆, x : A ⊲ let y A = x A in M : B ≈ ax ∆, y : A ⊲ M : B ( let ! λ ) ! ∆ ⊲ let x ! C = V in λy .M ≈ ax λ n +1 y . let x ! C = V in M : ! n +1 ( A ⊸ B ) ( let ⊗ 1 ) ∆ ⊲ h V , let − = M in N i ≈ ax let − = M in h V , N i : ! n ( A ⊗ B ) ( let ⊗ 2 ) ∆ ⊲ h let − = M in N , V i ≈ ax let − = M in h N , V i : ! n ( A ⊗ B ) ( let app 1 ) ∆ ⊲ V ( let − = M in N ) ≈ ax let − = M in V N : B ( let app 2 ) ∆ ⊲ ( let − = M in N ) V ≈ ax let − = M in N V : B T able 3. A xiomatic equ iv alence: derived rules Definition 2. Given t wo v alid t yping judgments ! ∆, Γ 1 ⊲ V : A and ! ∆, Γ 2 , x : A ⊲ M : B where V is a v alue, we define the substitu tion (with capture avoiding) ! ∆, Γ 1 , Γ 2 ⊲ M [ V /x ] : B as follows: we replace ea c h free ins tance x A ′ (where A < : A ′ from Lemma 2) in M by { ∆ ⊲ V : A < : A ′ } . Lemma 5 (Substitution Lemma). In Definition 2, ! ∆, Γ 1 , Γ 2 ⊲ M [ V /x ] : B is wel l- t yp e d. A lso, if M is a value, so is M [ V /x ] . Pr o of. P r o of by structural induction o n M , using Lemmas 2 and 4. ⊓ ⊔ 2.6 Axiomatic equiv alence W e define an equiv alence relation on (indexed) typing judgments. W e write ∆ ⊲ M ≈ ax M ′ : A , or simply M ≈ ax M ′ , to indicate that ∆ ⊲ M : A and ∆ ⊲ M ′ : A a re equiv alent. Axiomatic equiv a le n t is defined a s the reflexive, symmetric, transitive, and co ngruence closure of the r ules from T ables 2, so long as both sides o f the eq uiv ale nces ar e well-t yp ed. The symbol “ − ” is a pla ce holder for x , ∗ , or h x, y i . Lemma 6. The e quivalenc es of T able 3 ar e derivable. ⊓ ⊔ The following result stipulates that a ll the indexations of a given er asure liv e in the same axioma tic class. In other words, the axioma tic equiv alence cla ss of a term is indep endent of its indexation. Theorem 1. If Er ase ( M ) = Er ase ( M ′ ) and if ∆ ⊲ M , M ′ : A ar e valid typing judgments, then M ≈ ax M ′ . Pr o of ( S ketch). The actua l pro of is long and technical, and is omitted here for space reasons . W e pro ceed by first defining a sp ecial subset of terms, called neutr al terms, for which the Theorem is o bvious. W e then pr ov e that every term is axio matically equiv a lent to a neutral term via a series of rewrite systems. ⊓ ⊔ 3 Linear category for duplication As it was advertised, the structure of the categorica l semantics will closely follow the one pr op osed b y Bierma n [8 ], but with the added t wis t of a co mputational monad ` a la Mogg i [14]. Indeed, since one has tensor pr o duct and a tensor unit, one can exp ect the catego rical mo del to b e symmetric monoidal. Since one can construct candidate maps for building a comona d, a comonoid s tructure for each ! A and co herence maps for the comonad, we hav e a linear c ategory . Finally , the computational asp ect will be taken care by Mog gi’s computational monad. 3.1 Linear exp onential como nads In his P h.D. thesis, Bier man [8] gives the de finitio n o f a line ar c ate gory . W e prefer here the terminology given in [15], and use the concept of line ar exp onential c omonad . Definition 3. Let ( C , ⊗ , ⊤ ) b e a symmetric monoida l category [13], where α A,B ,C : A ⊗ ( B ⊗ C ) → ( A ⊗ B ) ⊗ C , λ A : ⊤ ⊗ A → A , ρ A : A ⊗ ⊤ → A and σ A,B : A ⊗ B → B ⊗ A ar e the usual asso c ia tivit y , left unit, right unit a nd symmetry morphisms. Let ( L, δ, ǫ , d L , d L ) be a monoidal comona d [8], where ǫ A : LA → A , δ A : LA → LLA , d L A,B : LA ⊗ LB → L ( A ⊗ B ) and d L ⊤ : ⊤ → L ⊤ . W e say that L is a line ar exp onential c omonad [15 ] provided that 1. ea c h ob ject in C of the fo r m L A is equipp ed with a comm utative comonoid ( LA, △ A , ♦ A ), wher e △ A : LA → LA ⊗ L A and ♦ A : LA → ⊤ ; 2. △ A and ♦ A are mo noidal natur al trans fo rmations; 3. △ A : ( LA, δ A ) → ( LA ⊗ LA, ( δ A ⊗ δ A ); d A ) and ♦ A : ( LA, δ A ) → ( ⊤ , d L ⊤ ) are L -coalg ebra morphisms; 4. E very map δ A is a co mo noid morphism ( L A, ♦ A , △ A ) → ( L 2 A, ♦ LA , △ LA ). The e q uations for 2–4 a re to be found in T a ble 4. 3.2 Strong monad and T -e xp onen ti als. T o capture the computational effect of the pro babilistic measurement, we use the notion of st r ong monad , a s in [14 ]. Recall that a monad ov er a catego ry C is a tr iple ( T , η , µ ) where T : C → C is a functor, η : id ˙ → T a nd µ : T 2 ˙ → T are natura l tr ansformations and such that T µ A ; µ A = µ T A ; µ A and η T A ; µ A = id T A = T η A ; µ A . Given a ma p f : A → T B , we define the map f ∗ : T A → T B by T f ; µ B . LA ⊗ LB d L A,B △ A ⊗△ B / / ( LA ⊗ L A ) ⊗ ( LB ⊗ LB ) sw ( LA ⊗ L B ) ⊗ ( LA ⊗ LB ) d L A,B ⊗ d L A,B L ( A ⊗ B ) △ ( A ⊗ B ) / / L ( A ⊗ B ) ⊗ L ( A ⊗ B ) ⊤ λ − 1 ⊤ / / d L ⊤ ⊤ ⊗ ⊤ d L ⊤ ⊗ d L ⊤ L ⊤ △ ⊤ / / L ⊤ ⊗ L ⊤ LA ⊗ LB ♦ A ⊗♦ B / / d L A,B ⊤ ⊗ ⊤ λ ⊤ L ( A ⊗ B ) ♦ A ⊗ B / / ⊤ ⊤ id / / d L ⊤ % % L L L L L L L L ⊤ ; L ⊤ ♦ ⊤ 8 8 r r r r r r r r △ A and ♦ A are monoidal natural transforma tions . LA △ A / / δ A LA ⊗ LA δ A ⊗ δ A L 2 A ⊗ L 2 A d L LA,LA L 2 A L △ A / / L ( LA ⊗ LA ) , LA ♦ A / / δ A ⊤ d L ⊤ L 2 A L ♦ A / / L ⊤ ; LA δ A / / △ A L 2 A, △ LA LA ⊗ LA δ A ⊗ δ A / / L 2 A ⊗ L 2 A LA δ A / / ♦ A 7 7 7 7 7 7 L 2 A. ♦ LA ⊤ △ A and ♦ A are L -coalgebra maps. δ A us a comonoid morph ism. T able 4. Eq u ations for a linear exp onential comonad Definition 4. A st r ong monad ov er a monoidal c a tegory C is a mo nad ( T , η , µ ) together with a na tural transfor mation t A,B : A ⊗ T B → T ( A ⊗ B ), called the tensorial st re ngth , sub ject to a n umber of coherence c onditions. R emark 1. If the categ o ry C is sy mmetric, the tensorial s trength t induces tw o natural tr ansformations T A ⊗ T B → T ( A ⊗ B ), namely Ψ 1 : T A ⊗ T B σ T A,T B − − − − − → T B ⊗ T A t T B ,A − − − − → T ( T B ⊗ A ) ( σ T B ,A ; t A,B ) ∗ − − − − − − − − − → T ( A ⊗ B ) , Ψ 2 : T A ⊗ T B t T A,B − − − − → T ( T A ⊗ B ) ( σ T A,B ; t B,A ) ∗ − − − − − − − − − → T ( B ⊗ A ) T σ B,A − − − − → T ( A ⊗ B ) . Note that Ψ 1 and Ψ 2 might not be equal: the map Ψ 1 “ev aluates” the first v aria ble and then the second o ne. The map Ψ 2 do es the opp osite. The s trength is called c ommutative if Ψ 1 = Ψ 2 . Lemma 7. If ( T , η , µ, t ) is a stro n g monad on a symmetric monoidal c ate gory C , then ( T , η , µ, Ψ 1 ) and ( T , η , µ, Ψ 2 ) ar e monoidal monad. ⊓ ⊔ Definition 5. A symmetric mo noidal catego ry ( C , ⊗ , ⊤ ) together with a strong monad ( T , η , µ ) is sa id to hav e T -exp onentials [14 ], or Kleisli exp onentials , if it is equipped with a bifunctor ⊸ : C op × C → C , and a natur al isomo r phism Φ : C ( A, B ⊸ C ) ∼ = − − − − − → C ( A ⊗ B , T C ) . Lemma 8. The map Φ induc es a natur al tr ansformation ε A,B : ( A ⊸ B ) ⊗ A → T B define d by Φ ( id A ⊸ B ) . ⊓ ⊔ 3.3 Idemp otent, strong m onoidal comonad A comona d ( L, ǫ, δ ) on s o me categor y is sa id to b e idemp otent if δ : L ˙ → L L is an iso morphism. A mono idal co monad ( L, δ, ǫ, d L , d L ) is str ong monoidal if d L ⊤ and d L A,B are is omorphisms. Definition 6. Given a monoida l categor y ( C , ⊗ , ⊤ ) with an idemp otent, strong monoidal comona d ( L , ǫ, δ ), a bifunctor ⊸ : C op × C → C , w e define a c anonic al arr ow for C with r esp e ct to duplic ation by induction: F or a ll ob jects A , the arrows id A , ǫ A , δ A , d L ⊤ and d L A,B are canonical. All exp ansions of c anonic al arr ows with r esp e ct to duplic ation are also canonical. An ex pa nsion o f an arrow f : A → B is defined to be either f or any of Lg , X ⊗ g , g ⊗ X , X ⊸ g , g ⊸ X , where g is an ex pa nsion of f and X ra nges ov er the ob jects of the catego ry . Finally , comp ositions o f canonica l arr ows are also canonical. Theorem 2 (Coherence for idemp otent comonads). Give n a c ate gory C with the stru ctur e in Definition 6, if f , g : A → B ar e two c anonic al arr ows with r esp e ct to duplic ation, then they ar e e qual. ⊓ ⊔ 3.4 Linear category fo r duplication W e now hav e enough bac k g round to define a candidate for the categor ic al mo del of the langua ge we des crib e in Section 2. Definition 7. A line ar c ate gory for duplic ation is a categor y C with the follow- ing structur e: – a symmetric monoidal structure ( ⊗ , ⊤ , α, λ, ρ, σ ); – an idemp otent, strongly monoidal, linea r exp onential comonad ( L, δ, ǫ, d L , d L , ♦ , △ ); – a strong monad ( T , µ, η ); – a Kleisli exp onential ⊸ . The c omput ational line ar c ate gory is defined to b e the Kleisli category C T , as defined in [14]. R emark 2. A linear category for duplication gives ris e to a double adjunction C L U L & & ⊥ C F L g g U T ( ( ⊥ C T , . F T f f Here the left adjunction arises fro m the co- Kleisli catego ry C L of the co monad L . It is as in the linear-non-linea r mo dels o f [4], and C L is a category of classical (non-quantum ) v alues. The rig h t adjunction arises from the Kleisli categor y C T of the computational monad T , as in [14]. Here C T is a catego ry of (effectful) quantum computations. 3.5 The category C λ Definition 8. W e can define a category C λ as fo llows: Ob jects are types, and arrows A → B a re axioma tic classes of v alid typing judgmen ts of the for m x : A ⊲ V : B , where V is a v alue. W e define the comp osition of ar rows x : A ⊲ V : B a nd y : B ⊲ W : C to b e x : A ⊲ let y = V in W : C . The identit y on A is set to b e the arr ow x : A ⊲ x : A . Lemma 9. The c ate gory C λ is wel l- defin e d. α A,B,C = x : A ⊗ ( B ⊗ C ) ⊲ let h y , z i = x in l et h t , u i = z i n hh y , t i , u i : ( A ⊗ B ) ⊗ C λ A = x : ⊤ ⊗ A ⊲ let h y , z i = x in let ∗ = y in z : A ρ A = x : A ⊗ ⊤ ⊲ let h y , z i = x in let ∗ = z in y : A σ A,B = x : A ⊗ B ⊲ let h y , z i = x in h z , y i : B ⊗ A η A = x : A ⊲ λ ∗ .x : ⊤ ⊸ A µ A = x : ⊤ ⊸ ( ⊤ ⊸ A ) ⊲ λ ∗ . ( x ∗ ) ∗ : ⊤ ⊸ A t A,B = z : A ⊗ ( ⊤ ⊸ B ) ⊲ l et h x, y i = z in λ ∗ . h x, y ∗i : ⊤ ⊸ ( A ⊗ B ) ǫ A = x : ! A ⊲ x A : A δ A = x : ! A ⊲ x ! 2 A : ! 2 A d ! A,B = z : ! A ⊗ ! B ⊲ let h x, y i = z in h x, y i : !( A ⊗ B ) d ! ⊤ = z : ⊤ ⊲ let ∗ = z in ∗ : ! ⊤ △ A = x : ! A ⊲ h x, x i : ! A ⊗ ! A ♦ A = x : ! A ⊲ ∗ : ⊤ ( x : A ⊲ V : B ) ⊗ ( y : C ⊲ W : D ) = z : A ⊗ B ⊲ let h x, y i = z in h V , W i : C ⊗ D ( x : A ⊲ V : B ) ⊸ ( y : C ⊲ W : D ) = z : B ⊸ C ⊲ λ x. ( let y = z V in W ) : A ⊸ D ( x : A ⊲ V : ⊤ ⊸ B ) ∗ = y : ⊤ ⊸ A ⊲ λ ∗ . let x = ( y ∗ ) in ( V ∗ ) : ⊤ ⊸ B Φ A,B,C ( x : A ⊲ V : B ⊸ C ) = t : A ⊗ B ⊲ λ ∗ . l et h x, y i = t in V y : ⊤ ⊸ C T able 5. D efinitions of maps and op erations on maps in C λ Pr o of. The co mpo sition of tw o ar rows yields an arrow a xiomatically equiv alent to a v alue due to Axiom ( β λ ) and Lemma 5. Co mpo sition is asso c ia tive due to Axiom ( let 1 ). The arrow x : A ⊲ x : A is indeed the identit y o n A due to a xioms ( α let ) a nd ( β 2 λ ). ⊓ ⊔ Lemma 10. Given a valid typing judgment ∆ ⊲ V : A wher e V is a value, ther e exists a c anonic al value V ′ such t hat Er ase ( V ′ ) = Er ase ( V ) and such that ! ∆ ⊲ V ′ : ! A . We denote this V ′ by { ! ∆ < : ∆ ⊲ V : A : > A ′ } . Pr o of. By induction on V . ⊓ ⊔ Lemma 11. If ∆ ⊲ V ≈ ax W : A , and if V ′ = { ! ∆ < : ∆ ⊲ V : A : > A ′ } and W ′ = { ! ∆ < : ∆ ⊲ W : A : > A ′ } , then V ′ ≈ ax W ′ . Pr o of. By induction on V ≈ ax W . ⊓ ⊔ Theorem 3. If we define T ( A ) := ⊤ ⊸ A and L ( A ) =! A , to gether with t he maps and the op er ations on maps define d in T able 5, C λ is a line ar c ate gory for duplic ation. Pr o of. The pr o of is mainly a long list of verifications. It uses Theor em 1 , Lem- mas 9, 10 a nd 1 1. ⊓ ⊔ 4 Denotational seman t ics 4.1 In terpretation of the l anguage The lambda-calc ulus defined in Section 2 is thought as a c omputational lambda- calculus. Using Moggi’s technique, we split the interpretation of the language int o the interpretation of the values in a linea r catego r y for duplication C a nd the interpretation of the c omputations , i.e. gener al terms, in its K leisli categ ory C T . Without lo ss of generality , for no tation purp ose s, we ass ume the category to be strictly monoidal. W e define an int erpr et ation of t he t yp e syst em to b e a map Θ that assig ns to ea ch constant type α a n ob ject Θ ( α ). Each t yp e A is interpreted as an o b ject of C : [ [ α ] ] Θ = Θ ( α ), [ [ ⊤ ] ] Θ = ⊤ , [ [! A ] ] Θ = L [ [ A ] ] Θ , [ [ A ⊗ B ] ] Θ = [ [ A ] ] Θ ⊗ [ [ B ] ] Θ and [ [ A ⊸ B ] ] Θ = [ [ A ] ] Θ ⊸ [ [ B ] ] Θ . Given a v alid subt y ping A < : B , ther e exists a ca nonical arr ow [ [ A ] ] Θ → [ [ B ] ] Θ in C with resp ect to duplication, a s defined in Definition 6. Mor eov er, this arrow is unique b y Theo r em 2 . W e ex tend the map Θ to in ter pret A < : B a s this uniq ue arrow and we denote it by I A,B . W e use the following straightforward sho rtcut definitions, wher e A, A ′ , B , B ′ are type s and ∆ , Γ and Γ ′ are typing contexts: – Split ! ∆,Γ ,Γ ′ : [ [! ∆ ] ] ⊗ [ [ Γ ] ] ⊗ [ [ Γ ′ ] ] → [ [! ∆ ] ] ⊗ [ [ Γ ] ] ⊗ [ [! ∆ ] ] ⊗ [ [ Γ ′ ] ] . – Given f : [ [! ∆ ] ] ⊗ [ [ Γ ] ] → [ [ A ] ] and g : [ [! ∆ ] ] ⊗ [ [ Γ ′ ] ] → [ [ B ] ], we define the map f ⊗ ! ∆ g : [ [! ∆ ] ] ⊗ [ [ Γ ] ] ⊗ [ [ Γ ′ ] ] → A ⊗ B . – Given a natural tr ansformation n A : F A → GA , if ∆ = { x 1 : A 1 . . . x n : A n } we define n ∆ = n [ [ A 1 ] ] ⊗ . . . ⊗ n [ [ A n ] ] . Definition 9. The map Θ is said to b e an interpr etation of t he language if moreov e r it as signs to each constant term c : A c an a r row Θ ( c ) : ⊤ → [ [ A c ] ] in C . Given a linear catego r y for duplication C , it is p ossible to interpret the typing deriv ation of a w ell-typed v alue a s a map in C a nd the t yping der iv a tion of a v alid computation a s a ma p in the Kleisli ca teg ory C T . W e define them inductively . – If x 1 : A 1 , . . . x n : A n ⊲ V : B is a v a lue with typing deriv ation π , its value interpr etation [ [ π ] ] v Θ is an arrow [ [ A 1 ] ] ⊗ . . . ⊗ [ [ A n ] ] → C [ [ B ] ]; – if x 1 : A 1 , . . . x n : A n ⊲ M : A is a term with typing der iv atio n π , its c omputational interpr etation [ [ π ] ] c Θ is an ar row [ [ A 1 ] ] ⊗ . . . ⊗ [ [ A n ] ] → C T ([ [ B ] ]). T able 6 fo r mu la tes the definition in the simple case where the co n tex ts ∆ , Γ 1 and Γ 2 contain o nly one v a r iable. One can ea sily extend this to the general setting. As we already noted in Section 2.4 , a v alid typing judgment do es no t have a unique typing tree p er se . How ever the following result holds: Theorem 4. Given a valid typing judgment with t wo typing derivations π and π ′ , for any interpr etation Θ we have [ [ π ] ] c Θ = [ [ π ′ ] ] c Θ (and [ [ π ] ] v Θ = [ [ π ′ ] ] v Θ if the typing judgment is a value). Pr o of. The pro of is done by showing that given any typing judgment ∆ ⊲ M : A with de no tation f one can factor f as ♦ ! Γ ⊗ ¯ f , whe r e ¯ f is the denotation o f ∆ ′ ⊲ M : A , where ∆ ′ , ! Γ = ∆ a nd | Γ | is the set of dummy v ariables . ⊓ ⊔ Definition 10. Given a in terpr etation Θ of the language in a c a tegory C , we de - fine the denotation of a v alid t yping judgment ∆ ⊲ M : A with typing deriv ation π to b e [ [ ∆ ⊲ M : A ] ] c Θ = [ [ π ] ] c Θ and [ [ ∆ ⊲ M : A ] ] v Θ = [ [ π ] ] v Θ if M is a v alue. Interpretation of core values: [ [! ∆, x : A ⊲ x : B ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ A ] ] ♦ ∆ ⊗ I A,B − − − − − − − → [ [ B ] ] [ [! ∆ ⊲ c : B ] ] v Θ = [ [! ∆ ] ] ♦ ∆ − − → ⊤ Θ ( c ) − − − → [ [ A c ] ] I A c ,B − − − − → [ [ B ] ] [ [! ∆ ⊲ ∗ : ! n ⊤ ] ] v Θ = [ [! ∆ ] ] ♦ ∆ − − → ⊤ d L ⊤ − − → L ⊤ I ! ⊤ , ! n ⊤ − − − − − → L n ⊤ [ [ ∆, x : A ⊲ M : B ] ] c Θ = [ [ ∆ ] ] ⊗ [ [ A ] ] f − → T ([ [ B ] ]) [ [ ∆ ⊲ λ x.M : A ⊸ B ] ] v Θ = [ [ ∆ ] ] Φ − 1 ( f ) − − − − − → [ [ A ] ] ⊸ [ [ B ] ] [ [! ∆, x : A ⊲ M : B ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ A ] ] f − → T ([ [ B ] ]) [ [! ∆ ⊲ λx .M : ! n +1 ( A ⊸ B )] ] v Θ = [ [! ∆ ] ] L ( Φ − 1 f ); I !( A ⊸ B ) , ! n +1 ( A ⊸ B ) − − − − − − − − − − − − − − − − − − − − → L n +1 ([ [ A ] ] ⊸ [ [ B ] ]) Interpretation of extended values: [ [! ∆, Γ 1 ⊲ V : A ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → [ [ A ] ] [ [! ∆, Γ 2 , x : A ⊲ W : B ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ [ [ A ] ] g − → [ [ B ] ] [ [! ∆, Γ 2 , Γ 1 ⊲ let x = V in W : B ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ [ [ Γ 1 ] ] id ⊗ ! ∆ f − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ [ [ A ] ] g − → [ [ B ] ] [ [! ∆, Γ 1 , ⊲ V : ! n ( A 1 ⊗ A 2 )] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → L n ([ [ A 1 ] ] ⊗ [ [ A 2 ] ]) [ [! ∆, Γ 2 , x : ! n A 1 , y : ! n A 2 ⊲ W : C ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ L n [ [ A 1 ] ] ⊗ L n [ [ A 2 ] ] g − → [ [ C ] ] [ [! ∆, Γ 2 , Γ 1 ⊲ let h x, y i n = V in W : C ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ [ [ Γ 1 ] ] id ⊗ ! ∆ f − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ L n ([ [ A 1 ] ] ⊗ [ [ A 2 ] ]) id ⊗ “ d L n [ [ A 1 ] ] , [ [ A 2 ] ] ” − 1 − − − − − − − − − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ L n [ [ A 1 ] ] ⊗ L n [ [ A 2 ] ] g − → [ [ C ] ] [ [! ∆, Γ 2 ⊲ V : ⊤ ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] f − → ⊤ [ [! ∆, Γ 1 ⊲ W : C ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] g − → [ [ C ] ] [ [! ∆, Γ 1 , Γ 2 ⊲ let ∗ = V in W : C ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] id ⊗ ! ∆ f − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] g − → [ [ C ] ] [ [! ∆, Γ 1 ⊲ V : ! n A ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → L n [ [ A ] ] [ [! ∆, Γ 2 ⊲ W : ! n B ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] g − → L n [ [ B ] ] [ [! ∆, Γ 1 , Γ 2 ⊲ h V , W i n : ! n ( A ⊗ B )] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] f ⊗ ! ∆ g − − − − → L n [ [ A ] ] ⊗ L n [ [ B ] ] d L n A,B − − − → L n ([ [ A ] ] ⊗ [ [ B ] ] ) Interpretation of computations: First, if U is a core value, [ [ ∆ ⊲ U : A ] ] c Θ = [ [ ∆ ⊲ U : A ] ] v Θ ; η A . [ [! ∆, Γ 1 ⊲ M : A ⊸ B ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → T ([ [ A ] ] ⊸ [ [ B ] ]) [ [! ∆, Γ 2 ⊲ N : A ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] g − → T ([ [ A ] ]) [ [! ∆, Γ 1 , Γ 2 ⊲ M N : B ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] f ⊗ ! ∆ g − − − − → T ([ [ A ] ] ⊸ [ [ B ] ]) ⊗ T ([ [ A ] ]) Ψ 1 − − → T (([ [ A ] ] ⊸ [ [ B ] ]) ⊗ [ [ A ] ]) ε ∗ A,B − − − → T ([ [ B ] ]) [ [! ∆, Γ 1 ⊲ M : ! n ( A 1 ⊗ A 2 )] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → T L n ([ [ A 1 ] ] ⊗ [ [ A 2 ] ]) [ [! ∆, Γ 2 , x : ! n A 1 , y : ! n A 2 ⊲ N : C ] ] v Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ L n [ [ A 1 ] ] ⊗ L n [ [ A 2 ] ] g − → T ([ [ C ] ]) [ [! ∆, Γ 2 , Γ 1 ⊲ let h x, y i n = M in N : ! n C ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] ⊗ [ [ Γ 1 ] ] id ⊗ ! ∆ f − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ T L n ([ [ A 1 ] ] ⊗ [ [ A 2 ] ]) t ; T „ id ⊗ “ d L n ” − 1 « − − − − − − − − − − − − → T ([ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ L n [ [ A 1 ] ] ⊗ L n [ [ A 2 ] ]) g ∗ − → T [ [ C ] ] [ [! ∆, Γ 2 ⊲ M : ⊤ ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] f − → T ( ⊤ ) [ [! ∆, Γ 1 ⊲ N : C ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] g − → T ([ [ C ] ]) [ [! ∆, Γ 1 , Γ 2 ⊲ let ∗ = M in N : C ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] id ⊗ ! ∆ f − − − − − → [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ T ( ⊤ ) t ; g ∗ − − → T ([ [ C ] ]) [ [! ∆, Γ 1 ⊲ M : ! n A ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] f − → T L n [ [ A ] ] [ [! ∆ , Γ 2 ⊲ N : ! n B ] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] g − → T L n [ [ B ] ] [ [! ∆, Γ 1 , Γ 2 ⊲ h M , N i n : ! n ( A ⊗ B )] ] c Θ = [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] f ⊗ ! ∆ g − − − − → T L n [ [ A ] ] ⊗ T L n [ [ B ] ] Ψ 1 ; T d L n A,B − − − − − − → T L n ([ [ A ] ] ⊗ [ [ B ] ]) T able 6. I nterpretatio n of v alues and computations. Lemma 12. Supp ose t hat ∆ ⊲ V : A is a valid typing judgment wher e V is a value. Then [ [ ∆ ⊲ V : A ] ] c = [ [ ∆ ] ] [ [ ∆ ⊲ V : A ] ] v − − − − − − − → [ [ A ] ] η [ [ A ] ] − − − → T ([ [ A ] ]) . Pr o of. P r o of by induction on V , using Lemma 7, the bifunctoriality of ⊗ LA and the eq ua tions for strong mona dicit y in Definition 4. ⊓ ⊔ 4.2 Soundness of the denotation The axiomatic equiv ale nce and the categor ical semantics are t wo faces of the same co in. Indeed, a s we will prove in this section, tw o terms in the same ax - iomatic e q uiv ale nce class have the same denotation. A cor ollary is that the in- dexation of terms do es not influence the denotatio n. This prov es semantically the fact that it is safe to work with unt yp ed terms. An alternate justifica tion of this fac t is of co urse the ope r ational semantics, which was g iven in [19]. Lemma 13. Supp ose M ′ = { ∆ ′ < : ∆ ⊲ M : A < : A ′ } . Then [ [ ∆ ′ ⊲ M ′ : A ′ ] ] c = I ∆ ′ ,∆ ; [ [ ∆ ⊲ M : A ] ] c ; T ( I A,A ′ ) . If M = V is a value, fr om L emma 4, M ′ = V ′ is a value. Then [ [ ∆ ′ ⊲ V ′ : A ′ ] ] v = I ∆ ′ ,∆ ; [ [ ∆ ⊲ V : A ] ] v ; I A,A ′ . Pr o of. P r o of by structural induction o n M . ⊓ ⊔ Lemma 14 (Substitutio n). Given two valid t yping judgments ! ∆, Γ 1 , x : A ⊲ M : B and ! ∆, Γ 2 ⊲ V : A , the typing judgment ! ∆, Γ 1 , Γ 2 ⊲ M [ V /x ] : B is valid. L et h b e [ [! ∆, Γ 1 , Γ 2 ⊲ M [ V /x ] : B ] ] c and h ′ b e [ [! ∆, Γ 1 , Γ 2 ⊲ W [ V /x ] : B ] ] v , in the c ase wher e M = W is a value. Then they ar e define d by [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] Split ! ∆,Γ 1 ,Γ 2 h / / T ([ [ B ] ]) [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] id ⊗ [ [! ∆,Γ 2 ⊲ V : A ] ] v / / [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ A ] ] , [ [! ∆,Γ 1 ,x : A ⊲ M : B ] ] c O O [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ Γ 2 ] ] Split ! ∆,Γ 1 ,Γ 2 h ′ / / [ [ B ] ] [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [! ∆ ] ] ⊗ [ [ Γ 2 ] ] id ⊗ [ [! ∆,Γ 2 ⊲ V : A ] ] v / / [ [! ∆ ] ] ⊗ [ [ Γ 1 ] ] ⊗ [ [ A ] ] . [ [! ∆,Γ 1 ,x : A ⊲ W : B ] ] v O O Pr o of. P r o of by induction on M , using Lemma 1, Lemma 12 and the natura lit y of Φ . ⊓ ⊔ Theorem 5. If ∆ ⊲ M ≈ ax M ′ : A t hen [ [ ∆ ⊲ M : A ] ] c Θ = [ [ ∆ ⊲ M ′ : A ] ] c Θ (and [ [ ∆ ⊲ M : A ] ] v Θ = [ [ ∆ ⊲ M ′ : A ] ] v Θ if M is a value) for every interpr etation Θ . Pr o of. P r o of by induction on M ≈ ax M ′ , using Lemmas 13 and 14. ⊓ ⊔ Corollary 1. If Er ase ( M ) = Er ase ( M ′ ) and if ∆ ⊲ M , M ′ : A ar e valid t yping judgments, then [ [ M ] ] c = [ [ M ′ ] ] c (and [ [ M ] ] v = [ [ M ′ ] ] v if M is a value). Pr o of. Co r ollary of Theorems 1 and 5. ⊓ ⊔ 4.3 Completenes s The categ o ry C λ being a linear category for duplicatio n, one can interpret the language in it. This section states that the defined lambda- calculus is an internal language of linea r catego ries for duplication. Since the ca tegory C λ is a mono idal categor y , one can w.l.o.g . generalize the notion of pairing to finite tenso r pro ducts of terms. Then the fo llowing results are tr ue: Lemma 15. In C λ , a valid typing judgment x 1 : A 1 , . . . x n : A n ⊲ M : B has for c omput ational denotation ( t : A 1 ⊗ · · · ⊗ A n ⊲ let h x 1 , . . . x n i = t in λ ∗ .M : ⊤ ⊸ B ) . If M = V is a value, the value int erpr et ation is ( t : A 1 ⊗ · · · ⊗ A n ⊲ let h x 1 , . . . x n i = t in V : B ) . Pr o of. P r o of by structural induction o n M and V . ⊓ ⊔ Theorem 6. In C λ , Θ b eing the identity, one has [ [ x : A ⊲ M : B ] ] c Θ ≈ ax ( x : A ⊲ λ ∗ .M : ⊤ ⊸ B ) and [ [ x : A ⊲ V : B ] ] v Θ ≈ ax ( x : A ⊲ V : B ) . Pr o of. Co r ollary of Lemma 15 ⊓ ⊔ 5 T o wards a denotational mo del of quan tum lambda calculus As noted in the introduction, this paper is mostly concerned with the categorical requirements for mo deling a generic call-by-v a lue linea r lam b da calculus, i.e., its t y pe system (whic h includes subtyping) a nd equationa l laws. W e hav e no t yet sp ecialized the langua ge to a pa rticular set of built-in op erator s, for exa mple, those that are required for quantum computation. How ever, since the qua n tum lambda calculus [1 9] is the main motiv ation behind our w o rk, we will comment very briefly on what additional prop erties would b e req uir ed to in ter pret its primitives. The quantum lambda calculus is obtained by insta n tia ting and extending the ca ll- b y-v alue language of this pape r with the following primitive t y pes , consta n ts , a nd op er ations: Types: bit , qbit Constants: 0 : ! bit , 1 : ! bit new : !( bit ⊸ qbit ), U : !( qbit n ⊸ qbit n ), me as : !( qbit ⊸ ! bit ) Op erations: Γ 1 , ! ∆ ⊲ P : bit Γ 2 , ! ∆ ⊲ M : A Γ 2 , ! ∆ ⊲ N : A Γ 1 , Γ 2 , ! ∆ ⊲ if P then M else N : A ( if ) Here, U rang es ov er a set of built-in unitar y oper ations. In the in tended semantics, ! bit ∼ = bit , while ! qbit is empty . n ew creates a new qubit, and me as measures a qubit. The denotational semantics of these op era tions is alre a dy well-understo o d in the a bsence of higher-or der types. They ca n all be interpreted in the catego ry Q of supe rop erator s from [18]. The par t tha t is not y et well-understoo d is how these features interact with higher-or der types . In light of our present w ork, we can conclude that a mo del of the quantum lambda calculus co nsists of a linea r categor y for duplication ( C , L, T , ⊸ ), such that the as s o ciated category of co mputatio ns C T contains the categor y Q of [18 ] as a full monoidal sub categ o ry . T o construct a n a ctual instance of such a mo del is still an op en problem. 6 Conclusion W e hav e developed a call-by-v alue, computatio na l la m b da- calculus for manip- ulating duplicable and non-duplicable data, together w ith an ax iomatic equiv- alence relation o n typed terms. W e use a s ubt yping relation in order to hav e implicit pr omotion, dereliction, copying a nd discar ding. Then we developed cat- egorica l mo del for the langua g e, inspired by the w o rk of [8 ] and [14]. W e fina lly show ed that the mode l is sound and complete with respect to the a xiomatic equiv alence. References 1. Abramsky , S.: Computational interpretations of linear logic. Theoretical Computer Science 111 (1993) 3–57 2. Abramsky , S., Co ecke, B.: A categorical semantics of qu antum protocols. In: Proceedings of LICS’04. (2004) 415–425 3. Barendregt, H.P .: The Lambda-Calculus, its Syntax and Semantics. North Holland (1984) 4. Benton, N.: A mixed linear and non-linear logic: Proofs, terms and mo dels (ex- tended abstract). In: Pro ceedings of CSL’94, S elected Papers. V olume 933 of Lec- ture N otes in Computer Science. (1994) 121–13 5 5. Benton, N., Bierman, G., de P aiva , V.C.V., Hy land, M.: A term calculus for intuitionis t ic linear logic. In: Proceedings of TLCA’93. V olume 664 of Lecture Notes in Computer Science. (1993) 75–90 6. Benton, N., Bierman, G., H y land, M., de Paiv a, V.C.V.: Linear lam b d a- calculus and categorical mo dels revisited. In : Proceedings of CSL’92, Selected Papers. V olume 702 of Lecture Notes in Computer S cience. (1992) 7. Benton, N., W adler, P .: Linear logic, monads and the lambda calculus. In: Pro- ceedings of LI CS’96. (1996) 420–431 8. Bierman, G.: On Intuitionistic Linear Logic. PhD thesis, Computer Science De- partment, Cam bridge U niversi ty (1993) 9. Coeck e, B.: Qu antum information-flo w, concretely , abstractly . [17] 57–73 10. Coeck e, B., Pa vlovic, D.: Quantum measurements without sums. In Chen, G., Kauffman, L., Lomonaco, S.J., eds.: Mathematics of Q uantum Computation and T echnolo gy . Chapman & H all (2007) 559–59 6 11. Ga y , S.J., Nagara jan, R.: Comm unicating quantum pro cesses. In: Proceedings of POPL’05, ACM Press (2005) 12. Lalire, M., Jorrand, P .: A pro cess algebraic approach to concurrent and distributed computation: operational semantics. [17] 109–126 13. Mac Lane, S.: Categories for th e W orking Mathematician. Springer V erlag (1998) 14. Moggi, E.: Notions of comp u tation an d monads. In formation and Computation 93 ( 1991) 55–92 15. Schalk, A.: What is a mo del for linear logic. Man uscript (2004) 16. Seely , R.A.G.: *-autonomous categories and cofree coal gebras. Contemporary Mathematics 92 (1989) 17. Selinger, P ., ed.: Pro ceedings of QPL’04. TUCS General Pub lication No 33, T urku Cen t re for Computer Science (2004) 18. Selinger, P .: T ow ards a q uantum programming language. Mathematical Structu res in Computer Science 14 (2004) 527–586 19. Selinger, P ., V aliron, B.: A lambda calculus for quantum computation with classical contro l. Mathematical S tructures in Computer Science 16 (2006) 527–55 2 20. Selinger, P ., V aliron, B.: On a fully abstract model for a quan t um linear fun ct ional language. In: Preliminary p roceedings of Q PL’06. (2006) 103–115 21. v an T onder, A.: A lam b d a calculus for quantum computation. SIAM Journal of Computing 33 (2004) 1109–113 5 22. W adler, P .: There’s no substitute for linear logic. Man uscript, presented at MFPS’92 (1992) 23. W o otters, W.K., Zurek, W.H.: A single quantum cannot b e cloned. Nature 299 (1982) 802–80 3
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment