<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Measurements in quantum programming language QML</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Nely Plata-Cesar</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>J. Raymundo Marcial-Romero</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>J. Antonio Hernandez-Serv n</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Facultad de Ingenier a Universidad Autonoma del Estado de Mexico</institution>
        </aff>
      </contrib-group>
      <fpage>159</fpage>
      <lpage>168</lpage>
      <abstract>
        <p>We present a proposal to add measurement operators to the quantum programming language QML, this strategy modifying the semantics on projections of products ( ), by adding some rules to allow measurements.</p>
      </abstract>
      <kwd-group>
        <kwd>Functional quantum programming</kwd>
        <kwd>QML</kwd>
        <kwd>Measurement</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Programming languages are an important eld in computer science and
quantum physics. In the last eld it allows to represent algorithms applying quantum
properties. Among the quantum programming languages, quantum lambda
calculus q and QML can be mentioned, being functional programming languages
and the foundations.</p>
      <p>The properties that quantum languages have are that programs operate with
quantum data, that is, superpositions of the form t t + u u; Operations
are represented with matrix and can be applied to superpositions, also having
mixed states and nally to allow quantum measurements.</p>
      <p>Quantum measurements on a system determine the probability that an
experiment will happen. These occur with some interference (observer) or some
phenomenon of nature that happens in these system, these measurements
generate irreversibility once they occur.</p>
      <p>
        The measurements in a programming language make it possible to move from
