Typing Quantum Superpositions and Measurement
Typing Quantum Superpositions and Measurement
Typing Quantum Superpositions and Measurement
measurement
1 Introduction
:= B | S( ) Qubit types ( )
Typing quantum superpositions and measurement 3
A := | A | S(A) Types (T )
b := x | x : t | |0i | |1i Base terms (B)
v := b | (v + v) | ~0S(A) | .v Values (V)
t := v | tt | (t + t) | t | ? | .t Terms ()
Terms are variables, abstractions, applications, two constants for base qubits
(|0i and |1i), linear combinations of terms (built with addition and product by
a scalar, addition being commutative and associative), a family of constants for
the null vectors, one for each type of the form S(A), (~0S(A) ), and an if-then-
else construction (?) deciding on base vectors. We also include a symbol for
measurement in the computational basis.
The grammar is split into base terms (non-superposed values), general values,
and general terms. Types are also split into qubit types and general types.
The set of free variables of a term t is defined as usual in -calculus and
denoted by F V (t). We use [.]t as a notation to refer indistinctly to .t and
to t. We use t as a shorthand notation for 1.t, and (t r) as a shorthand
notation for (t + (r)). The term (t t) has type S(A), and reduces to ~0S(A) ,
which is not a base term.
An important property of this calculus is that types S() are linear types.
Indeed, those correspond to superpositions, and so no duplication is allowed on
them. Instead, at this tensor-free stage, a type without an S() on head posi-
tion is a non-linear type, such as B, which correspond to base terms, i.e. terms
that can be cloned. A non-linear function is allowed to be applied to a lin-
ear argument, for example, x : B (f xx) can be applied to ( 12 . |0i + 12 . |1i),
however, it distributes in the following way: (x : B (f xx)) ( 12 . |0i+ 12 . |1i)
( 12 .(x : B (f xx)) |0i+ 12 .(x : B (f xx)) |1i) ( 12 .(f |0i |0i)+ 12 .(f |1i |1i)).
Hence, the beta reduction occurs only when the type of the argument is the
same as the type expected by the abstraction. Thus, the rewrite system depends
on types. For this reason, we describe first the type system, and only then the
rewrite system.
A type A will be interpreted as a set of vectors and S(A) as the vector space
generated by the span of such a set (cf. Section 5). Hence, we naturally have
A S(A) and S(S(A)) = S(A). Therefore, we also define a subtyping relation
on types. The type system and the subtyping relation are given in Table 1, where
contexts and have a disjoint support.
Remarks: Rule Ax allows typing variables only with qubit types. Hence, the
system is first-order and only qubits can be passed as arguments (more when
the rewrite system is presented). Rule Ax~0 types the null vector as a non-base
term, because the null vector cannot belong to the base of any vector space.
Rules Ax|0i and Ax|1i type the base qubits with the base type B.
Thanks to rule the term |0i has type B and also the more general type
S(B). Note that ((|0i + |0i) |0i) has type S(B) and reduces to |0i that has the
same type S(B). Reducing this term to |0i of type B would not preserve its type.
Moreover, this type would contain information impossible to compute, because
the value |0i is not the result of a measurement, but of an interference.
4 Alejandro Daz-Caro and Gilles Dowek
AB AB
A S(A) S(S(A)) S(A) A B S(A) S(B)
Ax Ax~0 Ax|0i Ax|1i
x: x: ~0S(A) : S(A) |0i : B |1i : B
t:A t:A u:A + t : S(B)
SI S SE
.t : S(A) , (t + u) : S(A) I t : B
t : A (AB) , x : t : A
If I
t:B ? : B B B B x : t : A
t: A u: t : S( A) u : S( )
E ES
, tu : A , tu : S(A)
t:A , x : B, y : B t : A
W C
, x : B t : A , x : B (x/y)t : A
Rule SI states that a term multiplied by a scalar is not a base term. Even if
the scalar is just a phase, we must type the term with an S() type, because our
measurement operator removes the scalars, so having the scalar means that it
has not been measured yet. Rule SI+ is the analog for sums to the previous rule.
Rule SE is the elimination of the superposition, which is achieved by measuring
(using the operator).
We use r?st as a notation for (?)rst. Notice that it is typed as a non-linear
function by rule If, and so, the if-then-else linearly distributes over superposi-
tions.
Rule ES is the elimination for superpositions, corresponding to the linear
distribution. Notice that the type of the argument is a superposition of the
argument expected by the abstraction (S( ) vs. ). Also, the abstraction is
allowed to be a superposition. If, for example, we want to apply the sum of
functions (f + g) to the base argument |0i, we would obtain the superposition
(f |0i + g |0i). The typing is as follows:
Ax|0i
f :BA g:BA + |0i : B
SI
(f + g) : S(B A) |0i : S(B)
ES
(f + g) |0i : S(A)
which reduces to
Ax|0i Ax|0i
f : B A |0i : B g : B A |0i : B
E E
f |0i : A g |0i : A +
SI
(f |0i + g |0i) : S(A)
Typing quantum superpositions and measurement 5
Ax|0i Ax|1i
f :BA |0i : B |1i : B +
SI
f : S(B A) (|0i + |1i) : S(B)
ES
f (|0i + |1i) : S(A)
which reduces to
Ax|0i Ax|1i
f : B A |0i : B f : B A |1i : B
E E
f |0i : A f |1i : A +
SI
(f |0i + f |1i) : S(A)
l )
X
(.t)u (1) .tu (lin ) ( [i .]bi ) (p) bk (proj)
l
i=1 2
~0S(BA) t (1) ~0S(A) (lin0l ) with p = Pn|k||
2
i=1 i|
t (p) u t (p) u
tv (p) uv (x : B v)t (p) (x : B v)u
t (p) u t (p) u t (p) u
t + v (p) u + v .t (p) u t (p) u
projection ((proj) rule). The rewrite system depends on the typing, in particular
an abstraction can either expect a base term as argument (that is, a non-linear
term) or a superposition, which has to be treated linearly. However, an abstrac-
tion expecting a non-linear argument can be given a superposition (which is lin-
ear), and it is typable, only that the reduction distributes before beta-reduction.
There are two beta rules. Rule (b ) acts only when the argument is a base
term, and the type expected by the abstraction is a base type. Hence, rule (b )
is call-by-base (base terms coincides with values of -calculus, while values
on this calculus also includes superpositions of base terms and the null vector).
Instead, (n ) is the usual call-by-name beta rule. They are distinguished by the
type of the argument. Rule (b ) acts on non-linear functions while (n ) is for
linear functions. The test on the type of the argument is due to the type system
that allows an argument with a type not matching with the type expected by
the abstraction (in such a case, one of the linear distribution rules applies).
Since there are two beta reductions, the contextual rule admitting reducing
the argument on an application is valid only when the abstraction expects an
argument of type B. If the argument is typed with a base type, then it reduces
to a term that can be cloned, and we must reduce it first to ensure that we are
cloning a term that can be cloned. For example, a measure over a superposition
(e.g. (|0i + |1i)) has a base type B, but it cannot be cloned until it is reduced.
Indeed, (x : B (f xx))(|0i + |1i) can reduce either to f |0i |0i or f |1i |1i, but
never to f |0i |1i or f |1i |0i, which would be possible only if the measure happens
after the cloning machine.
The group If-then-else contains the tests over the base qubits |0i and |1i.
The first three of the linear distribution rules (those marked with subindex
r), are the rules that are used when a non-linear abstraction is applied to a
linear argument (that is, when an abstraction expecting a base term is given a
superposition). In these cases the beta reductions cannot be used since the side
conditions on types are not met. Hence, these distributivity rules apply instead.
For example, let us give more details in the reduction sequence on the example
given at the beginning of this Section.
1 1
(x : B (f xx))( . |0i + . |1i)
2 2
+
(linr ) 1 1
(1) ((x : B (f xx)) . |0i + (x : B (f xx)) . |1i)
2 2
(lin
r )
2 1 1
(1) ( .(x : B (f xx)) |0i + .(x : B (f xx)) |1i)
2 2
( ) 2 1 1
b (1) ( .f |0i |0i + .f |1i |1i)
2 2
The remaining rules in this group deal with a superposition of functions. For
example, rule (lin+
l ) is the sum of functions: A superposition is a sum, therefore,
if an argument is given to a sum of functions, it needs to be given to each
function in the sum. We use a weak reduction strategy (i.e. reduction occurs
only on closed terms), hence the argument v on this rule is closed, otherwise, it
Typing quantum superpositions and measurement 7
The type system includes all the typing rules given in the previous section,
plus the rules for tensor, for cast, and an updated rule SE , for which we introduce
the following notation:
S
Definition 3.1. Let SS {1, , n}. We define Qn inductively by:
An1 (B) if n
/S
QSn = S\{n}
An1 (S(B)) if n S
A0 (B) = B
S
Ak (B) B if k + 1
/S
ASk+1 (B) = S\{k+1}
Ak (S(B)) B if k + 1 S
S
S Ak (B) S(B) if k + 1 /S
Ak+1 (S(B)) = S\{k+1}
Ak (S(B B)) if k + 1 S
where B is any type.
In simple words, notation QSn stands for a tensor of n qubits, where those
indexed by the set S are superposed and typed with the most general type,
{1,2}
for example Q3 stands for S(B B) B and not for S(B) S(B) B. The
following example may be clarifying.
{1,2,4} {1,2,4}
Q5 = A4 (B)
{1,2}
= A3 (S(B)) B
{1,2}
= A2 (B) S(B) B
{1}
= A1 (S(B)) B S(B) B
= A0 (S(B B)) B S(B) B
= S(B B) B S(B) B
In addition, we update the subtyping relation adding the following two rules.
AB AB
and .
AC B C C AC B
The updated type system is given in Table 3.
Rules Ax, Ax~0 , Ax|0i , Ax|1i , , SI , SI+ , If, I , E and ES remain un-
changed. Rule SE types the generalized projection: we force the term to be
measured to be typed with a type of the form QSn , and then, after measuring
S\{1,...,j}
the first j qubits, the new type becomes Qn , that is, we remove the su-
perposition mark S() from the first j types in the tensor product. Rules W and
C are updated only to act on types B instead of just B.
Typing quantum superpositions and measurement 9
=
t~0S(B) (1) ~0S(A) (lin0r ) ((u + v) + w) =AC (u + (v + w)) (assoc)
(t + u)v (1) (tv + uv) (lin+l ) If h 6= u v and h B, then
(.t)u (1) .tu (lin l ) head (h t) (1) h (head)
Lists
~0S(BA) t (1) ~0S(A) (lin0l ) If h 6= u v and h B, then
tail (h t) (1) t (tail)
S(AB)
S(S(A)B) S(AB)
((r + s) u) (1) (S(S(A)B) S(AB)
(r u) + S(S(A)B) (s u)) (dist+ r )
+
S(BA) S(BA) S(BA)
S(BS(A)) (u (r + s)) (1) (S(BS(A)) (u r) + S(BS(A)) (u s)) (distl )
S(AB) S(AB)
S(S(A)B) ((.r) u) (1) . S(S(A)B) (r u) (distr )
Typing casts
S(BA) S(BA)
S(BS(A)) (u (.r)) (1) . S(BS(A)) (u r) (distl )
S(AB)
S(S(A)B) (~0S(A) u) (1) ~0S(AB) (dist0r )
S(BA)
S(BS(A)) (u ~0S(A) ) (1) ~0S(BA) (dist0l )
S(BC)
S(A) S(BC)
(t + u) (1) (S(A) t + S(A) S(BC)
u) (dist+
)
S(BC)
S(A) S(BC)
(.t) (1) . S(A) t (dist)
S(AB)
If u B, then, S(S(A)B) (u v) (1) u v (neut r )
S(AB)
If u B, then, S(AS(B)) (v u) (1) v u (neut l )
j ( n
P
i=1 [i .](b1i bmi ))
Projection
(p) jh=1 bhk iP P i
N P
2
.(bj+1,i bmi ) (proj)
iP |i |
|i |2
P
with p = iP Pn | |2
i=1 i
t (p) u t (p) u
tv (p) uv (x : B v)t (p) (x : B v)u
t (p) u t (p) u t (p) u t (p) u
t + v (p) u + v .t (p) u j t (p) j u t v (p) u v
t (p) u t (p) u t (p) u
head t (p) head u tail t (p) tail u S(B) S(B)
S(A) t (p) S(A) u
(r + s) u may have type S(A) B, S(A) S(B) or S(A B), while, among
those, the term (r u + s u) can only have type S(A B). Hence, we cannot
reduce the first term to the second without losing subject reduction. Instead,
we need to cast the term explicitly to the valir type in order to reduce. Notice
S(AB)
that in the previous example it would have been enough to use S(A)B . Indeed,
Typing quantum superpositions and measurement 11
the term (r + s) u can be typed with S(A) B. However, we prefer the more
general S(S(A) B) and hence to use the same rule when, for example, a sum
is given.
The next two rules, (dist+
) and (dist ), distribute the cast over sums and
scalars. For example S(BB)
S(S(B)B) ((. |1i) |0i + (. |0i) |1i) reduces by rule
(dist+ S(BB) S(BB)
) to (S(S(B)B) (. |1i) |0i + S(S(B)B) (. |0i) |1i), and hence, the dis-
tributivity rule can act. The last two rules in the group, (neutr ) and (neutl ), re-
move the cast when it is not needed anymore. For example S(BB)
S(S(B)B) (.. |0i)
(dist
r ) (dist
r ) (neutr )
S(BB)
|1i (1) . S(S(B)B) (. |0i) |1i (1) .. S(BB) S(S(B)B) |0i |1i (1)
.. |0i |1i.
The measurement rule (proj) is updated to measure the first j qubits. Hence,
a n-qubits in normal form (that is, a sum of tensors of qubits with or without
a scalar in front), for example, the term ((2.(|0i |1i |1i) + |0i |1i |0i) +
3.(|1i |1i |1i)) can be measured and will produce a n-qubits where the first
j qubits are the same and the remaining are untouched, with its scalars changed
to have norm 1. In this 3-qubits example, measuring the first two can produce
either |0i |1i ( 25 . |1i + 15 . |0i) or |1i |1i (1. |1i). The probability of
|2|2 |1|2 5
producing the first is (|2|2 +|1|2 +|3|2 ) + (|2|2 +|1|2 +|3|2 ) = 14 and the probability of
|3|2 9
producing the second is (|2|2 +|1| 2 +|3|2 ) = 14 .
Remark, to conclude, that since the calculus presented in this paper is call-
by-base for the functions expecting a non-linear argument, it avoids a well-
known problem in others -calculi with a linear logic type system including
modalities. To illustrate this problem, consider the following typing judgement:
y : S(B) (x : B (x x))(y) : S(B) S(B). If we allow to -reduce this
term, we would obtain (y) (y) which is not typable in the context y : S(B).
A standard solution to this problem is illustrated in [7], where the terms that
can be cloned are distinguished by a mark, and used in a let construction, while
non-clonable terms are used in abstractions.
4 Subject reduction
Thanks to the explicit casts, the resulting system has the Subject Reduction
property (Theorem 4.5), that is, the typing is preserved by weak-reduction
(i.e. reduction on closed terms). The proof of this theorem is not trivial, spe-
cially due to the complexity of the system itself. The detailed proofs with some
additional lemmas are given in the seven-page long Appendix B.
The two main lemmas of the proof, the generation lemma and the substi-
tution lemma, are stated below, together with a few paradigmatic cases of the
proof.
If x : A, then x : , | | \ { } B, and A.
If x : t : A, then , x : t : B, with , B A and
| \ | B.
If |0i : A, then B A and | | B.
If |1i : A, then B A and | | B.
If ~0S(B) : A, then S(B) A and | | B.
If tu : A, then one of the following possibilities happens:
1 t : B and 2 u : , with B A, or
1 t : S( B) and 2 u : S( ), with S(B) A.
In both cases, 1 2 and | | \ |1 2 | B.
If (t + u) : A, then 1 t : B and 2 u : B, with S(B) A and
1 2 , | \ (1 2 )| B.
S\{1,...,j}
If j t : A, then t : QSn , with , | \ | B and Qn
A.
If ? : A, then B B B B A and | | B.
If .t : A, then t : B, with , | \ | B and S(B) A.
If t u : A, then 1 t : B and 2 u : C, with 1 2 ,
| \ (1 2 )| B and B C A.
If head t : A, then t : B B, with , | \ | B and B A.
If tail t : A, then t : B B, with , | \ | B and B A.
If S(B)S(C)
t : A, then t : S(B), with , | \ | B and
S(C) A. Moreover,
If t 6= .t and t 6= (t1 +t2 ), then a rule R allows typing S(B)
S(C)
t : S(C)
directly from t : S(B).
If t = .t , then t : S(B), and a rule R allows typing S(B) S(C)
t :
S(C) directly from t : S(B).
If t = (t1 + t2 ), then for i = 1, 2, i ti : S(B), with = 1 , 2 , and
S(C)
a rule R allows typing i S(B) ti : S(C) directly from i ti : S(B).
Proof. First notice that if t : A is derivable, then t : B is derivable, with
and | \ | B (because of rule W ) and A B, (because of rule ).
Notice also that those are the only typing rules changing the sequent without
changing the term on the sequent. Rules E and ES and are straightforward to
check. All the other rules, except for those involving arrows, are syntax directed:
one rule for each term. Therefore, the lemma is proven by a straightforward rule
by rule analysis for all the items but last.
For the last item, let S(B)S(C)
t : A, then it is clear that S(B)
S(C)
t : S(C),
with S(C) A, and | \ | B. Also, notice that there is always a
S(E) S(E)
Rule allowing typing S(D) u : S(E) if u : S(D), if S(D) is a subterm of a
well-typed term. We finish the proof by induction on t.
Corollary 4.3. If (t + u) : A, then t : A and u : A.
Proof. By Lemma 4.2, t : B and u : B, with B S(B) A, then, we
conclude by rule .
Lemma 4.4 (Substitution lemma). Let F V (u) = , then if , x : t : A,
u : , where if = B then u B, we have , (u/x)t : A.
Typing quantum superpositions and measurement 13
Since the strategy is weak, subject reduction is proven for closed terms.
Theorem 4.5 (Subject reduction on closed terms). For any closed terms
t and u and type A, if t (p) u and t : A, then u : A.
Proof. By induction on the rewrite relation. We only give two cases as example.
5 Interpretation
We consider vector spaces equipped with a canonical base, and subsets of such
spaces.
Let E and F be two vector spaces with canonical bases B = {~bi | i I} and
C = {~cj | j J}. The tensor product E F of E and F is the vector space
of canonical base {~bi ~cj | i I and j J}, where ~bi ~cj is the ordered pair
formed with the vector ~bi and the vector ~cj . The operation is extended to the
vectors of E and F bilinearly: ( i i~bi ) ( j j ~cj ) = ij i j (~bi ~cj ).
P P P
Let E and F be two vector spaces equipped with bases B and C, and S and
T be two subsets of E and F respectively, we define the set S T , subset of the
vector space E F , as follows: S T = {~u ~v |~u S, ~v T }.
Remark that E F differs from E F . For instance, if E and F are C2
equipped with the base {~i, ~j}, then E F contains ~i ~i and ~j ~j but not
~i ~i + ~j ~j, that is not a tensor product of two vectors of C2 .
Let E be a vector space equipped with a base B, and S a subset of E. We
write S(S) for the vector space over C generated by the span of S, that is,
containing all the linear combinations of elements of S.
14 Alejandro Daz-Caro and Gilles Dowek
JxK = x
Jx : tK = {f | a J K, f a JtK,x7J K }
J|0iK = {( 10 )}
J|1iK = {( 01 )}
Jt uK = JtK JuK
J(t + u)K = {a + b | a JtK and b JuK }
J.tK = {a | a JtK }
J0S(B) K = {~0}, the null vector of the vector space JS(B)K
~
P P
g (a) | g JtK , a JuK If t : A
i i i i
(iI
iI )
JtuK = P P P P
i j gi (cj ) | i gi JtK , j cj JuK
iI jJ
iI jJ
If t : S( A)
j
O X
Jj tK = { bhk r Pi 2 (bj+1,i bmi ) | i P, h, bhi = bhk }
|i |
h=1 iP iP
n
X
where JtK = { i (b1i bmi )} with bih = ( 01 ) or ( 10 )
i=1
Typing quantum superpositions and measurement 15
b If a = ( 01 )
J?K = {f | a, b, c JBK, f abc = }
c If a = ( 10 )
Jhead tK = {a1 | a1 an JtK , a1 JBK}
Jtail tK = {a2 an | a1 an JtK , a1 JBK}
S(BC)
JS(A) tK = JtK
6 Examples
In this section we show that our language is expressive enough to express the
Deutsch algorithm (Section 6.1) and the Teleportation algorithm. (Section 6.2).
The Deutsch algorithm tests whether the binary function f implemented by the
oracle Uf is constant (f (0) = f (1)) or balanced (f (0) 6= f (1)). The algorithm
is as follows: it starts with a qubit in state |0i and another in state |1i, and
apply Hadamard gates to both. Then it applies the Uf operator, followed by a
Hadamard and a measurement to the first qubit. When the function is constant,
the first qubit ends in |0i, when it is balanced, it ends in |1i.
The Hadamard gate (H) produces 12 .(|0i + |1i) when applied to |0i and
1 .(|0i |1i) when applied to |1i. Hence, it can be implemented with the if-
2
then-else construction: H = x : B 12 .(|0i + (x?( |1i)|1i)). Notice that the
abstracted variable has a base type (i.e. non-linear). Hence, if H is applied to a
superposition, say (. |0i + . |1i), it reduces, as expected, in the following way:
+
(lin ) (lin )2
H(. |0i + . |1i) r (1) (H. |0i + H. |1i) r (1) (.H |0i + .H |1i)
16 Alejandro Daz-Caro and Gilles Dowek
and then is applied to the base terms. We define H1 as the function taking a
two-qubits system and applying H to the first. H1 = x : B B ((H (head x))
(tail x)). Similarly, Hboth applies H to both qubits.
The gate Uf is called oracle, and it is defined by Uf |xyi = |x, y f (x)i where
is the addition modulo 2. In order to implement it, we need the not gate, which
can be implemented similarly to the Hadamard gate:
not = x : B (x?|0i|1i)
The casts after the Hadamards are needed to fully develop the qubits and
then be able to use it as an argument of a non-linear abstraction (i.e. an abstrac-
tion expecting for base terms and so linear-distributing over superpositions). The
Deutschf term is typed, as expected, by Deutschf : B S(B).
This term, on the identity function, reduces as follows:
1 1 1 1
Deutschid (1) 1 ( . |1i |0i . |1i |1i) (1) |1i( . |0i . |1i)
(proj)
2 2 2 2
The trace on this reduction and the type derivation are given in Appendix D.
Alice
|i H
00 Bob
Z b1 notb2 |i
Remark that the only difference with H1 is the type of the abstracted variable.
In addition, we need to apply cnot to the two first qubits, so we define cnot312 as
The Z gate returns |0i when it receives |0i, and |1i when it receives |1i.
Hence, it can be implemented by:
Z = x : B (x?( |1i)|0i)
The Bob side of the algorithm will apply Z and/or not according to the bits
it receives from Alice. Hence, for any U : B S(B) or U : B B, we define
U(b) to be the function which depending on the value of a base qubit b applies
the U gate or not:
U(b) = (x : B y : B (x?Uyy)) b
Alice and Bob parts of the algorithm are defined separately:
S(BBB)
Alice = x : S(B)S(BB)(2 (S(S(B)BB) H31 (cnot312 S(BS(BB))
S(BBB)
S(S(B)S(BB))
S(BS(BB))
x)))
Notice that before passing to cnot312 the parameter of type S(B) S(B B),
we need to fully develop the term using the two casts, and again, after the
Hadamard gate. Bob side is implemented by
Bob = x : B B B (Z(head x)
(not(head tail x)
(tail tail x)))
7 Conclusion
duplicable data and as non-linear ones when they do not, and illustrated this
idea with the definition of a calculus.
This calculus is first-order in the sense that variables do not have functional
types. In a higher-order version we should expect abstractions to be clonable.
But, allowing cloning abstractions allows cloning superpositions, by hiding them
inside. For example, x : B B ( 12 . |0i + 12 . |1i). It has been argued [4, 5]
that what is cloned is not the superposition but a function that creates the
superposition, because we had no way there to create such an abstraction from
an arbitrary superposition. The situation is different in the calculus presented
in this paper as the term x : S(B) y : B x precisely takes any term t of type
S(B) and returns the term y : B t. So, a cloning machine could be constructed
by encapsulating any superposition t under a lambda, which transform it into a
basis term, so a clonable term. Extending this calculus to the higher-order will
require characterizing precisely the abstractions that can be taken as arguments,
not allowing to duplicate functions creating superpositions.
References
12. Michael Nielsen and Isaac Chuang. Quantum Computation and Quantum Infor-
mation. Cambridge University Press., 2000.
13. Michele Pagani, Peter Selinger, and Benot Valiron. Applying quantitative seman-
tics to higher-order quantum computing. ACM SIGPLAN Notices (POPL14),
49(1):647658, 2014.
14. Gerald E. Peterson and Mark E. Stickel. Complete sets of reductions for some
equational theories. Journal of the ACM, 28(2):233264, 1981.
15. Peter Selinger and Benot Valiron. Quantum lambda calculus. In Simon Gay and
Ian Mackie, editors, Semantic Techniques in Quantum Computation, chapter 9,
pages 135172. Cambridge University Press, 2009.
16. William K. Wootters and Wojciech H. Zurek. A single quantum cannot be cloned.
Nature, 299:802803, 1982.
17. Margherita Zorzi. On quantum lambda calculi: a foundational perspective. Math-
ematical Structures in Computer Science, 26(7):11071195, 2016.
The R 4 gate. The R 4 gate is a single-qubit gate that modifies the phase of
the qubit:
R 4 |0i = |0i ; R 4 |1i =
where 4 is the phase shift.
ei 4 |1i
The H gate. The Hadamard gate is a single-qubit gate which produces a basis
change:
H |0i = 12 |0i + 12 |1i ; H |1i = 12 |0i 12 |1i
To make these gates act in higher-dimension qubits, they can be put together
with the bilinear symbol . For example, to make the Hadamard gate act only
in the first qubit of a two-qubits register, it can be taken to H Id, and to apply
a Hadamard gate to both qubits, just H H.
An important restriction, which has to be taken into account if a calculus
pretends to encode quantum computing, is the so called no-cloning theorem [16]:
Theorem A.1 (No cloning). There is no linear operator such that, given any
qubit |i CN , it can clone it. That is, it does not exist any isometric operator
U and fixed |i CN such that U |i = |i.
Proof. Assume there exists such an operator U , so given any |i and |i one has
U |i = |i and also U |i = |i. Then
hU |U i = h|i (1)
where hU | is the conjugate transpose of U |i. However, notice that the left
side of equation (1) can be rewritten as
h| U U |i = h|i = h|i
C2 , P0 = |0i h0| is a projector and P1 = |1i h1| is another projector, with respect
to such a base. Indeed,
For example,
P0 ( |0i + |1i)
M0 ( |0i + |1i) = p
( h0| + h1|)P0 ( |0i + |1i)
|0i
=p
( h0| + h1|)( |0i)
|0i
=p
|| h0|0i + h1|0i
2
|0i
=p = |0i 5 |0i
|| 2 ||
i ti : S(B).
Corollary 4.3.
If (t + u) : A, then t : A and u : A.
If (t + u) : A, then A = S(B).
If .t : A, then t : A.
If .t : A, then .t : A.
If .t : A, then A = S(B).
Proof.
unclassified := x | x : t
arity0 := ~0S(A) | |0i | |1i | ?
arity1 (r) := j r | .r | head r | tail r | S(CD)
S(B) t
arity2 (r)(s) := rs | (r + s) | r s
Theorem 4.5 (Subject reduction on closed terms). For any closed terms
t and u and type A, if t (p) u and t : A, then u : A.
Proof. We proceed by induction on the rewrite relation.
(b) |1i? : S(2 C), and u : S(2 ), with S(C) 1 B, but this
case is impossible by Lemma B.1.
2. |1i?u : S(1 B) and v : S(1 ), with S(B) A. Then, by
Lemma 4.2 again, one of the following possibilities happens:
(a) |1i? : 2 C, and u : 2 , with CE S(1 B) S(1 A).
Then, by Lemma 4.2 again, one of the following possibilities happens:
i. ? : 3 D, and |1i : 3 , with D 2 C 2
S(1 A). Then, by Lemma 4.2 again, B B B B
3 2 S(1 A), so 2 = B A, and hence, by rule ,
u : A.
ii. ? : S(3 D), and |1i : S(3 ), with S(D) 2 C, but
this case is impossible by Lemma B.1.
(b) |1i? : S(2 C), and u : S(2 ), with S(C) S(1 B) Then,
by Lemma 4.2 again, one of the following possibilities happens:
i. ? : 3 D, and |1i : 3 , with D S(2 C) S(2
S(1 A)). Then, by lemma 4.2 again, B B B B
3 D 3 S(2 S(1 A)). So, 2 = B A, hence,
by rule , u : A.
ii. ? : S(3 D), and |1i : S(3 ), with S(D) S(2 C).
By Lemma 4.2 again, B B B B S(3 D) S(3
S(2 S(2 A))), so 2 = B A, and hence, by rule ,
u : A.
(if0 ) Analogous to case (if1 ).
(lin+r ) Let t(u + v) : A, with t : B B. Then, by Lemma 4.2, one of the
following cases happens:
1. t : C and (u + v) : , with C A. However, since t : B B,
we have B, which is impossible due to Corollary 4.3.
2. t : S( C) and (u + v) : S( ), with S(C) A. Then, by
Corollary 4.3, u : S( ) and v : S( ). Hence,
t : S( C) u : S( ) t : S( C) v : S( )
ES ES
tu : S(C) tv : S(C) +
SI
(tu + tv) : S(S(C))
(tu + tv) : A
(lin
r ) Let t(.u) : A, with t : B B. Then, by Lemma 4.2, one of the
following cases happens:
1. t : C and .u : , with C A. However, since t : B B, we
have B, which is impossible due to Corollary 4.3.
2. t : S( C) and .u : S( ), with S(C) A. Then, by Corol-
lary 4.3, u : S( ). Hence,
t : S( C) u : S( )
ES
tu : S(C)
S
.tu : S(S(C)) I
.tu : A
Typing quantum superpositions and measurement 27
(dist+ +
l ) Analogous to case (distr ).
(dist S(BC)
r ) Let S(S(B)C) ((.r) u) : A. By Lemma 4.2, S(B C) A, and
((.r) u) : S(S(B) C). Then, by the same Lemma, .r : D and
u : E, with D E S(S(B) C). Hence, D S(B) and E C, so by
rule , .r : S(B) and u : C. By Corollary 4.3, r : S(B). Therefore,
r : S(B) u : C
I
r u : S(B) C
r u : S(S(B) C)
S(BC)
r
S(S(B)C) (r u) : S(B C)
S(BC)
SI
. S(S(B)C) (r u) : S(S(B C))
S(BC)
. S(S(B)C) (r u) : A
(dist
l ) Analogous to case (distr ).
(dist0r ) Let S(S(B)C)
S(BC)
(~0S(B) u) : A. By Lemma 4.2, S(B C) A. By rule
~
Ax~0 , 0S(BC) : S(B C). Hence, we conclude by rule .
(dist0l ) Analogous to case (dist0r ).
(dist+ S(CD)
) Let S(B) (t + u) : A. Then, by Lemma 4.2, S(C D) A, S(CD)
S(B)
JA CK = JAK JCK
= {a c | a JAK, c JCK}
{b c | b JBK, c JCK}
= JBK JCK
= JB CK
JC AK JC BK by an analogous reasoning to the previous one.
JS(A)K = SJAK SJBK = JS(B)K.
Lemma 5.2. I f t : A and , x 7 S, y 7 S is a -valuation, then
JtK,x7S,y7S = J(x/y)tK,x7S .
Proof. We proceed by induction on t.
Independent cases. The cases where t does not includes x nor y and the
denotation does not depends on the valuation, are trivial. Those cases are:
|0i, |1i, ~0S(A) and ?.
Let t = x. Then, JxK,x7S,y7S = S = JxK,x7S .
Let t = y. Then, JyK,x7S,y7S = S = JxK,x7S .
Let t = z. Then, JzK,x7S,y7S = z = JzK,x7S .
Let t = z : r. Then,
Jz : rK,x7S,y7S = {f | a J K, f a JrK,x7S,y7S,z7J K }
(by IH) = {f | a J K, f a J(x/y)rK,x7S,z7J K }
= Jz : (x/y)rK,x7S
= J(x/y)z : rK,x7S
Let t = r s. Then,
JrsK,x7S,y7S
P P
{ i gi (a) | i gi JrK,x7S,y7S , a JsK,x7S,y7S } If A = B
iI iI
= P P P P
{ i j gi (cj ) | i gi JrK,x7S,y7S , j cj JsK,x7S,y7S } If A = S( B)
iI jJ iI jJ
(by IH)
P P
{ i gi (a) | i gi J(x/y)rK,x7S , a J(x/y)sK,x7S } If A = B
iI iI
= P P P P
{ i j gi (cj ) | i gi J(x/y)rK,x7S , j cj J(x/y)sK,x7S } If A = S( B)
iI jJ iI jJ
= J(x/y)r(x/y)sK,x7S
= J(x/y)(rs)K,x7S
Let t = j r. Then,
j
!
O X i
Jj rK,x7S,y7S = { bhk pP (bj+1,i bmi) | i P, h, bhi = bhk }
h=1 iP iP |i |2
JS(BC)
S(A)
rK,x7S,y7S = JrK,x7S,y7S
(by IH) = J(x/y)rK,x7S
S(BC)
= JS(A) (x/y)rK,x7S
S(BC)
= J(x/y) S(A) rK,x7S
Typing quantum superpositions and measurement 33
Jx : tK = {f | a J K, f a JtK,x7J K }
{f | a J K, f a JAK}
= J K JAK = J AK.
XX X X
JtuK = { i j gi (cj ) | i gi JtK and j cj JuK }
iI jJ iI jJ
XX X X
{ i j gi (cj ) | i gi S(J K JAK) and j cj SJ K}
iI jJ iI jJ
XX
={ i j gi (cj ) | gi J K JAK and cj J K}
iI jJ
SJAK = JS(A)K
= J(t + r)K
= {a + b | a JtK and b JrK }
= {a + b | a JtK and b JrK }
{a + b | a, b SJAK}
SJAK
= JS(A)K
P
S I f t : A, is a -valuation, and t (pi ) ri , with
Theorem 5.4. i pi = 1,
then JtK = i Jri K .
S(BS(B))
S(S(B)S(B)) .
Deutschid
= 1 (S(BB)
S(S(B)B) H1 (Uf 2 212 (Hboth |01i)))
( )
b(1) 1 (S(BB)
S(S(B)B)
H1 (Uid 2 212 ((H(head |01i)) (H(tail |01i)))))
(head) 2
(1) 1 (S(BB)
S(S(B)B) H1 (Uid 2 12 ((H |0i) (H(tail |01i)))))
(tail) 2
(1) 1 S(BB)
S(S(B)B) H1 (Uid 2 12 ((H |0i) (H |1i)))
( )2 1 1
b (1) 1 (S(BB) 2
S(S(B)B) H1 (Uid 2 12 (
.(|0i + (|0i?( |1i)|1i)) .(|0i + (|1i?( |1i)|1i)))))
2 2
(if0 ) 1 1
(1) 1 (S(S(B)B) H1 (Uid 2 12 ( .(|0i + |1i) .(|0i + (|1i?( |1i)|1i)))))
S(BB) 2
2 2
(if1 ) 1 1
(1) 1 (S(BB) 2
S(S(B)B) H1 (Uid 2 12 (
.(|0i + |1i) .(|0i |1i))))
2 2
(dist ) 1 1
r(1) 1 (S(S(B)B) H1 (Uid S(BS(B)) . S(S(B)S(B)) ((|0i + |1i) .(|0i |1i))))
S(BB) S(BB) S(BS(B))
2 2
Typing quantum superpositions and measurement 37
+
(dist ) 1 1
r(1) 1 (S(BB)
S(S(B)B)
H1 (Uid S(BB)
S(BS(B))
. (S(BS(B))
S(S(B)S(B))
|0i .(|0i |1i)
2 2
1
+S(BS(B))
S(S(B)S(B))
|1i .(|0i |1i))))
2
(neutr ) 1 1
(1) 1 (S(S(B)B) H1 (Uid S(BS(B)) . (|0i .(|0i |1i)
S(BB) S(BB)
2 2
1
+|1i .(|0i |1i))))
2
(dist ) 1 1
(1) 1 (S(S(B)B) H1 (Uid . S(BS(B)) (|0i .(|0i |1i)
S(BB) S(BB)
2 2
1
+|1i .(|0i |1i))))
2
+
(dist ) 1 1
(1) 1 (S(BB)
S(S(B)B) H1 (Uid
. ( S(BB)
S(BS(B)) (|0i
.(|0i |1i))
2 2
1
+ S(BS(B)) (|1i .(|0i |1i)))))
S(BB)
2
(dist )2 1 1
l (1) 1 (S(BB)
S(S(B)B) H1 (Uid
. ( . S(BB)S(BS(B)) (|0i (|0i |1i))
2 2
1
+ . S(BB)
S(BS(B))
(|1i (|0i |1i)))))
2
(dist) 1 1
(1) 1 (S(BB)
S(S(B)B)
H1 (Uid ( . . S(BB)S(BS(B))
(|0i (|0i |1i))
2 2
1 1
+ . . S(BB)S(BS(B))
(|1i (|0i |1i)))))
2 2
(prod) 1
(1) 1 (S(S(B)B)
S(BB)
H1 (Uid ( . S(BB) (|0i (|0i |1i))
2 S(BS(B))
1
+ . S(BB) (|1i (|0i |1i)))))
2 S(BS(B))
+
(dist )2 1
l (1) 1 (S(S(B)B)
S(BB)
H1 (Uid ( .(S(BB) |00i + S(BB)
S(BS(B)) |0i ( |1i))
2 S(BS(B))
1
+ .(S(BB) |10i + S(BB)
S(BS(B)) |1i ( |1i)))))
2 S(BS(B))
(dist )2 1
l (1) 1 (S(BB)
S(S(B)B) H1 (Uid ( .(S(BB) |00i S(BB)
S(BS(B)) |01i)
2 S(BS(B))
1
+ .(S(BB) |10i S(BB) |11i))))
2 S(BS(B)) S(BS(B))
(neut )4 1 1
l (1) 1 (S(BB)
S(S(B)B)
H1 (Uid ( .(|00i |01i) + .(|10i |11i))))
2 2
+
(lin ) 1 1
r (1) 1 (S(BB)
S(S(B)B)
H1 (Uid .(|00i |01i) + Uid .(|10i |11i)))
2 2
(lin )2 1 1
S(S(B)B) H1 ( .Uid (|00i |01i) +
r (1) 1 (S(BB) .Uid (|10i |11i)))
2 2
38 Alejandro Daz-Caro and Gilles Dowek
+
(lin )2 1 1
r (1) 1 (S(BB)
S(S(B)B)
H1 ( .(Uid |00i + Uid ( |01i)) + .(Uid |10i + Uid ( |11i))))
2 2
(lin
r )
2 1 1
(1) 1 (S(S(B)B) H1 ( .(Uid |00i Uid |01i) + .(Uid |10i Uid |11i)))
S(BB)
2 2
(b ) 1
(1) 1 (S(S(B)B) H1 ( .((head |00i) ((tail |00i)?(not(id(head |00i)))(id(head |00i)))
S(BB)
2
1
Uid |01i) + .(Uid |10i Uid |11i)))
2
(head)3 S(BB)
1
(1) 1 (S(S(B)B) H1 ( .(|0i ((tail |00i)?(not(id |0i)))(id |0i))
2
1
Uid |01i) + ( .(Uid |10i Uid |11i)))
2
(tail) 1
(1) 1 (S(S(B)B) H1 ( .(|0i (|0i?(not(id |0i)))(id |0i))
S(BB)
2
1
Uid |01i) + ( .(Uid |10i Uid |11i)))
2
(if0 ) 1 1
(1) 1 (S(S(B)B) H1 ( .(|0i (id |0i) Uid |01i) + .(Uid |10i Uid |11i)))
S(BB)
2 2
(b ) S(BB)
1 1
(1) 1 (S(S(B)B) H1 ( .(|00i Uid |01i) + .(Uid |10i Uid |11i)))
2 2
S(BB)
1 1
(1) 1 (S(S(B)B) H1 ( .(|00i |01i) + .(|11i |10i)))
2 2
+
(linr ) 1 1
(1) 1 (S(S(B)B) (H1 .(|00i |01i) + H1 .(|11i |10i)))
S(BB)
2 2
(lin
r )
2 1 1
(1) 1 (S(S(B)B) ( .H1 (|00i |01i) + .H1 (|11i |10i)))
S(BB)
2 2
+
(linr )2 1 1
(1) 1 (S(S(B)B) ( .(H1 |00i + H1 ( |01i)) + .(H1 |11i + H1 ( |10i))))
S(BB)
2 2
(lin
r )
2 1 1
(1) 1 (S(S(B)B) ( .(H1 |00i H1 |01i) + .(H1 |11i H1 |10i)))
S(BB)
2 2
(b ) S(BB)
1 1
(1) 1 (S(S(B)B) ( .((H(head |00i)) (tail |00i) H1 |01i) + .(H1 |11i H1 |10i)))
2 2
(head) 1 1
(1) 1 (S(S(B)B) ( .((H |0i) (tail |00i) H1 |01i) + .(H1 |11i H1 |10i)))
S(BB)
2 2
(tail) 1 1
(1) 1 (S(S(B)B) ( .((H |0i) |0i H1 |01i) + .(H1 |11i H1 |10i)))
S(BB)
2 2
(b ) 1 1 1
(1) 1 (S(S(B)B) ( .(( .(|0i + |0i?( |1i)|1i)) |0i H1 |01i) + .(H1 |11i H1 |10i)))
S(BB)
2 2 2
(if0 ) 1 1 1
(1) 1 (S(BB)
S(S(B)B)
( .(( .(|0i + |1i)) |0i H1 |01i) + .(H1 |11i H1 |10i)))
2 2 2
+
(dist ) 1 1 1 1
(1) 1 (S(BB)
S(S(B)B)
.(( . |0i + . |1i) |0i H1 |01i) + S(BB)
S(S(B)B)
.(H1 |11i H1 |10i))
2 2 2 2
(dist )2 1 1 1 1
(1) 1 ( . S(BB) (( . |0i + . |1i) |0i H1 |01i) + . S(BB) (H1 |11i H1 |10i))
2 S(S(B)B) 2 2 2 S(S(B)B)
Typing quantum superpositions and measurement 39
+
(dist ) 1 1 1
(1) 1 ( .(S(BB)
S(S(B)B)
(( . |0i + . |1i) |0i) + S(BB)S(S(B)B)
(H1 |01i))
2 2 2
1
+ . S(BB) (H1 |11i H1 |10i))
2 S(S(B)B)
(dist ) 1 1 1
(1) 1 ( .(S(BB) (( . |0i + . |1i) |0i) S(BB) H1 |01i)
2 S(S(B)B) 2 2
S(S(B)B)
1
+ . S(BB) (H1 |11i H1 |10i))
2 S(S(B)B)
+
(dist ) 1 1 1
r(1) 1 ( .((S(BB)
S(S(B)B)
( . |0i) |0i + S(BB)
S(S(B)B)
( . |1i) |0i) S(BB)
S(S(B)B)
H1 |01i)
2 2 2
1
+ . S(BB) (H1 |11i H1 |10i))
2 S(S(B)B)
(dist )2 1 1 1
r (1) 1 ( .(( . S(BB)
S(S(B)B)
|00i + . S(BB)
S(S(B)B)
|10i) S(BB)
S(S(B)B)
H1 |01i)
2 2 2
1
+ . S(BB) (H1 |11i H1 |10i))
2 S(S(B)B)
(neut )2 1 1 1 1 S(BB)
r (1) 1 ( .(( . |00i + . |10i) S(BB) S(S(B)B) H1 |01i) + . (H1 |11i H1 |10i))
2 2 2 2 S(S(B)B)
1 1 1 1 1
(1) 1 ( .((( . |00i + . |10i) + ( . |01i . |11i))
2 2 2 2 2
1 1 1 1
+(( . |01i . |11i) + ( . |00i + . |10i))))
2 2 2 2
1 1 1 1 1
=AC 1 ( .((( . |00i . |00i) + ( . |01i + . |01i))
2 2 2 2 2
1 1 1 1
+(( . |11i . |11i) + ( . |10i + . |10i))))
2 2 2 2
(fact)4 1 1 1 1 1
(1) 1 ( .((( ). |00i + ( + ). |01i)
2 2 2 2 2
1 1 1 1
+(( ). |11i + ( + ). |10i)))
2 2 2 2
1 2 2
= 1 ( .((0. |00i + 0. |01i) + ( . |11i + . |10i)))
2 2 2
(zero )2 1 ~ 2 2
(1) 1 ( .((0S(BB) + ~0S(BB) ) + ( . |11i + . |10i)))
2 2 2
(neutral)2 1 2 2
(1) 1 ( .( . |11i + . |10i))
2 2 2
(dist) 1 2 1 2
(1) 1 ( .( ). |11i + . . |10i)
2 2 2 2
(prod) 2 1 1
(1) 1 ( . |11i + . |10i)
2 2
1 1
=AC 1 ( . |10i . |11i)
2 2
40 Alejandro Daz-Caro and Gilles Dowek
(proj) 1 1
(1) |1i ( . |0i . |1i)
2 2
The typing of Deutschf , for any f : B B, is given below:
If Ax
? : B B B B x : B x : B E Ax|1i
x : B x? : B B B |1i : B
S Ax|1i
x : B x? : S(B B B) |1i : S(B) I |1i : B
Ax|0i ES
|0i : B x : B x?( |1i) : S(B B) |1i : S(B)
ES
|0i : S(B) x : B x?( |1i)|1i : S(B) +
SI
x : B |0i + x?( |1i)|1i : S(S(B))
SI
x : B 12 .(|0i + x?( |1i)|1i) : S(S(S(B)))
x : B 12 .(|0i + x?( |1i)|1i) : S(B)
I
H : B S(B)
(2)
(2) Ax
x:BBx:BB
E Ax
H : B S(B) x : B B head x : B r
E y : B B y : B B El
x : B B H (head x) : S(B) y : B B tail y : B
I
x : B B, y : B B (H (head x)) (tail y) : S(B) B
C
x : B B (H (head x)) (tail x) : S(B) B
I
H1 : B B S(B) B (3)
If Ax
? : B B B B x : B x : B E Ax|0i
x : B x? : B B B |0i : B
E Ax|1i
x : B x?|0i : B B |1i : B
E
x : B x?|0i|1i : B
I
not : B B
(4)
Ax
z :BBz :BB
Ax (4) f : B B z : B B head z : B
Er
y :BBy :BB E
If El
? : B B B B A y : B B tail y : B not : B B z : B B f (head z) : B
E E
y : B B (tail y)? : B B B z : B B not (f (head z)) : B Ax
E z :BB z : BB
Er
y : B B, z : B B (tail y)?(not (f (head z))) : B B f : B B z : B B head z : B
C E
y : B B (tail y)?(not (f (head y))) : B B z : B B f (head z) : B
E
y : B B, z : B B (tail y)?(not (f (head y)))(f (head z)) : B
C
y : B B (tail y)?(not (f (head y)))(f (head y)) : B
(5)
Typing quantum superpositions and measurement 41
Ax (5)
x:BBx:BB
Er
x : B B head x : B y : B B (tail y)?(not (f (head y)))(f (head y)) : B
I
x : B B, y : B B (head x) (tail y)?(not (f (head y)))f (head y) : B B
C
x : B B (head x) (tail x)?(not (f (head x)))f (head x) : B B
I
Uf : B B B B
(6)
(2) Ax (2) Ax
x :BB x: BB y :BB y :BB
Er El
H : B S(B) x : B B head x : B H : B S(B) y : B B tail y : B
E E
x : B B H (head x) : S(B) y : B B H (tail y) : S(B)
I
x : B B, y : B B (H (head x)) (H (tail y)) : S(B) S(B)
C Ax|0i Ax|1i
x : B B (H (head x)) (H (tail x)) : S(B) S(B) |0i : B |1i : B
I I
Hboth : B B S(B) S(B) |01i : B B
E
Hboth |01i : S(B) S(B)
(7)
(7)
Hboth |01i : S(B) S(B)
(6) Hboth |01i : S(S(B) S(B))
r
(3) Uf : B B B B 212 B S(B)Hboth |01i : S(B S(B))
l
H1 : B B S(B) B Uf : S(B B B B) 2 212 Hboth |01i : S(B B)
ES
H1 : S(B B S(B) B) Uf (2 212 Hboth |01i) : S(B B)
ES
H1 (Uf 2 212 Hboth |01i) : S(S(B) B)
r
S(BB)
S(S(B)B) H1 (Uf 2 12 Hboth |01i) : S(B B)
2
SE
Deutschf : B S(B)
2 2
1 1
+.( . 23 |100i + . 23 |111i)))))
2 2
(neut )4 3 3 1 1
l (1) Bob 3 (2 (1 H1 (cnot12 (.( . |000i + . |011i)
2 2
1 1
+.( . |100i + . |111i)))))
2 2
(dist)2 3 3 1 1
(1) Bob 3 (2 (1 H1 (cnot12 ((. . |000i + . . |011i)
2 2
1 1
+(. . |100i + . . |111i)))))
2 2
(prod)4 3 3
(1) Bob 3 (2 (1 H1 (cnot12 (( . |000i + . |011i)
2 2
+( . |100i + . |111i)))))
2 2
+
(linr )3
(1) Bob 3 (2 (1 H1 ((cnot12 . |000i + cnot312 . |011i)
3 3
2 2
+(cnot312 . |100i + cnot312 . |111i))))
2 2
(lin
r )
4
3 3 3
(1) Bob 3 (2 (1 H1 (( .cnot12 |000i + .cnot12 |011i)
2 2
+( .cnot12 |100i + .cnot312 |111i))))
3
2 2
Typing quantum superpositions and measurement 43
( )4
b (1) Bob 3 (2 (1 H31 (( .((cnot (head |000i (head tail |000i))) (tail tail |000i))
2
+ .((cnot (head |011i (head tail |011i))) (tail tail |011i)))
2
+( .((cnot (head |100i (head tail |100i))) (tail tail |100i))
2
+ .((cnot (head |111i (head tail |111i))) (tail tail |111i))))))
2
(tail)12 3
(1) Bob 3 (2 (1 H1 (( .((cnot (head |000i (head |00i))) (|0i))
2
+ .((cnot (head |011i (head |11i))) (|1i)))
2
+( .((cnot (head |100i (head |00i))) (|0i))
2
+ .((cnot (head |111i (head |11i))) (|1i))))))
2
(head)8 3
(1) Bob 3 (2 (1 H1 (( .((cnot |00i) (|0i))
2
+ .((cnot |01i) (|1i)))
2
+( .((cnot |10i) (|0i))
2
+ .((cnot |11i) (|1i))))))
2
(b )4 3
(1) Bob 3 (2 (1 H1 ((( .(((head |00i) ((head |00i)?(not(tail |00i))(tail |00i))) |0i)
2
+ .(((head |01i) ((head |01i)?(not(tail |01i))(tail |01i))) |1i))
2
+( .(((head |10i) ((head |10i)?(not(tail |10i))(tail |10i))) |0i)
2
+ .(((head |11i) ((head |11i)?(not(tail |11i))(tail |11i))) |1i))))))
2
(head)8 3
(1) Bob 3 (2 (1 H1 ((( .((|0i (|0i?(not(tail |00i))(tail |00i))) |0i)
2
+ .((|0i (|0i?(not(tail |01i))(tail |01i))) |1i))
2
+( .((|1i (|1i?(not(tail |10i))(tail |10i))) |0i)
2
+ .((|1i (|1i?(not(tail |11i))(tail |11i))) |1i))))))
2
44 Alejandro Daz-Caro and Gilles Dowek
(if )2
1 (1) Bob 3 (2 (1 H31 ((( .((|0i (|0i?(not(tail |00i))(tail |00i))) |0i)
2
+ .((|0i (|0i?(not(tail |01i))(tail |01i))) |1i))
2
+( .((|1i (not(tail |10i))) |0i)
2
+ .((|1i (not(tail |11i))) |1i))))))
2
(if0 )2 3
(1) Bob 3 (2 (1 H1 ((( .((|0i (tail |00i)) |0i)
2
+ .((|0i (tail |01i)) |1i))
2
+( .((|1i (not(tail |10i))) |0i)
2
+ .((|1i (not(tail |11i))) |1i))))))
2
(tail)4 3
(1) Bob 3 (2 (1 H1 ((( .((|0i |0i) |0i)
2
+ .((|0i |1i) |1i))
2
+( .((|1i (not |0i)) |0i)
2
+ .((|1i (not |1i)) |1i))))))
2
(b )2 3
(1) Bob 3 (2 (1 H1 ((( .(|0i |0i |0i)
2
+ .(|0i |1i |1i))
2
+( .(|1i (|0i?|0i|1i) |0i)
2
+ .(|1i (|1i?|0i|1i) |1i))))))
2
(if0 ) 3
(1) Bob 3 (2 (1 H1 ((( .(|0i |0i |0i)
2
+ .(|0i |1i |1i))
2
+( .(|1i |1i |1i)
2
+ .(|1i (|1i?|0i|1i) |1i))))))
2
(if )
1(1) Bob 3 (2 (1 H31 ((( . |000i + . |011i) + ( . |110i + . |101i)))))
2 2 2 2
Typing quantum superpositions and measurement 45
+
(lin )3
r (1) Bob 3 (2 (1 ((H31 ( . |000i) + H31 ( . |011i)) + (H31 ( . |110i) + H31 ( . |101i)))))
2 2 2 2
(lin 4
r (1) Bob 3 (2 (1 (( .H31 |000i + .H31 |011i) + ( .H31 |110i + .H31 |101i))))
)
2 2 2 2
(b )4
(1) Bob 3 (2 (1 (( .((H(head |000i)) (tail |000i)) + .((H(head |011i)) (tail |011i)))
2 2
+( .((H(head |110i)) (tail |110i)) + .((H(head |101i)) (tail |101i))))))
2 2
(head)4
(1) Bob 3 (2 (1 (( .((H |0i) (tail |000i)) + .((H |0i) (tail |011i)))
2 2
+( .((H |1i) (tail |110i)) + .((H |1i) (tail |101i))))))
2 2
(tail)4
(1) Bob 3 (2 (1 (( .((H |0i) |00i) + .((H |0i) |11i))
2 2
+( .((H |1i) |10i) + .((H |1i) |01i)))))
2 2
(b )4 1
(1) Bob 3 (2 (1 ( .( .(|0i + (|0i?( |1i)|1i)) |00i)
2 2
1
+ .( .(|0i + (|0i?( |1i)|1i)) |11i)
2 2
1
+( .( .(|0i + (|1i?( |1i)|1i)) |10i)
2 2
1
+ .( .(|0i + (|1i?( |1i)|1i)) |01i)))))
2 2
(if0 )2 1
(1) Bob 3 (2 (1 (( .( .(|0i + |1i) |00i)
2 2
1
+ .( .(|0i + |1i) |11i))
2 2
1
+( .( .(|0i + (|1i?( |1i)|1i)) |10i)
2 2
1
+ .( .(|0i + (|1i?( |1i)|1i)) |01i)))))
2 2
(if1 )2 1 1
(1) Bob 3 (2 (1 (( .( .(|0i + |1i) |00i) + .( .(|0i + |1i) |11i))
2 2 2 2
1 1
+( .( .(|0i |1i) |10i) + .( .(|0i |1i) |01i)))))
2 2 2 2
+
(dist )3 1 1
(1) Bob 3 (2 ((1 .( .(|0i + |1i) |00i) + 1 .( .(|0i + |1i) |11i))
2 2 2 2
1 1
+(1 .( .(|0i |1i) |10i) + 1 .( .(|0i |1i) |01i))))
2 2 2 2
46 Alejandro Daz-Caro and Gilles Dowek
(dist )4 1 1
(1) Bob 3 (2 (( . 1 ( .(|0i + |1i) |00i) + . 1 ( .(|0i + |1i) |11i))
2 2 2 2
1 1
+( . 1 ( .(|0i |1i) |10i) + . 1 ( .(|0i |1i) |01i))))
2 2 2 2
(dist
r )
4 1 1
(1) Bob 3 (2 (( . . 1 (|0i + |1i) |00i + . . 1 (|0i + |1i) |11i)
2 2 2 2
1 1
+( . . 1 (|0i |1i) |10i + . . 1 (|0i |1i) |01i)))
2 2 2 2
(prod)4
(1) Bob 3 (2 (( . 1 (|0i + |1i) |00i + . 1 (|0i + |1i) |11i)
2 2
+( . 1 (|0i |1i) |10i + . 1 (|0i |1i) |01i)))
2 2
+
(distr )4
(1) Bob 3 (2 (( .(1 |000i + 1 |100i) + .(1 |011i + 1 |111i))
2 2
+( .(1 |010i + 1 ( |110i)) + .(1 |001i + 1 ( |101i)))))
2 2
(dist )2
r (1) Bob 3 (2 (( .(1 |000i + 1 |100i) + .(1 |011i + 1 |111i))
2 2
+( .(1 |010i 1 |110i) + .(1 |001i 1 |101i))))
2 2
(neutr )8
(1) Bob 3 (2 (( .(|000i + |100i) + .(|011i + |111i))
2 2
+( .(|010i |110i) + .(|001i |101i))))
2 2
(dist)4
(1) Bob 3 (2 ((( . |000i + . |100i) + ( . |011i + . |111i))
2 2 2 2
+(( . |010i + .( |110i)) + ( . |001i + .( |101i)))))
2 2 2 2
(prod)2
(1) Bob 3 (2 ((( . |000i + . |100i) + ( . |011i + . |111i))
2 2 2 2
+(( . |010i . |110i) + ( . |001i . |101i))))
2 2 2 2
=AC Bob 3 (2 ((( . |000i + . |001i) + ( . |011i + . |010i))
2 2 2 2
+(( . |100i . |101i) + ( . |111i . |110i))))
2 2 2 2
The next rewrite step following rule (proj), may produce one of the following
four results probability 41 each:
(00) Bob 3 |00i (. |0i + . |1i)
(01) Bob 3 |01i (. |1i + . |0i)
(10) Bob 3 |01i (. |0i . |1i)
(11) Bob 3 |11i (. |1i . |0i)
So, in general, Bob 3 |xyi (. |zi + []. |wi). Then,
Bob 3 |xyi (. |zi + []. |wi)
Typing quantum superpositions and measurement 47
+
(dist )
l(1) Bob(3 |xyi . |zi + 3 |xyi []. |wi)
(dist 2
l )
(1) Bob (. 3 |xyzi + []. 3 |xywi)
(neut )2
l (1) Bob (. |xyzi + []. |xywi)
+
(lin )
r (1) (Bob . |xyzi + Bob []. |xywi)
(lin )
r (1) (.Bob |xyzi + [].Bob |xywi)
( )2
b (1) (.Zhead|xyzi (nothead tail|xyzi
(tail tail |xyzi))
head|xywi head tail|xywi
+ [].Z (not (tail tail |xywi)))
(tail)6 head|xyzi head|yzi
(1) (.Z (not (|zi)) + [].Zhead|xywi (nothead|ywi (|wi)))
(head)4
(1) (.Z|xi (not|yi |zi) + [].Z|xi (not|yi |wi))
( )4
b (1) (.Z|xi (|yi?not |zi|zi) + [].Z|xi (|yi?not |wi|wi))
Cases:
( )4
b (1) (.|0i?(Z |0i)|0i + .|0i?(Z |1i)|1i)
(if )2
0 (1) (. |0i + . |1i)
(10) (.Z|1i (|0i?not |0i|0i) .Z|1i (|0i?not |1i|1i))
(if )2
0 (1) (.Z|1i |0i .Z|1i |1i)
( )4
b (1) (.|1i?(Z |0i)|0i .|1i?(Z |1i)|1i)
(if )2
1 (1) (.Z |0i .Z |1i)
( )2
b (1) (.|0i?( |1i)|0i .|1i?( |1i)|0i)
(if )
0(1) (. |0i .|1i?( |1i)|0i)
(if )
1(1) (. |0i .( |1i))
(prod)
(1) (. |0i + . |1i)
48 Alejandro Daz-Caro and Gilles Dowek
( )4
b (1) (.|1i?(Z |0i)|0i .|1i?(Z |1i)|1i)
(if )2
1 (1) (.Z |0i + .Z |1i)
( )2
b (1) (.|0i?( |1i)|0i .|1i?( |1i)|0i)
(if )
0(1) (. |0i .|1i?( |1i)|0i)
(if )
1(1) (. |0i .( |1i))
(prod)
(1) (. |0i + . |1i)
If Ax
? : B B B B y:By:B Ax|1i
E
y : B y? : B B B |1i : B
S Ax|0i
y : B y? : S(B B B) |1i : S(B) I |0i : B
ES
y : B y?( |1i) : S(B B) |0i : S(B)
ES
y : B y?( |1i)|0i : S(B)
I Ax
Z : B S(B) x:Bx:B
E
x : B Zx : S(B)
(8)
If Ax
? : B B B B y:By:B
E
y : B y? : B B B (8)
Ax
y : B y? : S(B B B) w : B Zw : S(B) v:Bv:B
ES
y : B, w : B y?Zw : S(B B) v : B v : S(B)
ES
y : B, w : B, v : B y?Zwv : S(B)
C
y : B, w : B y?Zww : S(B)
I
y : B w : B y?Zww : B S(B) Ax
I x:BBBx:BBB
Er
y : B w : B y?Zww : B B S(B) x : B B B head x : B
E
x : B B B Z(head x) : B S(B)
(9)
Typing quantum superpositions and measurement 49
(4)
If Ax Ax
? : B B B B y:By:B
E not : B B z : B z : B E
y : B y? : B B B z : B not z : B
E Ax
y : B, z : B y?not z : B B w:Bw:B
E
y : B, z : B, w : B y?not zw : B
C Ax
y : B, z : B y?not zz : B x :BBB x:BBB
I E
y : B z : B y?not zz : B B x : B B B tail x : B B l
I Er
y : B z : B y?not zz : B B B x : B B B head tail x : B
E
x : B B B not(head tail x) : B B
(10)
Ax
x:BBB x :BBB
(10) E
x : B B B tail x : B B l
(tail y) El
y : B B B not : B B x : B B B tail tail x : B
E
(9) x : B B B, y : B B B not(tail y) (tail tail x) : B
C
y : B B B Zhead y) : B S(B) x : B B B not(tail x) (tail tail x) : B
E
x : B B B, y : B B B Zhead y) (not(head tail x) (tail tail x)) : S(B)
C
x : B B B Zhead x) (not(head tail x) (tail tail x)) : S(B)
I
Bob : B B B S(B)
(11)
(2) Ax
x:BBB x :BBB
H : B S(B) x : B B B head x : B
Er Ax
E y :BBB y :BBB
El
x : B B B H(head x) : S(B) y : B B B tail y : B B
I
x : B B B, y : B B B (H(head x)) (tail y) : S(B) B B
C
x : B B B (H(head x)) (tail x) : S(B) B B
I
H31 : B B B S(B) B B
(12)
50 Alejandro Daz-Caro and Gilles Dowek
Ax Ax
x:BBx:BB (4) y :BBy :BB
If Er El
? : B B B B x : B B head x : B not : B B y : B B tail y : B
E E
x : B B (head x)? : B B B y : B B not(tail y) : B
E Ax
x : B B, y : B B (head x)?not(tail y) : B B y :BB y : BB
C El
x : B B (head x)?not(tail x) : B B y : B B tail y : B
Ax E
y :BB y :BB x : B B, y : B B (head x)?not(tail x)(tail y) :B
Er C
y : B B head y : B x : B B (head x)?not(tail x)(tail x) : B
I
x : B B, y : B B (heady) ((head x)?not(tail x)(tail x)) : B B
C
x : B B (headx) ((head x)?not(tail x)(tail x)) : B B
I
cnot : B B B B
(13)
Ax
y :BBBy :BBB
Ax El
x:BBB x :BBB y : B B B tail y : B B
Er Er
x : B B B head x : B y : B B B head tail y : B
I Ax
(13) x : B B B, y : B B B (head x) (head tail y) : B B y :BBBy :BBB
C El
cnot : B B B B x : B B B (head x) (head tail x) : B B y : B B B tail y : B B
E El
x : B B B cnot((head x) (head tail x)) : B B y : B B B tail tail y : B
I
x : B B B, y : B B B (cnot((head x) (head tail x))) (tail tail x) : B B B
C
x : B B B (cnot((head x) (head tail x))) (tail tail x) : B B B
I
cnot312 : B B B B B B
(14)
Ax
x : S(B) S(B B) x : S(B) S(B B)
(14) x : S(B) S(B B) x : S(S(B) S(B B))
r
cnot312 : B B B B B B x : S(B) S(B B) 23 123
x : S(B S(B B))
l
cnot312 : S(B B B B B B) x : S(B) S(B B) 23 23 123 x : S(B B B)
ES
x : S(B) S(B B) cnot312 23 23
123 x : S(B B B)
(15)
(12)
H31 : B B B S(B) B B (15)
H31 : S(B B B S(B) B B) x : S(B) S(B B) cnot312 23 23
123 x : S(B B B)
ES
x : S(B) S(B B) H31 (cnot312 23 23
123 x) : S(S(B) B B)
r
x : S(B) S(B B) 1 H31 (cnot312 23 23
123 x) : S(B B B)
SE
x : S(B) S(B B) 2 (1 H31 (cnot312 23 23 x)) : B B S(B)
123
I
Alice : S(B) S(B B) B B S(B)
(16)
Typing quantum superpositions and measurement 51
(17)
Ax
(16) q : S(B) q : S(B) 00 : S(B B)
I
Alice : S(B) S(B B) B B S(B) q : S(B) q 00 : S(B) S(B B)
E
(11) q : S(B) Alice (q 00 ) : B B S(B)
Bob : B B B S(B) q : S(B) Alice (q 00 ) : S(B B S(B))
l
Bob : S(B B B S(B)) q : S(B) 1 Alice (q 00 ) : S(B B B)
ES
q : S(B) Bob (1 Alice (q 00 )) : S(S(B))
q : S(B) Bob (1 Alice (q 00 )) : S(B)
I
T eleportation : S(B) S(B)