Professional Documents
Culture Documents
by
Anya Taiovich
A thesis submitted in conformity with the requirements for the degree of Master of Science Graduate Department of Computer Science University of Toronto
Abstract
Quantum Programming Anya Taiovich Master of Science Graduate Department of Computer Science University of Toronto 2004 The subject of this work is quantum programming the study of developing of programs intended for execution on a quantum computer. We look at programming in the context of formal methods of program development, or programming methodology. Our work is based on probabilistic predicative programming, a recent generalisation of the well-established predicative programming. It supports the style of program development in which each programming step is proven correct as it is made. We inherit the advantages of the theory, such as its generality, simple treatment of recursive programs, and time and space complexity. Our theory of quantum programming provides tools to write both classical and quantum specications, develop quantum programs that implement these specications, and reason about their comparative time and space complexity all in the same framework.
ii
Acknowledgements
I would like to thank my supervisor Eric C.R. Hehner for advice, help, and support during the past two years. I thank the organisers of 2003 PIMS-MITACS Summer School on Quantum Information Science for introducing me to Quantum Computing. My graduate studies at the University of Toronto were nancially supported by Ontario Graduate Scholarship Program and Natural Sciences and Engineering Research Council of Canada.
iii
Contents
1 Introduction 2 Related Work 3 Introduction to quantum computation 3.1 Basics from linear algebra . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Dirac notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.2 Vector spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.4 Tensor product . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 4 5 5 6 6 8 9
3.1.5 Computational basis . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.2 Postulates of quantum mechanics . . . . . . . . . . . . . . . . . . . . . . 11 3.3 A quantum algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 Introduction to probabilistic predicative programming 18
4.1 Predicative programming . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.1.1 Specications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.1.2 Specication notation . . . . . . . . . . . . . . . . . . . . . . . . 19 4.1.3 Renement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.1.4 Bunches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.1.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 iv
4.1.6 Quantiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.1.7 Program development . . . . . . . . . . . . . . . . . . . . . . . . 22 4.1.8 Time and space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.2 Probabilistic predicative programming . . . . . . . . . . . . . . . . . . . 24 4.2.1 Probabilistic specications . . . . . . . . . . . . . . . . . . . . . . 25 4.2.2 Developing probabilistic programs . . . . . . . . . . . . . . . . . 27 4.2.3 Partial probabilistic specications . . . . . . . . . . . . . . . . . . 31 5 The quantum system 32
5.1 The quantum state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 5.2 Composing quantum systems . . . . . . . . . . . . . . . . . . . . . . . . 33 5.3 Unitary transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 5.4 Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6 Quantum programming 38
6.1 A quantum program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 6.2 Fair coin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 6.3 Deutschs problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 6.4 Deutsch-Josza problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 6.5 Grovers search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 6.6 Computing with Mixed States . . . . . . . . . . . . . . . . . . . . . . . . 54 7 Conclusion and Future Work Bibliography A Notations B Renement Laws v 60 63 65 68
70
C.1 A classical solution for Deutsch-Jozsa problem . . . . . . . . . . . . . . . 70 C.2 Deutsch-Jozsa problem with time restriction . . . . . . . . . . . . . . . . 73
vi
Chapter 1 Introduction
Modern physics is dominated by concepts of quantum mechanics. Today, over seventy years after its recognition by the scientic community, quantum mechanics provides the most accurate known description of natures behaviour. Surprisingly, the idea of using the quantum mechanical nature of the world to perform computational tasks is very new, less than thirty years old. Quantum computation and quantum information is the study of information processing and communication accomplished with quantum mechanical systems. In recent years the eld has grown immensely. Scientists from various elds of computer science have discovered that thinking physically about computation yields new and exciting results in computation and communication. There has been extensive research in the areas of quantum algorithms, quantum communication and information, quantum cryptography, quantum error-correction, adiabatic computation, theoretical quantum optics, and the very new quantum game theory. Experimental quantum information and communication has also been a fruitful eld. Experimental quantum optics, ion traps, solid state implementations and nuclear magnetic resonance (NMR) all add to the experimental successes of quantum computation. The subject of this work is quantum programming the study of developing programs intended for execution on a quantum computer. We assume a model of a quan1
C HAPTER 1. I NTRODUCTION
tum computer proposed by Knill [10]: a classical computer with access to a quantum device that is capable of storing quantum bits, performing certain operations and measurements on these bits, and reporting the results of the measurements. We look at programming in the context of formal methods of program development, or programming methodology. This is the eld of computer science concerned with applications of mathematics and logic to software engineering tasks. In particular, the formal methods provide tools to formally express software specications, prove correctness of implementations, and reason about various properties of specications (e.g. implementability) and implementations (e.g. time and space complexity). Today formal methods are successfully employed in all stages of software development, such as requirements elicitation and analysis, software design, and software implementation. In this work the theory of quantum programming is based on probabilistic predicative programming, a recent generalisation of the well-established predicative programming [7, 8], which we deem to be the simplest and the most elegant programming theory known today. It supports the style of program development in which each programming step is proven correct as it is made. We inherit the advantages of the theory, such as its generality, simple treatment of recursive programs, and time and space complexity. Our theory of quantum programming provides tools to write both classical and quantum specications, develop quantum programs that implement these specications, and reason about their comparative time and space complexity all in the same framework. The rest of this work is organised as follows. Chapter 2 is a brief outline of related work. Chapter 3 is the introduction to quantum computation. It assumes that the reader has some basic knowledge of linear algebra and no knowledge of quantum computing. Chapter 4 contains the introduction to probabilistic predicative programming. The reader is assumed to have some background in logic, but no background in programming theory is necessary. The contribution of this work is Chapters 5 and 6.
C HAPTER 1. I NTRODUCTION
Chapter 5 denes the quantum system and chapter 6 introduces programming with the quantum system. Chapter 6 contains several well-known problems, their classical and quantum solutions, and their formal comparative time complexity analyses. Chapter 7 states conclusions and outlines directions for future research.
3.1
In this section we provide a brief overview of the notions from linear algebra necessary for understanding the basics of quantum computation. We assume the reader has some background in rst and second-year linear algebra. The purpose of this section is to remind the reader of some basic facts about complex vector spaces and introduce the algebraic notations used in quantum mechanics. The reader with insufcient background in linear algebra is referred to [11] for a more detailed introduction. 5
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
The vector spaces considered will all be nite-dimensional complex vector spaces that are of interest in quantum computation and quantum information. In this section, whenever we refer to a vector space, nite dimensionality is implied.
3.1.1
Dirac notation
The Dirac notation, invented by Paul Dirac, is often used in quantum mechanics because
clearly distinguishes vectors from operators and scalars, and makes it possible to write operators directly as combinations of bras and kets.
3.1.2
Let .
Vector spaces
is denoted by
an inner product dened on it) that is complete with respect to the norm dened by the inner product. In the case of nite dimensionality, a Hilbert space is equivalent to an inner product space.
2.
@ A
E C FDB
1.
0 ' 1)' (
is a function
is a zero vector.
$ %
5 & 2 643&
"! #
The
element of a vector
is denoted
corresponds to an
by
&
and
-dimensional vector
is a scalar and
is
9
7 8
&
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
complex conjugate of its every element. In this setting, the inner product of two column
the action of the dual operator and the corresponding matrix multiplication, since the two are equivalent.
For the sake of consistency, we use this quantier notation throughout this work. For now the reader should understand this notation as the sum as varies from (including)
varies, if they can be understood from the context. The reasons for using this quantier notation will become clear in Chapter 4.
$
!
to (excluding)
of
, dened by
D ' ' 0
$ '
by
is made clear by the notation. In matrix representation, the action of the operator
and
The expression
7 BE 0
@
&
and
to
acting on
&
If
and
and
&
or
, with dimensions
vectors
and
vector
, is obtained by taking the corresponding row vector and then taking the
and
and
B 0
G
maps
, such that
if
G
, written
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
called a unit vector. A basis is a set of linearly independent vectors that span the vector
each pair of distinct vectors are orthogonal and each vector is unit vector.
3.1.3
Operators
1 7 8
dened on a vector space is linear if for any two vectors
An operator
The operator
. If
is called a projector on
The following several linear algebra results are important in quantum mechanics.
Any projector is a Hermitian operator. Any Hermitian operator is normal. The Spectral Decomposition Theorem tells us that an operator is normal if and only if it is diagonal-
eigenspace of
, where
and
for
, such that
. The operator
on a Hilbert space
can be written as
7 8
@ 2 ' # (&%$ 7
! "
&
' 0 (1%) 87 87 ) !
$ $ '
2 2 $ 6 3 5'
operator on
, then
is a -dimensional subspace
@
@
or simply
G
1 @
7 8
7 8
A@
@
4
7 E 0 B9
on
If
@
and
corresponds
is the identity
&
E @
&
space. Vectors
and
are orthogonal if
4
The norm of
is written
and is dened by
. If
@
@
, then
is
&
$
3 5
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
otherwise. Any unitary operator is normal, and therefore has a spectral decompois normal, the eigenvalues of
sition. If
have modulus 1. A
3.1.4
Tensor product
The tensor product is a way of combining vector spaces to form larger vector spaces.
linear combinations of the tensor products of the elements of the original vector spaces.
If
, and
$ '
$
! $ $
$ '
$
D
for
and
&
3.
@
'
B
2.
@
' 6
&
1.
, and
is a scalar, then
8( 8 7 7
. If
, then
, then
and
E % $
&
'
&
FE
In particular, if
and
&
If
and
&
, where
$
is
2 2 $ @ 2 $ 2
@ $ 12' 3
if
, and
7 8
'
E E
7 8
&
is a
, ,
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
10
It may be more natural to think about tensor products in terms of matrices. Suppose
. . .
. . .
. . .
. . .
Transpose, complex conjugation, and adjoint operations distribute over tensor product. The tensor product of two unitary operators is a unitary operator.
3.1.5
Computational basis
In quantum mechanics, the vector spaces of interest are the Hilbert spaces of dimension
. . . corresponds to corresponds to
The term Kronecker product is most often used in the context of matrices, while the term tensor product is used in the context of operators. Essentially, the two are equivalent.
BE E 7 7 7
E BE E 7 7 7
E E 7 7 7
7 7 7 BE BE
corresponds to
E BE E 7 7 7
7 7 7 BE BE
corresponds to
E BE E 7 #! BE BE 7 7 " 7 7 7
corresponds to
7 7 7 BE BE BE
7 7 7 BE BE BE
!
for some
. A convenient orthonormal basis is what is called a computational basis vectors using binary strings of length as follows:
$ E E
E
" "
E
entry
of the matrix
The sub-matrices
are
by
written
, is the following
by
matrix:
$
!' !
$ 1
is an
by
matrix and
is a
by
" #!
@ 6
E E
E E
E E
and
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
11
. From now on, whenever we refer to a zero vector, we will mean the zero vector
3.2
In this section we introduce the basic concepts of quantum mechanics, as they pertain to the quantum systems that we will consider for quantum computation. The discussion of the underlying physical processes, spin- -particles, etc. is not of our interest. We are concerned with the model for quantum computation only. Postulate 1 (state space): Associated to any isolated physical system is a Hilbert space, known as the state space of the system. The system is completely described by its state vector, which is a unit vector in the systems state space. The simplest quantum system is a quantum bit, or a qubit, which has a two-dimensional
are different.
and
2 $
, then
and
2 $
@ 9
If
and
2 $
E
basis states
and
. for some ,
, respectively. If both
and
E
means that
. The coefcients
and
where
and
are complex numbers. The condition that the state is a unit vector and
and
'
E
vector in
E E 7
. An arbitrary
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
12
Postulate 2 (evolution): The evolution of a closed quantum system is described by a unitary transformation.
. Note that since unitary transformations preserve the norm, the resulting vector
represents a valid system state. Another important remark is that unitarity of evolution operators implies reversibility, since every unitary operator has a unique inverse, which is unitary. Postulate 3 (measurement): Quantum measurements are described by a collection
of measurement operators, which act on the state space of the system refers to the possible measurement outcomes. If
case the state of the system immediately after the measurement is described by
An important special class of measurements is known as projective measurements, which are equivalent to general measurements provided that we also have the ability to perform unitary transformations. A projective measurement is described by an observable
erator on the state space of the system being measured. This observable has a spectral
! #"!
ability of measuring
is
with eigenvalue
decomposition
, where
, which corresponds to the outcome of the measurement. The prob, in which case immediately after the measurement .
2 2 5' 3
'
vector
is
, in which
and
'
'
'
, and the
'
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
13
Measurement with respect to the computational basis is the simplest and the most
Suppose the result of the measurement is ignored and we continue the computation. In this case the system is said to be in a mixed state. A mixed state is not the actual physical state of the system. Rather it describes our knowledge of the state the system is in. The conventional notation for mixed states is inconsistent. In the above example, the mixed state is expressed by the following equation:
There are two important principles of quantum computation pertaining to measurements that are worth emphasising. We do not prove these in this work. The detailed proofs can be found in [12].
although
probability
. The brackets
cease to denote a set and are meant to denote the is not a valid
is
with probability
and it is
or
, respectively.
with probability
and outcome
with probability
. The
with
( E
E
after measuring
is
@ 9
projectors are
and
D
, the
' 6
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
14
Principle of deferred measurement: Measurements can always be moved from an intermediate stage of quantum computation to the end of the computation. If any stage of the computation uses results of the measurement, then the classically controlled operations can always be replaced by conditional quantum operators. Principle of implicit measurement: Without loss of generality, any qubits that are not measured at the end of the computation may be assumed to be measured. Postulate 4 (composite systems): The state space of a composite physical system is the tensor product of the state spaces of the component systems. If we have
It is important to understand that, while we can always describe a composite system given descriptions of the component systems, the reverse is not true. Indeed, given a state vector that describes a composite system, it may not be possible to factor it to obtain the state vectors of the component systems. A well-known example is the state
. The reader may verify that there are no single qubit states
so, we apply
qubit operation
to a particular qubit and leave the rest of the qubits unchanged. To do to every other
in state
' !
' !
' !
results
F
'(% ' !
and
, such that
to qubit ,
'
' (%
systems numbered
"
' !
E E
'
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
15
Just as it may not be possible to represent the state of a multi-qubit system as tensor product of its component systems, it may not be possible to represent an operation on a composite system as a tensor product of single-qubit operations on the component systems. Consider, for example, controlled-NOT (CNOT) operation on two qubits dened by
where
3.3
A quantum algorithm
In this section we look at one of the most famous quantum algorithms, Deutschs algorithm [4]. While Deutschs algorithm is simple and easy to understand (compared to most of the quantum algorithms), it illustrates two important aspects of quantum computing: quantum parallelism and quantum superposition. Moreover, it solves a problem that a classical computer cannot solve even in principle. The problem is as follows. Given a function a (classical) oracle, compute , where
provided that we are only allowed to query the oracle once. It is easy to convince oneself (by listing all possibilities) that there is no classical solution to this problem. Before we present the quantum solution, we need to introduce two important op-
BE 5 BE F 7 7 0
E
, such that
, usually referred to as
and
' !
' !
' !
E
'
B 7 E
To apply
state
'
'
!
' !
' !
!
'
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
16
0 1
s0
H H
s1
Uf
y y f(x)
s2
s3
Figure 3.1: Deutschs algorithm erators. The rst one is the Hadamard transform, dened by
Hadamard is unitary and self-inverse. The second one is a quantum version of the
bit as follows:
Traditionally we use quantum circuits to describe and analyse quantum algorithms. Figure 3.1 shows a quantum circuit that implements Deutschs algorithm.
cations of the Hadamard transform. After this step the system is in state
E
E
E
, results in state
. The value of
gets pushed
E
2
2 2
@ E @ E
BE 7
is to introduce an auxiliary
C HAPTER 3. I NTRODUCTION
TO QUANTUM COMPUTATION
17
with probability
to
, for
E
2 '
E 2 !
B6 7 E
E
E
2
4.1
Predicative programming
In the theory of predicative programming specication is a boolean expression and renement is logical implication. The theory applies to sequential and parallel, standalone and interactive, terminating and non-terminating, deterministic, non-deterministic, and probabilistic computation. It supports reasoning about computation time and space without introducing new concepts. While being remarkably general, it is also remarkably simple. 18
C HAPTER 4. I NTRODUCTION
19
4.1.1
Specications
A specication is a boolean expression. The variables in a specication represent the quantities of interest, such as prestate (inputs), poststate (outputs), and computation time and space. We use primed variables to describe outputs and unprimed variables
if, given a prestate, it produces a poststate, such that the pair makes the specication true. A specication is implementable if for each input state there is at least one output state that satises the specication.
4.1.2
Specication notation
(conjunction), (dis-
use lowercase letters for variables of interest and uppercase letters for specications. In addition to the above, we use the following notations:
prestate
poststate
domain of .
7 7
7 7
If
and
is obtained from
by sub-
@0
species that the values of all variables are unchanged. In the assignment
$
@ @
and
and
@ @ @ @ @ @ @
@ @
junction),
(logical implication),
states
@0
)
C HAPTER 4. I NTRODUCTION
20
Here is the precedence order: numbers, names, bracketed expressions function application (juxtaposition) superscript, subscript, exponentiation
Various laws can be proved about sequential composition. One of the most impor
tant ones is the substitution law, which states that for any expression state variable , and specication for
According to the precedence rules listed above, this expression should be read as
substitute
in
of the prestate,
@
@ @
means
. The operators
@ @@
inx operators
and
@0
if then else
measure
'
7 7
@ @
@ @
@ @
@0
of
and
is dened by
7 7
7 7
ables
, and
7 7
is obtained from
21
4.1.3
Renement
is rened by specication if and only if is satised whenever
satised:
4.1.4
Bunches
A bunch is a collection of objects. It is different from a set, which is a collection of objects in a package. Bunches are simpler than sets; they dont have a nesting structure. A bunch of one element is the element itself. We use upper-case to denote arbitrary bunches and lower-case to denote elements (an element is the same as a bunch of one element). bunch denotes the union of bunches and
to (excluding) .
4.1.5
If
Functions
is a bunch, and is an arbitrary expression,
' 0
then
with domain
7
is included in bunch
. We use notation
and body . If
0
Specications
and
Specication
substitute
in
@ @
7
@ '
' 7
7
@0
is
C HAPTER 4. I NTRODUCTION
22
whose body is a boolean expression. A relation is a function whose body is a predicate. A higher-order function is a function whose parameter is a function.
4.1.6
Quantiers
We are now ready to explain what our quantier notation really means. A quantier
taking the conjunction of those results. Taking the disjunction of the results produces
results.
example, we can omit the domain of the free variable if it is clear from the context. We
4.1.7
Program development
A program is an implemented specication. For simplicity we only take the following to be implemented:
'
7 0 BE 7
can be abbreviated to
7 BE 0
3'
% %
'
)
7 BE 0
breviate to
'
7 BE 0
quantum state
, yields:
'
7 BE 0
to the function
5 3
rst applying
to all the elements in its domain and then taking the sum of those
. Similarly, if
, for some
is a predicate, then
variables, for
variables is a function of
. A predicate is function
is the
is a function, then
, then
( applied to )
% %
'
7 BE
C HAPTER 4. I NTRODUCTION
23
One of the best features of Hehners theory, is its simple treatment of recursion. In
The specication says that if the initial value of be . The solution is: if the value of
4.1.8
To talk about computation time and space we dont need to expand the theory. We
the same way that we treat any other variable. For example, consider the program in section 4.1.7.
How long does the computation take? To account for time we add a time variable .
@0
E @
E @
if
then
else
E @
FC E
)
E @
FC E
E @
if
then
else
E @
E @
if
then
else
E @
if
then
else
E @
E @
if
then
else
E @
FC E
E @
if
then
else
expand
E @
FC E
E FC E @ @ E C @ FC E EFC @0 @0
@0
E @
if
then
else
it is possible for
to appear in
, such that
renes , i.e.
. The
E @
FC E
FC E
@ @
@ @
@ @
@ @
@ @
2 2
E
and
C HAPTER 4. I NTRODUCTION
24
at which the computation ends1 . We choose to use a recursive time measure, in which we charge time unit for each time is called. We replace each call to
is decremented,
else if
else if
else
4.2
Probabilistic predicative programming was introduced in [7] and was further developed in [8]. It is a generalisation of predicative programming that allows reasoning about probability distributions of values of variables of interest. Although in this work
In case of non-termination,
@ E @ FC E @ E @ FC E @ E @ FC E E @ @ E E @ @ FC E @ E @ E @ E @ E @ E @ @ E @ E C
then
then
E @
if
then
E FC
@0
@0
else
E @
if
then
E FC
@0
else
expand
substitute
context, math
E @
if
then
@ 0
E FC
i.e.
, if
, and
@ D 0
@0
)
E @
to include
2
@ @ @ @ @ @ @ @
C HAPTER 4. I NTRODUCTION
25
we apply this reasoning to boolean and integer variables only, the theory does not change if we want to work with real numbers: we replace summations with integrals.
4.2.1
Probabilistic specications
and , inclusive. A distribution is an expres-
sion whose value is a probability and whose sum over all values of variables is . For
product of distributions of the individual variables, then the variables are independent.
of several variables, we can sum out some of the variables to obtain a distribution of
and
distributions of
and , respectively:
and
7 7
specication and
E @
E @
for boolean
and
, respectively.2 If
and
'
% %
'
For example,
and
, which is a distribution of
and
be
and
'
is a probability, and
and ,
example, if
7 7
@ @
@ @
% %
%
C HAPTER 4. I NTRODUCTION
26
distribution is then
longer independent. A probability distribution of initial and nal values of variables is a probabilistic specication. Sequential composition and if then else are generalised to apply to probabilistic specications as follows.
7 7
7 7
ables
, and
is obtained from
7 7
7 7
If
and
is obtained from
and
and
one third of the time. Note that we cannot express this distribution as a and the nal value of . They are no
7 7
both
and
@ @
E @
E @
E @
E @ @
@ ' 7
E @ @
@ @
@ 6 @
@ @
be
@ @
E @
E @
E @ @
is
is
' 7
@ 6 @
2 @0
by sub-
C HAPTER 4. I NTRODUCTION
27
Various laws can be proven about sequential composition. One of the most important ones, the substitution law, introduced in section 4.1, applies to probabilistic specications as well.
4.2.2
To implement a probabilistic specication we use a pseudo-random number generator. Since we cannot, even in theory, produce a real random number generator by means of traditional computing, we assume that a pseudo-random number generator generates truly random numbers and we simply refer to it as random number generator. For a
loop, we parametrise the introduced variables by the execution time. Recall the example from sections 4.1.7 and 4.1.8.
@0
@0
E @
if
then
else
@ D 0
@0
)
E @
FC E
E @
if
then
else
BE 0 7
. If
BE 0 7
)
variable
. If
BE 7
uniformly distributed in
@ @
@ @
if
then
else
If
is a probability and
and
produces a random natural number
'
7 7
@ @
of
and
is dened by
C HAPTER 4. I NTRODUCTION
28
is either decremented by
with equal probability. Our intuition tells us that the revised program should still work,
E @
if
then
else
else
E @
if
then
else
@
E @
if
then
@ )0
@0
else
E @
if
then
substitute
context
@0
@0
else
replace
E @
if
then
E A@
at each iteration. .
and
boolean laws,
BE D 7 0
E @
E @
E @
E @
FC E
E D# C
E @
E @
E @
E @
E @
if
then
else
E @
FC E
@ )0
else
E @
if
then
E @
FC E
@ )0
else
replace
)
E @
if
then
FC E
E @
E @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
with
having probability
. Ignoring time:
0
with
and
E 7
or it is unchanged,
C HAPTER 4. I NTRODUCTION
29
How long should we expect to wait for the execution to complete? In other words, what is the distribution of ? We can either give a little thought to the problem or recall what weve learned about Negative Binomial Distribution in a statistics class some years ago, to arrive at the following distribution of the nal states:
substitute
distribute
! %!
@ E
else
@ E
E @
if
then
' (% ! % !
@
@ E
@ E
else
E @
if
then
expand,
replace
@0
@ E
@ E
@0
else
@
E @
if
then
! !
)
@ E
where
'
'
C @ @
@ E
@ @ @ @
2
E
'
! %!
2
@
@ @
! %!
@
2 2
@
! %!
@ E
@
@ E
@ E
@ @
2 2
@
! %!
2
@ @
@ E
@
@
C HAPTER 4. I NTRODUCTION
if
then
E @
else
@ E
if
then
E @
else
@ E
if
then
2 @
@ ! %!
E @
else
E @
if
then
E @
else
@ E
@
with parameters
time units for the computation to complete. arithmetic expand if context, terms collect 30
'
2
@ @
@ E
@ E
@ E
@ @
@ @
@ @
@ @
C HAPTER 4. I NTRODUCTION
31
4.2.3
specication is:
Partial specications often come up in quantum computation. The goal of a number of quantum algorithms is to successfully discriminate between their inputs with high probability. In such cases a (partial) probabilistic specication often looks like
where
the distribution that renes the specication. There is an intrinsic problem with formalising specications as superdistributions the convex closure problem, which we do not address in this work. See [8] for an example of the problem.
E @
@ @
@ )0
E @0
if
then
else
is not zero
E @
E @
with probability
is, the
according to
with probability
and
E @
E @
E @
@ @
5.1
Let
the complex conjugate operator . Then a state of an -qubit system is a function , such that:
dened by:
32
!
quantum states
, such that:
0
If
and
and
'
@ 9 $ '
7 BE 0
'
7 BE 0
7 0 BE 7
5
7 BE 0
, is
C HAPTER 5. T HE
QUANTUM SYSTEM
33
Most of the time we choose the computational basis, which is the simplest, to describe the quantum system. We adopt the following Dirac-like notation for the computational
5.2
If
Here is another example. The composition of two -qubit quantum systems, the rst
one in state
E @
$
$
E E
( ' '
'
'
7 BE 0
7 BE 0
7 BE 0
E E
E E
system in state
, results in
tensor product of
)
'
is a state of an
-qubit system:
and a -qubit
, an arbitrary state
1!
'
'
7 BE 0
7 E 0
7 0 E
@ E E
7 BE 0
7 E B0 5
basis: if
of an -qubit
and
, the
C HAPTER 5. T HE
QUANTUM SYSTEM
34
5.3
Unitary transformations
, written
The unitary transformations that describe the evolution of a -qubit quantum system
are operations
In this setting, the tensor product of operators is dened in the usual way. If
of an
-qubit system,
and
are operations
&
7 BE
$E
" #!
@ $ E
'
" #!
A@
7 BE 0
@
We write
E
and
"
@ 7 0 6' BE 5
"
'
'
B9 5 7 E 0
7 BE 0
5
@
@ @
in a 2-qubit system.
is a state
C HAPTER 5. T HE
QUANTUM SYSTEM
35 and
dened by:
(5.1)
'
7 BE 0
xy
'
7 E 0
The operation
to
BE 7
E 7
2 $
' (% $ % $
is dened by:
" #!
'
E 9 5 BE 0 5 7 0 ' 7
To apply an operation
" #!
" #!
'
@ $
itself
times:
to mean operation
& $ $ 2 $ $'
7 BE 0
$ $'
7 E 0
7 0 BE
7 7 BE 0 &
and
&
dened on an
dened on
and -qubit systems, respectively, then the tensor product of qubit system by:
tensored with
&
is
&
@ @
C HAPTER 5. T HE
QUANTUM SYSTEM
36
5.4
Measurement
qubits in state
!
distribution of
and
(these depend on
Finally, the simplest and the most commonly used measurement in the computational basis is:
@ @
measure
@ @
measure
, measurement of
in basis
! A @
@ @
measure
with eigenvalue
, where
is:
5'
'
@ @
7 7
measure
, where
'
7 E 0
@
7 7
7 7
7 E
we have a variable
7
@ @
C HAPTER 5. T HE
QUANTUM SYSTEM
37
which is precisely the mixed quantum state that results from the measurement. We have recovered consistency in the denitions of pure and mixed states by providing the tools to compute directly with distributions and, thus, removing the necessity to
is
'
6.1
A quantum program
In order to develop quantum programs we need to add to our list of implemented things from section 4.1.7. We add variables of type quantum state as in section 5.1 and we allow the following three kinds of operations on these variables. If
is a state of an
is a collection of measurement
C HAPTER 6. Q UANTUM
PROGRAMMING
39
The special cases of measurements, described in section 5.4, are therefore also allowed:
Now we are ready to develop quantum programs. In the rest of this chapter we will describe a few well-known problems, develop both classical and quantum solutions to these problems, and analyse their complexity.
6.2
Fair coin
We begin with the following simple problem. The task is to simulate a ip of a fair
number generator
BE 0 7
probability
and
BE 7
@
E @
measure
are programs.
for an observable
, measure
, measure
3. measure
is a program
E @
@0
2.
@0
1.
, where
, and
@ @
@ @
C HAPTER 6. Q UANTUM
PROGRAMMING
40 by means of classical
computing. On the other hand, with a quantum computer, in theory we can implement the following. Let
denition of measure
6.3
Deutschs problem
Recall the Deutschs problem discussed in section 3.3. The task is: given an oracle
substitution
to
is that we want to be able to add time increments before each statement that contains
one call to
a call to
(see time analysis later in this section). It is therefore convenient to have per statement.
E
@0
@0 E E E
E
@ )0
function
, compute
measure
E
BE 5 BE 0 7 7
measure
measure
Hadamard substitution
@0
E @
E @0
@ @
@ @ @ @ @ @ @ @
C HAPTER 6. Q UANTUM
PROGRAMMING
41
Recall that the denition of the quantum analog of the above classical oracle is:
measure
So far we have two solutions a simple classical one and a complicated quantum one. Let us add the restriction on the number of allowed calls to the oracle. We add a time variable and decide to charge
'
!
@0
@ E 2 ' ! @ E @
@0
measure
measure
measure
measure
measure
measure
measure
'
!
2
'
E 0 7
'
@
@0
5
BE 0 5 7
E
E
E
@0
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@
measure
as before
as before
C HAPTER 6. Q UANTUM
PROGRAMMING
42 substitutions
measure
Readers can convince themselves that the new specication is unimplementable classically. Our classical solution fails with the time-constraint:
substitution
weaken
Classically, at least two calls to the oracle functions are necessary to compute
6.4
Deutsch-Josza problem
qubits [5]. It is an example
of the broad class of quantum algorithms that are based on quantum Fourier trans-
or balanced, determine which case it is. Without any restrictions on the number of calls to , we can write the specication (let us call it ) as follows:
formally as follows:
E @
$
'
'
7 0 E 9
7 0 BE 9
@ 9 @
@ @
where
!
7 BE 0
, such that
is either constant
are dened
E
BE 7
@0 @0 @0 5
@0
@0 @0
@ 0 @ 2
@
@
@0
@0
E
@
@0 @0 @
E E
E E
@0 @0
@0 )D
@ @
@ @ @ @ @ @
measure
PROGRAMMING
43
In other words, given that the function is either constant or it balanced, the function is constant if and only if half of its values plus one are the same.
as follows:
until we either get two different values of , in which case we conclude that the func-
Interested readers can nd the detailed proof in Appendix C.1. The quantum solution is a direct generalisation of Deutschs algorithm. We intro-
, so that a measurement of
E @
E @
@ )0
produces
if and only if
!
7 E 0
2
!
7 BE
'
7 BE 0
'
duce a variable
, a quantum state
@0
@ 0
else if
then
else
@ 0
' (%
if
then
and , is:
@ )0
and
is constant. The
and make
7 E
with values of
dened
E
,
@
'
' (%
7 BE 0
@ @
@
E
'
(% '
'
E
7 BE 0
7 BE 0
7 BE 0
@0
@ @
@ @
@ @
@
C HAPTER 6. Q UANTUM
PROGRAMMING
44
To implement
we notice that:
, we proceed:
Now that we have some intuition about why the two expressions are equal, we can produce a formal proof of this step:
E @
xz
denition of z
E @
xz
E @
xz
E @
'
7 B
xz
'
7 0
xy
'
'
7
7 0
are , i.e.
xy
. When
'
'
7 0
( 3
state, whenever
'
. Since
xy
xz
z is a valid quantum
' 7 B
@
reduces to
'
xz
7 B
'
'
simplied to
. Thus,
is , if
xz
'
7
'
7 B
7 B
7 0
( 3
@ @
and
xz
can be is conz
@
7 B
'
z . Since z applied to
is
xz
E @
xz
E @
'
7 B
xz
for
!
7 BE
E @
Introducing variables
, and
and assuming
E @
' '
7 B
(6.1) (6.2)
@ 9
@ 9 @ @ @
'
7 0
7 B
'
@ @
are free. Clearly, the above quantum solution works. Classically the specication is where we charge 1 unit of time for each call to the oracle and all other operations
Let us add to the specication a restriction on the number of calls to the oracle. Suppose
'
2
'
2
'
'
2
'
2 '
E @
E @
E @
2 E @
C HAPTER 6. Q UANTUM
xz
PROGRAMMING
xz
E @
7 B
xz
xz
7
'
'
7 0
'
@ 9
'
measure
measure
xz
measure
measure
measure
'
measure
'
measure
measure
@ )0
@0
measure
E @
@0
@0
@ )0
@0
@ )0
@ )0
@0
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ C
from (6.1)
substitute
7 B
7 B
@ @
'
@ @
C HAPTER 6. Q UANTUM
PROGRAMMING
46
which is implemented by the above classical program. The proof of renement can be found in Appendix C.2. In other words, the quantum solution offers an exponential speed-up. Deutsch-Josza algorithm is a powerful illustration of the potential of quantum computation.
6.5
Grovers search
Grovers quantum search algorithm [6] is well-known for the quadratic speed-up it offers in the solutions of NP-complete problems. The algorithm is optimal up to a
7 BE 0
7 8
followed by
where
'
7 BE 0
7 BE
'
7 E 0
7 BE 0
which we denote
, i.e.
and
for all
'
1' @
2
, such that
. For simplicity we assume that there is only a single solution, . The proofs are not very
to
7 E BD0
, nd
BE 7
' (%
5
'
@ @
7 BE
C HAPTER 6. Q UANTUM
PROGRAMMING
47
the system. Finally, the state is measured. The probability of error is determined by the number of iterations performed by the algorithm. The algorithm can be understood in a beautiful way with the help of a geometric
be the sum over all , which are not solutions, and let
be the solution:
by
followed by
dene
radians is:
Suppose we charge one unit of time for each call to the oracle and all other operations are free. Consider the specication:
the number of times we use the oracle. We show that Grovers algorithm implements this specication.
7 BE
2
where
'
'
2 2 2 2
and
. Similarly, the
2
'
'
'
@ @
@ $
@ @ @
'
'
'
7 BE 0
C HAPTER 6. Q UANTUM
As usual, we want to specify the quantum state that, when measured, gives the
PROGRAMMING
/2 /2
Uf
'
'
measure
trigonometry
def. of
@ @
arithmetic
measure 48
@ @
@ @
@ @
C HAPTER 6. Q UANTUM
PROGRAMMING
49
Let
iterations performed:
trigonometry
def. of
and
arithmetic
7 E 0
, and we already know that this superposition can Hadamards to the zero state of an -qubit system.
@0
and
and we are
@0
@0
@9 @ @ 0
@9 @ @ 0
ication
Since
rotations by
substitutions denition of
measure
2 2
2
! % !
! % !
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
C HAPTER 6. Q UANTUM x
PROGRAMMING
50 Hadamard
Proving the renement is a bit of work. Firstly, let us analyse the action of the oracle
arithmetic
'
@ @
if
then
else
'
'
'
'
'
'
@ @
@ @
if
then
else
'
' 2 ' @
else
if
then
is:
'
action of
@ )0
@0
2
@0 )D
2 $
@0
'
'
'
'
'
'
'
'
'
if
then
else
@0
)
@ )0
E
'
@ @ @ @ @ @ @ @ @ @
@0
'
@ @ @ @ @ @
is easy. Adding
oracle
We now recall some trigonometry to prove that this state is identical to the state of the
2
'
arithmetic
2 2
' '
@
x
2
'
2
' '
2 2
'
2
2
'
'
'
@
'
'
'
2
$
'
'
2
'
C HAPTER 6. Q UANTUM
PROGRAMMING
in the
plane is:
action of
2
2
2 2
2
@ @
'
'
2
2
2
2 2
@ @
2 2
2 2
$
system after
rotations by
radians.
denition of
trigonometry linearity 51
2
2
2
@ @
2 2
2
2
2 2
2
@ @
@ @
@ @
@
@0
@ )0
)
@ 0 )
Finally, we are ready to prove the renement. Starting with the right side:
' $
@ @
('
2
2
2 2
2 2
2
2 2 2 2 2 2 2 2 2 2 2 2 2 2
2
2
2 2
2 2
2 2 2
so that
and similarly
C HAPTER 6. Q UANTUM
PROGRAMMING
denition of
trigonometry
trigonometry
trigonometry
'
'
2
@ @ $
else
if
then
expand
(6.3)
@9 0
if
then
else
@0
@ )0
@ )0
@0
substitute, weaken 52
@ @
@ @ @ @
@ @
@ @
@ @ @ @
@ @
PROGRAMMING
53
if
then
else if
then
else if
then
else
In summary,
Or we might ask how many iterations should be performed to minimise the probability of an error. Examining rst and second derivatives, we nd that the above probability
the number of iterations performed must be a natural number. It is interesting to note that probability of error is periodic in the number of iterations, but since we dont gain
2
@
. Finally, assuming
is minimised when
iterations is
2
Specication
@0
@ )0
@0
@9 0
if
then
else
@ )0
measure
'
'
else
2 2 2 2
)
@0
@9 @ 0
@ @
@ @
@ @
@ @
@ @
@ @
math, weaken
context
from (6.3)
case idempotence
, ,
C HAPTER 6. Q UANTUM
PROGRAMMING
54
In contrast, the best a classical algorithm can do to solve the problem is to randomly
6.6
As we have discussed in section 3.2, the state of a quantum system after a measurement
state of the system. Rather, it describes our knowledge of in what state the system is.
unitary operations are not applicable to mixed states. Traditionally, the application of
also inconsistent.
In our framework, there is no need for an additional mechanism to compute with mixed states. Indeed, a mixed state is not a system state, but a distribution over system states, and all our programming notions apply to distributions. The above mixed state
, the probability of
also
and ,
is
with probability
2 @
2 E
, which is
, it is
with probability
, which is
@ E
@ 9E
E
is the state
with probability
notation
Writing
probability
, which is
is
with probability
and it is
!
7 E
should with
. This
C HAPTER 6. Q UANTUM
PROGRAMMING
55
as desired. Similarly, there is no need to extend the application of unitary operators. Consider the following toy program:
In the second application of Hadamard the quantum state is mixed, but this is not evident from the syntax of the program. It is only in the analysis of the nal quantum state that the notion of a mixed state is meaningful. The operator is applied to a (pure) system state, though we are unsure what that state is.
measure else
E @
@0
'
E @
if
then
else
@0
@ E @
if
then
@0
E @
measure
if
then
else
sequential composition
@ @
@ )0
@0
2 2
measure
as before
and
2 @
@
'
E E @ 7
@ )0
@ @
'
@0
@ @ @ @ @ @ @ @ @ @ @ @
C HAPTER 6. Q UANTUM
PROGRAMMING
56
A lot of properties of measurements and mixed states can be proven from the denitions of measurement and sequential composition. For example, the fact that a measurement in the computational basis, performed immediately following a measurement in the same basis, does not change the state of the system and yields the same result as the rst measurement with probability , is proven as follows: measure
In case of a general quantum measurement, the proof is similar, but a little more computationally involved. Recall the example from section 4.2.2: if then else
and
@0 )D
@ )0
)
E @
measure
measure
E @
E @ 2
@
E @
E @
'
E @
FC E
E E
7 2 2 '
@ @ @
@ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @
measure
with prob-
E @
FC E
@ @
E @
E @
E @
)
E @
)
7
2
)
E @
@ )0
)
)
E @
E C
@ )0
)
BE 0 7
ability
C HAPTER 6. Q UANTUM
if
E @
else
then
PROGRAMMING
measure
@0 )D
E @
E C
We need to prove that the new program is correct. In other words, we need to show
@ )0
@0
@0
if
E @
else
@0
@ )0
if
E @
else
then
then
measure
and
apply
E C
@ @
@0
@ )0
if
E @
else
then
E @
if
E @
else
then
'
if
E @
else
then
seq. composition
if then else ,
substitute,
arithmetic
E @
E @
E @ E @
@ @
E @
E @
FC E
@ @
measure
. Starting with
sum 57
@ @
@ @
' (% ! % !
7
2
' (% ! % !
@
@ E
2
2
@ E
@
! !
Let us prove it. Adding time and starting with the right side:
@ E
and
C HAPTER 6. Q UANTUM
if
E @
else
then
PROGRAMMING
measure
apply
! %!
@ E
@ @0 )D @0
2
@ E
@
@ )0 @0
'
if
E @
else
then
if
E @
else
then
composition
substitute,
sequential
measure,
sum
@ E
@ E
@
'
'
@ @
'
@ @
@ E
58
2
! %!
2
@
@ E
@
@ E
! %! ! %! @
@ E @ E
! ! %
! %!
! %!
2 @ E 2 @ E
@ @ @ E @ E
2
C HAPTER 6. Q UANTUM
if
E @
else
if
E @
else
! %!
time units for the if then else expand simplify math sum, , 59
@ E
@ @
E @ E @
@ E
@ @
E @
'
@ @
'
@ @
'
@ @
C HAPTER 7. C ONCLUSION
AND
F UTURE W ORK
61
structures in a readable fashion. As was mentioned in Chapter 2, a few attempts were already made in this direction. Since the works of Omer [13] and later Betelli et al. [2] do not involve mathematical proof techniques, there is little use in comparing our work to theirs. The quantum programming language, proposed by Selinger [15], is also very different from our approach. It uses density matrices to represent quantum states, which has both advantages and disadvantages. One obvious advantage of his approach is uniform treatment of pure and mixed states. Disadvantages of using density matrices include the inherent difculty of applying operations to them and problems with visual recognition of quantum states and their properties. A claimed advantage is a lack of growth in distributions as the computation progresses. However, the expressions describing the density matrices still grow in the same fashion. In addition, their use of ow charts to represent quantum programs also decreases readability and ease of writing somewhat, for more complex algorithms. The work of Sanders and Zuliani [14] is more similar to our work. Our claim is that, while being no less expressive than qGCL, our approach is simpler and more intuitive. Facility of developing recursive programs, familiarity of notation, and uniformity in time complexity analysis are the evidence. Research in the immediate future will involve reasoning about non-locality. We will attempt to express quantum teleportation, dense coding, and various games involving entanglement, in a way that makes complexity analysis of these quantum algorithms simple and natural. We can easily express teleportation as renement of a specica-
more interested in the possibilities of simple proofs and analysis of programs involving communication, both via quantum channels and exhibiting the LOCC (local operations, classical communication) paradigm. We also plan to formalise quantum cryptographic protocols, such as BB84 [1], in our framework and provide formal analysis of these protocols. This will naturally lead to formal analysis of distributed quantum algorithms
tion
and
C HAPTER 7. C ONCLUSION
AND
F UTURE W ORK
62
Bibliography
[1] C. H. Bennet and G. Brassard. Quantum cryptography: Public key distribution and coin tossing. In IEEE Int. Conf. Computers, Systems and Signal Processing, pages 175179, Bangalore, India, 1984.
[2] S. Bettelli, T. Calarco, and L. Serani. Toward an architecture for quantum programming. In The European Physical Journal, pages 181200, 2003.
[3] M. Boyer, G. Brassard, P Hyer, and A. Tapp. Tight bounds on quantum searching. . In Fortschritte der Physik, pages 493506, 1998.
[4] D. Deutsch. Quantum theory, the church-turing principle and the universal quantum computer. In Proceedings of the Royal Society of London, pages 97117, 1985.
[5] D. Deutsch and R. Jozsa. Rapid solution of problems by quantum computation. Proceedings of the Royal Society of London, 439:553558, 1992.
[6] L. K. Grover. A fast quantum mechanical algorithm for database search. In TwentyEighth Annual ACM Symposium on Theory of Computing, pages 212219, Philadelphia, PA, May 1996.
[7] E.C.R. Hehner. a Practical Theory of Programming. Springer, New York, second
B IBLIOGRAPHY
64
[9] R. Jozsa. Quantum algorithms and the fourier transform. Proceedings of the Royal Society of London, pages 323337, 1998. [10] E. Knill. Conventions for quantum pseudocode. Technical Report LAUR-96-2724, Los Alamos National Laboratory, 1996. [11] W. K. Nicholson. Linear Algebra with Applications. PWS Publishing Company, third edition, 1993. [12] M. A. Nielsen and I. L. Chuang. Quantum Computation and Quantum Information. Cambridge University Press, 2000. [13] B. Omer. Quantum programming in qcl. Masters thesis, TU Vienna, 2000. [14] J. W. Sanders and P Zuliani. Quantum programming. In Mathematics of Program . Construction, pages 8099, 2000. [15] P Selinger. Towards a quantum programming language. Mathematical Structures . in Computer Science, 2004. [16] A. Yimsiriwattana and S. J. Lomonaco Jr. Distributed quantum computing: A
( # % $ ! # ! )'&"
Appendix A Notations
ket in Dirac notation (6) complex conjugate (6) inner product (6) Hilbert space (6)
65
)
dual vector (7) outer product (7) norm (8) adjoint (8) tensor product (9) Hadamard transform (16) (19)
66
bunch inclusion (21) function (22) quantiers (22) time variable (23) space variable (23)
innity (24)
if then else
measure
x
from (including)
@ @
@ @
if then else
' 0
0
7
@ @
@0 2
math symbols (20) (20) boolean symbols (20) sequential composition (20) to (excluding) (21)
67
expand
For a state
of an -qubit system:
68
for
substitute
in
@ @
@ @
@ @
'
'
7 BE 0
if
then
else
(for
substitute
in )
'
@ @
7 7
@ @
@ @
@0
if
then
else
if then else sequential composition substitution case idempotence one point law portation Modus Ponens
and :
7 7
@
@ @
@
5'
@ 6
'
7 BE 0
2
' '
2 $
2
'
Hadamard transform
Hadamard on
7 E 0
E 9 5 BE 0 5 7 0 ' 7
7 BE 0
7 BE 0
' 5
xy
For a collection
equation
, an observable
Hadamard on x
quantum oracle
, where
'
7 BE 0
measure
measure
measure
with eigenvalue
measurement
measurement
measurement
in basis
measure
@ @
@ @
@ @
@ @
! 6 @
@
2
@
'
' (%
7 0 E 9
@ @ @ @
@0
@ '
7 BE 0 7 BE 0 @ )0
'
E
@
'
2 (% '
7 BE 0
C.1
Appendix C
if
then
@ 0
' (%
else if
then
else
denition of
denition of
E E
@
' @
' 1
(% ' ' (%
@ )0
70
E
@
'
(% '
7 BE 0
7 BE 0 7 BE 0
@ @ @
7 BE 0 7 BE 0
@ E
@ @
substitute
simplify
@ @
@0 @0
' '
E E
@ )0 @ @ @ )0
2
@ 0
@ @ @ @
@ @
@
' 1
7 BE 0
' (%
@ @
@
7 BE 0
'
@
'
7 0 BE 9
(% '
@ @
'
@ @
@ @
'(% ' (%
(% '
'
'
@
'
(% '
'
@0
@
'
(% '
7 BE 0
7 BE 0 @ )0
'
@
2
A PPENDIX C. P ROOFS
if
then
)@0
' (%
else if
then
OMITTED FROM
else
@0
@ )0
if
then
)@0
' (%
else if
then
else
@ @
if
then
)@0
' (%
else if
then
@ )0
else
@
7 0 BE 9
@ @
7 0 E 9
if
then
' (%
else if
then
else
@
7 0 BE 9
@ @
C HAPTER 6
@ @
7 BE 0
@
@
@ @
@
7 0 E 9
@ @
@ @
@ @
@ @
@ @
@
@
' ' @
(% '
'
7 BE 0
@ @
portation
'
7 BE 0 E
(% ' ' (%
' 1
7 BE 0 @
' (%
@ ' 7 BE 0 @ @ @ @ @@ @ @ ' 7 BE 0
@ @
@ (% '
@
' @
(% '
@ @
72
'
7 BE 0
A PPENDIX C. P ROOFS
OMITTED FROM
C HAPTER 6
Modus Ponens
@
'
7 0 E 9
' (%
'
@ @
7 BE 0
@ E
'
7 BE 0
(% '
7 BE 0
@ @
(% '
@
E
7 0 E 9
' (%
@ '
@
7 0 BE 9 @
'
@ @ @
@ @
portation
@ @
'
7 BE 0
' (%
@ @
@ @
@ @ @ @
7 BE 0
2 2
@ @
@ )0
2
@
' (%
@ @
@0 @0 @0
@ (% '
@
@ @ @
C.2
To prove the second renement, we divide the proof into three simpler proofs, as in the
2
' (%
@
'
' (%
@ @
2
@
@ )0
E
@0
' (%
'
(% '
A PPENDIX C. P ROOFS
if
OMITTED FROM
then
)@0
' (%
else if
then
C HAPTER 6
else
@ )0
denition of
@
' (%
@
'
(% '
@ @
@ )0
@0
E
@ )0
7 E 0
'
7 BE 0
previous section:
@ @
7 BE 0
7 BE 0
@ @ @
7 0 BE 9
substitute
simplify 73
'
@ @
7 0 BE 9
'
7 BE 0
@0 )D
@0 @ @
2
@ @
7 BE 0
@0 @ @
@ @
@ @
@
portation
' (%
@
'
7 0 BE 9
(% '
'
@ @
E
@
'
7 0 BE 9
7 BE 0
@ @ @ @
@ @ (% '
@ (% ' (% '
@
@ @
7 BE 0
@
substitute
@
'
@ @ @ @
@ @ (% '
@ (% ' (% '
'
7 0 BE 9
@ @
7 BE 0
@ @ @
@ (% '
'
@0 )D
' (%
@
'
' (%
@
@ @
'
@ ' (%
(% '
@
@ @
'
@ @ ' (%
@
(% '
@ @
@ @ @
@ @
@
7 0 E 9
'
7 BE 0
@
7 0 BE 9
@ @ @
@
A PPENDIX C. P ROOFS
OMITTED FROM
C HAPTER 6
substitute
portation 74
7 BE 0
'
@
7 0 BE 9
@ @ @
@
7 BE 0
'
@0 )D
A PPENDIX C. P ROOFS
OMITTED FROM
C HAPTER 6
Modus Ponens
@ @
absorption
(% E @ ' (% BE 0 @ ' ' 7 ' ' 7 0 (% E @ ' (% BE 9 @ @ @ ' 7 BE 0 @ ' 7 ' BE 0 (% @ (% E @ ' (% BE 0 @ ' ' 7 ' (% E @ ' (% BE 9 @ ' 7 0
@ @
'
7 BE 0
'
E
@ @ @ @
' (%
'
7 0 BE 9
substitute
substitute
portation
@ @
7 BE 0 @
'
7 0 BE 9
'
' (%
@ @
(% '
'
7 BE 0
@ @ @ @
' (%
@ E
' @
' (% (% '
'
7 0 BE 9
@ @
7 BE 0 @
' (%
7 0 BE 9
'
@ @
(% '
'
7 BE 0
' (%
@ @
@
'
@
@0 )D @ @ @
' (%
7 0 BE 9
(% ' (% '
@ @
7 BE 0 @
7 0 BE 9
'
' (%
@ @
7 BE 0
@0
' '
' (%
@0 )D
75
' (%
(% '
then
@
' 1
@
@ ' (%
@ E
7 0 BE 9 @ )0
' (%
)@0
' (%
(% ' (% '
2 )@0 )@0 (% @ ' )@0 @ @ 0 @ 2 (% @ @ E @ 1 (% BE 0 @ @ 2 ' ' ' 7 2 )@0 E @ 0 @ 0 @ ' (% @ @ E @ 1 (% BE 0 @ @ ' ' 7 (% @ '
(% '
@ E @ E
@
' @
@0
'
E
(% ' (% '
@ )0
A PPENDIX C. P ROOFS
else if
else if
@0 )D
7 BE 0 7 BE 0
@0 )D
if
then
if
then
@ )0
if
else
then
@
@
' (%
else if
else
@ E
'
7 0 E 9
@ @
OMITTED FROM
then
then
C HAPTER 6
else
substitute
substitute math 76
@ @
@ @
@ @
@ @
@ E @ E
@
' @
7 BE 0 7 BE 0
' (%
@ E
portation
@ (% '
@
' (%
@
@ E
@ (% '
' (% 2
@
@ E
@
@
A PPENDIX C. P ROOFS
OMITTED FROM
C HAPTER 6
portation
weakening
(% ' ' (%
'
(% ' (% '
' (%
' 1
' (%
7 BE 0
@ @
@ @ @
'
7 BE 0
(% '
@ @
simplify simplify 77
@ @