the quantum to the classical environment, emitting the output of a program.
The contribution of measurements to some languages, has been gradual, for
example, the incorporation of measurements in quantum lambda happens after
its de nition [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>
        Lambda calculus is a representative and useful language to theoretically
study the foundations of mathematics and recursion [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. Van Tonder
proposes quantum lambda calculus q, with the mentioned above properties [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
Subsequently, D az-Caro, Arrighi, et al. incorporate a family of measurement
operators to q calculus [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        q calculus in its initial de nition does not incorporate measurements, similar
to the QML language, which has a semantics with quantum data and control,
but without measurements. In this paper the measurements are added to QML,
taking as a guide the work carried out by D az-Caro, et al. [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>Organization: This article is structured as follows: In chapter 2, you will nd
the de nition of the QML language and general concepts of quantum
measurements. In chapter 3, the description of the quantum lambda calculus language.
Chapter 4, presents the contribution of adding measurement operators to QML.
This proposal will be found as an example. And nally in part 5, the conclusions
and future work are summarized.</p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <p>
        Quantum programming language QML
The QML language will be approached from the perspective of Altenkirch,
Grattage, Vizzotto and Sabry, they work on the pure fragment of language and
de ne your semantic model, they also develop a sound and complete equational
theory, omitting recursive types and measurements [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. This latest research will
be retaken, the syntax of terms is:
(Variables) x; y; : : : 2 V ars
(Prob. amplitudes) ; ; : : : 2 C
(Patterns) p; q ::= x j (x; y)
(Terms) t; u ::= x j () j (t; u) j
let p = t in u j 0 j
f alsej truej t j t + u j
if t then u else u0
      </p>
      <p>From the syntax you can form conventional programs such as tuples, let, if,
among others, and in turn append terms with a probability amplitude , that is,
have a probability value that they happen, and also de ne superposition t + u,
it means than a term can be in t and u at the same time.</p>
      <p>The types are given by the grammar: = Q1jQ2j , where Q1 is the
type (), which carry no information and Q2 corresponds to qubits (0 and 1).
Semantically J K = J K J K, where is the standard product type and
returns a tuple.</p>
      <p>Typing contexts ( ; ) are given by: ; x : = j ; x : , where stands for the
empty context. The context correspond to functions from a nite set of variables
to types. For this case, we assume that every variable appears at most once. To
maps pairs of contexts to contexts, the operator is incorporated, with the
following operation:
; x : ; x :
; x :
); x :
); x : si x 2= dom
= (
= (
=</p>
      <p>var
` c : Q2 ` t; u :
` if c then t else u :</p>
      <p>if
f-intro
` f alse : Q2</p>
      <p>` t :
` t :
; x : Q1 ` t :
wk-unit
` t :</p>
      <p>; x : ` t : let
` let x = t in u :
` t :</p>
      <p>` u :
` (t; u) :
` true : Q2
t-intro</p>
      <p>intro
` () : Q1</p>
      <p>elim
unit
The quantum measurements are the third postulate of quantum computing,
interpreted as:</p>
      <p>
        In a quantum system the measurements disturb a system, collapsing from
a quantum to classic state, implying loss of information from the initial state.
Theoretically, the measurements determine how probable a state can collapse,
for example, take the initial state 0 j0i + 1 j1i, when applying a measurement,
it can collapse to j0i with probability j 0j2 or j1i with probability j 1j2 [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>The measurement of state consists of being exposed to an observer, with
the following conditions [7{9]. Let quantum state j'i = Pi j ii:
{ The index mi stands for the measurements outcomes that may occur in the
experiment:
{ Each mi has an associated matrix Mmi , where Mmi are called measurement
operators:
(1)
(2)</p>
      <p>; x : ; y : ` u :
` let (x; y) = t in u :</p>
      <p>m1; m2; : : : ; mi
Mm1 ; Mm2 ; : : : ; Mmi
{ The operators Mmi must satisfy:</p>
      <p>Mm1 Mm1 + Mm2 Mm2 +
+ Mmn Mmn = I
to:
called completeness or completeness equation. This equation guarantees that
the sum of the probabilities of the state is 1.
{ Let j'i be the current state of the system, if it is observed then it collapses</p>
      <p>Mmi j'i , with probability P (mi), where: P (mi) = h'j Mmi Mmi j'i.
jjMmi j'i jj
De nition 1 (Operator). An operator of C2 is a square matrix of dimension
n with complex coe cients.</p>
      <p>De nition 2 (Projection operator). A projection or measurement matrix,
are operators of the form P = j i h j.</p>
      <p>If P = j i h j is a projection operator and is applied to the j'i state, then:
P j'i = (j i h j) j'i
= j i h j'i
= where
j i
2 h j'i</p>
      <p>These measurement operators will be considered to incorporate them into
the QML language.</p>
      <p>Example 1. The base is fj0i ; j1ig, with j0i =
are:
P0 = j0i h0j =
j i =
j0i +
01 (1 0) = 01 00 , P1 = j1i h1j =
j1i, if we apply P0, then:
1
0 ; j1i =</p>
      <p>01 , the operators
01 (0 1) =</p>
      <p>00 01 . Suppose
=
j1i
P0 j i =
Therefore, the application of a measurement operator is conceived as:j i M!i j 0i.
3</p>
      <p>Measurements in Quantum Lambda Calculi
Quantum lambda calculus is a functional language that is not typed and
without measurements, which allows operations and analysis of properties of this and
other languages. After this, a way of adding quantum measurements is
incorporated, allowing us to guide the implementation of the same technique to the
QML language, this is possible since QML is a quantum programming language,
with a functional paradigm, typed and without measurements.</p>
      <p>
        Next we will describe important information and the procedure for adding
measurement operators to the quantum lambda calculi language q [
        <xref ref-type="bibr" rid="ref10 ref5">5, 10</xref>
        ].
      </p>
      <p>q calculus carries a history track to preserve the information needed to
reverse reductions, ensuring that the computing process satis es quantum
properties. A state of this language, after the measurement is irreversibly changed,
even retaining the history track.</p>
      <p>
        Lambda calculus was developed with classical data [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], subsequently,
quantum data is added resulting in q [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. Of q its syntax is reconsidered, which
extends with a family of measurement operators.
      </p>
      <p>Of the most signi cant modi cations, qubits are de ned explicitly, the
constants (of the original syntax) are divided into: qubits, measurement operators
and gates and the measurement operators MI are added. As a result of the
above, the syntax is (Table 3):
( x.t)
!t
(cU )
MI
(q</p>
      <p>q)
(q)
abstraction
nonlinear term
gate-constant
measurement-constant
tensorial product
scalar product
t::=
x
(t t)
( !x.t)
q
q::=
(j0i; j1i)
(q + q)
CU ::=</p>
      <p>H j j X j cnot j : : :
pre-terms:
variable
application
nonlinear abstraction
qubit-constant</p>
      <sec id="sec-2-1">
        <title>Qubit-constants: base-qubit superposition</title>
      </sec>
      <sec id="sec-2-2">
        <title>Gate-constants:</title>
        <p>
          The rules for well-formed terms are found in Fig. 3 of the following article
[
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. With the previous content, we proceed with the description of quantum
measurements in q. The corresponding rule is initially mentioned, and then its
components and functionality will be explained.
        </p>
        <p>The measurement rule is de ned as:</p>
        <p>H; (MI q) !pw</p>
        <p>2m 1
q = X
u=0
uq(u)</p>
        <p>X
{ I indicates the indices or positions that are observed in a measurement. For
example, if I = f2; 3; 5g, the positions 2, 3 and 5 will be observed.
{ q(u) =!q1(u) !q2(u) !qm(u), with !qk(u) =! j0i or ! j1i, for k = 1; : : : ; m. Such
states (in binary) conform to q with their corresponding probability, these
represent all possible values between 0 and 2m 1, for example, the 0 j101i
state in terms of this rule is written as: q(5) = ! j1i ! j0i ! j1i).
{ C(w; m; I),is the set of binary strings of length m, such that they coincide
with w over the letters of index I. Assume w = 010 and the set I = f2; 3; 5g,
in each qubit you will look for the rst 0 (of w) in index 2, 1 in position 3
and 0 in index 5: q1 0 1 q4 0 .
{ pw = X j uj2, is the probability of collapsing to the state w.</p>
        <p>u2C(w;m;I)
{ The notation t !pw t0, means that t goes to t0 with probability pw.</p>
        <p>To conclude this section, a complete example the application of the rule is
shown.</p>
        <p>Example 2. Let m = 3; I = f1; 3g and w = 01.</p>
        <p>Considering C(w; m; I) = C(01; 3; f1; 3g), of the states in q (0 is in index 1, and
1 in the index 3) you get the following:
1 1
p8 !j0i ! j0i !j1i + p8 !j0i ! j1i !j1i
The probability of collapsing with w = 01 in q is given by: pw = j p18 j2 + j p18 j2 =
14 . With this, when measuring we get:</p>
        <p>H; (Mf1;3g q) =
! j0i ! j0i ! j1i
+</p>
        <p>! j0i ! j1i ! j1i
When implementing measurements according to q, it is required to access the
elements of each state, and considering that the types in QML are given by
J rst orKs=ecoJndK eleJmKe,ntthoef ptrhoejepcrtoiojencstiaorne. used which will allow to access to the</p>
        <sec id="sec-2-2-1">
          <title>De nition 3 (Projections).</title>
          <p>{ f st : A
{ snd : A</p>
          <p>B ! A, where f st(a; b) 7! a.</p>
          <p>B ! B, where snd(a; b) 7! b.
()
(A) = 1 A
(A1 : : : ; An) = ( (A1 : : : ; An 1))</p>
          <p>An
For every x 2 A
products, the object</p>
          <p>
            B you have x = (f st(x); snd(x)). In a category with
(A1; : : : ; An) is inductively de ned as:
nite
With this, the projection in : (A1 : : : ; An) ! Ai is generalized, establishing:
nn = snd and in = in 1 f st, when i &lt; n [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ].
          </p>
          <p>This de nition applies in QML to the rules of well-formed terms:
` t :
` f irst t :
f irst</p>
          <p>` t :
` snd t :
snd</p>
          <p>It is also required to de ne a grouping when you have a
applying the following (for associative purposes ):
type, inductively
= Q1</p>
          <p>( 1
14 = (((snd f st) f st) f st)
= ((snd f st) f st) f st (Q1
= (snd f st) f st (Q1
= snd (Q1
1) =
1
3</p>
          <p>4
1)
2
3 = snd f st (Q1
1)
2
With the above rules, we proceed with the incorporation of quantum
measurements.
4.1</p>
        </sec>
        <sec id="sec-2-2-2">
          <title>Quantum Measurement Rule</title>
          <p>The components that will integrate the rule are listed below.
{ m, is the number of sub-terms that compose the qubit q1. For example, in
the following state q1, m = 2:
{ The quantum states in superposition should be expressed in conventional
manner as: Pi2=m0 1 i qi, however, the rule (by de nition) to form
superpositions in QML is q = 1 t1 + 2 t2. Where every t0 in q can be formed
with true; f alse or tuples (true; f alse); (true; (f alse; f alse)); : : : and
superpositions.</p>
          <p>What it means is that the sub-terms t0 can be de ned in terms of others
and successively; once these t0 have the desired type, then they will have
the form Pi2=m0 1 i qi to perform a quantum measurement, for which this
should be apply the red rule in the Table 5.
{ The de nition of I is still conceived as the set of indexes or positions to
consider when measuring q. De ned as:</p>
          <p>I = f i j i 2 N; 1
i
mg
In practical terms this means that if I = f2g in a q state, the indexes to be
observed are identi ed as: p12 p12 (f alse; f alse) + p12 (f alse; true ) + p12
|I={fz2g} I|={fz2}g
p12 (true; true ). The elements of I will determine the</p>
          <p>I|={fz2}g
(true; f alse) + p12
| {z }</p>
          <p>I=f2g
projections im (De nition 3) that will be accessed in each state of a qubit.
{ With respect to w, it is necessary that w = 0; : : : ; 2jIj 1, being the
expected value when measuring. The chosen value w, must be coded in
binary (1 = true; 0 = f alse), as the following example: w = 5, would be
101 true; f alse; true.</p>
          <p>For measurement purposes, the w string is broken down as follows:
w = w1; w2;
; wn; where n
m
The subscripts of w must match I. For example: If I = f1; 3g, w = true; f alse;
so, w = w1; w3 where w1 = true and w3 = f alse.
{ C(w; m; I), it is the function that returns the set of strings of length m, such
that they coincide with the expected values w in the indexes I. This function
can be de ned as:
8i 2 I; 8 t0 t0 in q; if
t0
im(t0) =
t0
wi )
t0 t0 2 C(w; m; I)
where t0 is an irreducible term. For example, taking the equation 3, with
I = f1; 3g; w = f alse; true; m = 3, if it is veri ed that: 8i 2 f1; 3g, 8 t0 t0
| w{z1 } |w{z3}
in q, satisfy t0 i3(t0) = t0 wi, then t0 belongs to that function:
f alse = p18
true = p18
f alse = p18
true = p18
w1, and
w3
w1, and
w3
)</p>
          <p>1
C(w; m; I) = f p8
(f alse; (f alse; true)) + p18
(f alse; (true; true))g</p>
          <p>With the above, the rules for reducing terms described in superpositions and
the measurement rule in QML are deduced.
Let I = f2g; m = 2; w = true and the state q:</p>
          <p>1
(f alse; f alse) + p
2
Performing the measurement with respect to w = f alse:</p>
          <p>MI q 1!=2 u2CX(w;m;I) p1u=2
tu</p>
          <p>X
The addition of a measurement operator in QML, is that given a quantum state
(consisting of sub-terms), it is initially determined with respect to which position
of each sub-state will be measured and the expected value, collapsing to the state
or states that coincide with the above, determining with what probability and
normalizing to the nal state.</p>
        </sec>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Thorsten</given-names>
            <surname>Altenkirch</surname>
          </string-name>
          , Jonathan Grattage,
          <string-name>
            <surname>Juliana K. Vizzotto</surname>
            , and
            <given-names>Amr</given-names>
          </string-name>
          <string-name>
            <surname>Sabry</surname>
          </string-name>
          .
          <article-title>An algebra of pure quantum programming</article-title>
          .
          <source>Electronic Notes in Theoretical Computer Science</source>
          ,
          <volume>170</volume>
          :
          <fpage>23</fpage>
          {
          <fpage>47</fpage>
          ,
          <year>2007</year>
          .
          <source>Proceedings of the 3rd International Workshop on Quantum Programming Languages (QPL</source>
          <year>2005</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Guido</given-names>
            <surname>Bacciagaluppi</surname>
          </string-name>
          .
          <article-title>Is logic empirical? In Kurt Engesser</article-title>
          ,
          <string-name>
            <surname>Dov M. Gabbay</surname>
          </string-name>
          , and Daniel Lehmann, editors,
          <source>Handbook of Quantum Logic and Quantum Structures</source>
          , pages
          <volume>49</volume>
          {
          <fpage>78</fpage>
          .
          <string-name>
            <surname>Elsevier</surname>
          </string-name>
          , Amsterdam,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Paul</given-names>
            <surname>Bernays</surname>
          </string-name>
          .
          <article-title>Alonzo church. an unsolvable problem of elementary number theoSryym. baomlicerLicoagnicj,o1u(r2n)a:7l3o'Afm74a,th1e9m36a</article-title>
          .tics, vol.
          <volume>58</volume>
          (
          <year>1936</year>
          ), pp.
          <fpage>345</fpage>
          '
          <article-title>A 363</article-title>
          . Journal of
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>A.</given-names>
            <surname>Church</surname>
          </string-name>
          .
          <article-title>The Calculi of Lambda-conversion</article-title>
          .
          <source>Annals of Mathematics Studies</source>
          . Princeton University Press,
          <year>1941</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Alejandro D az-Caro</surname>
            , Pablo Arrighi, Manuel Gadella, and
            <given-names>Jonathan</given-names>
          </string-name>
          <string-name>
            <surname>Grattage</surname>
          </string-name>
          .
          <article-title>Measurements and con uence in quantum lambda calculi with explicit qubits</article-title>
          .
          <source>Electronic Notes in Theoretical Computer Science</source>
          ,
          <volume>270</volume>
          (
          <issue>1</issue>
          ):
          <volume>59</volume>
          {
          <fpage>74</fpage>
          ,
          <year>2011</year>
          .
          <source>Proceedings of the Joint 5th International Workshop on Quantum Physics and Logic and 4th Workshop on Developments in Computational Models (QPL/DCM</source>
          <year>2008</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>C.A.</given-names>
            <surname>Gunter</surname>
          </string-name>
          .
          <source>Semantics of Programming Languages: Structures and Techniques. Foundations of Computing</source>
          . MIT Press,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>S.</given-names>
            <surname>Imre</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Balazs</surname>
          </string-name>
          .
          <article-title>Quantum Computing and Communications: An Engineering Approach</article-title>
          . Wiley,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>N. David</given-names>
            <surname>Mermin</surname>
          </string-name>
          .
          <article-title>From cbits to qbits: Teaching computer scientists quantum mechanics</article-title>
          .
          <source>American Journal of Physics</source>
          ,
          <volume>71</volume>
          (
          <issue>1</issue>
          ):
          <volume>23</volume>
          {
          <fpage>30</fpage>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Michael</surname>
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Nielsen and Isaac L. Chuang</surname>
          </string-name>
          .
          <source>Quantum Computation and Quantum Information: 10th Anniversary Edition</source>
          . Cambridge University Press,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Andre van Tonder</surname>
          </string-name>
          .
          <article-title>A lambda calculus for quantum computation</article-title>
          .
          <source>SIAM J. Comput.</source>
          ,
          <volume>33</volume>
          (
          <issue>5</issue>
          ):
          <volume>1109</volume>
          {
          <fpage>1135</fpage>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>