Vous êtes sur la page 1sur 204

Vicente Moret-Bonillo

Adventures
in Computer
Science
From Classical Bits to Quantum Bits
Adventures in Computer Science
Vicente Moret-Bonillo

Adventures in
Computer Science
From Classical Bits to Quantum Bits
Vicente Moret-Bonillo
Departamento de Computación
Universidad de A Coru~na
A Coru~na, Spain

ISBN 978-3-319-64806-4 ISBN 978-3-319-64807-1 (eBook)


DOI 10.1007/978-3-319-64807-1

Library of Congress Control Number: 2017948673

© Springer International Publishing AG 2017


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt
from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained
herein or for any errors or omissions that may have been made. The publisher remains neutral with
regard to jurisdictional claims in published maps and institutional affiliations.

Printed on acid-free paper

This Springer imprint is published by Springer Nature


The registered company is Springer International Publishing AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
To my family
Preface

Would you tell me, please, which way I ought to go from here? said Alice. That depends a
good deal on where you want to get to, said the Cat. I don’t much care where, said Alice.
Then it doesn’t matter which way you go, said the Cat.
Lewis Carroll

In a long academic career teaching different subjects in the fields of chemistry,


physics, and computer science, I noticed how many of my students finish their
studies knowing how to do things, although sometimes they do not understand the
basic underlying concepts that permit generalization and reasoning by analogy. In
fact, I am convinced that, perhaps, our teaching efforts focus excessively on
specialization. I fear that educators (and I belong to this exciting community)
very frequently overlook some very interesting questions that deserve deep and
abstract thinking. In other words, we center more on problem solving than on the
problem itself. We also assume that our students are capable of thinking by
themselves, and they are, of course, but it is also true that not all of them have
the same skills when trying to find the solution to a problem that has not previously
been explained. However, these skills can be fostered by the teacher and acquired
by the student, and I believe that at least a part of this training is our responsibility
as educators. With these ideas in mind, I decided to write this book. It is an almost
speculative text in which I discuss different areas of science from a computer
science perspective. This fact will be more evident in some chapters of the book
than in others.
The main focus of the text is the basic unit of information and the way in which
our understanding of this basic unit of information has evolved over time. Do not
expect to find anything new in this book; you may even consider the way I have
chosen to explain things to be extravagant. This could be due to the fact that I was
inspired by my readings of two brilliant scientists and communicators: Richard
P. Feynman and George Gamow. I hope that the final outcome will be to pique the
reader’s curiosity and lead him or her to think with the sole objective of better
understanding our world. As I used to say, and according to Richard P. Feynman:
“All right, I have not been the first, but at least I understand it.”

vii
viii Preface

The scientific material of this book covers concepts related to information,


classical computing, logic, reversible computing, quantum mechanics, quantum
computing, thermodynamics, and something of artificial intelligence and even
biology, all approached from the point of view of the computer sciences. In some
chapters, the discussion is extremely informal, even irreverent, but I think that this
way of presenting difficult concepts may stimulate the curiosity of the reader. In
fact, it was my own doctoral students who suggested I write a book based on my
notes for the doctoral course on “Physical Models in Advanced Computing” that I
teach, as I had done previously with the notes of an undergraduate course on
“Artificial Intelligence.” Perhaps this is why the book’s layout may seem to be
rather unusual, although, in the opinion of the author, this is not entirely a bad thing,
as it means the reader can pick and choose chapters in no particular order and still
achieve a reasonable understanding of the material.
The book can be used by graduate, postgraduate, and even doctoral students,
although I suggest that it would most benefit graduate students—and people
suffering from insomnia! The apparent disorganization of this book is not
indeliberate. In fact, it took me a long time to properly disorganize the text so as
to encourage the reader to embark on reasoning by analogy and also to force them to
verify for themselves some of the stranger ideas and approaches described in
the book.
The material in this book has been organized into eight chapters. Chapter 1
focuses on “classical bits.” Chapter 2 explains “reversibility.” Chapter 3 discusses
“reversible architectures.” Chapter 4 describes basic “quantum mechanics princi-
ples.” Chapter 5 draws on the material presented in Chaps. 2–4 in order to introduce
the “quantum computing paradigm.” Chapter 6 discusses “Feynman’s universal
quantum machine” in depth. Chapter 7 explores key “quantum algorithms.” Finally,
Chap. 8 poses questions for reflection and discussion. Each chapter concludes with
a summary, a glossary of terms, and an explanation of the notation used. Before the
bibliography, Appendix A provides some mathematical background, and Appendix
B brings together the terms used in each individual chapter in a glossary.
The book begins by asking the following question: what is a bit? This apparently
trivial concept is not, in fact, so trivial and we spend several pages thinking about
it. We continue with some fundamental and elementary computations with bits in,
for example, binary arithmetic and binary logic and describe the implementation of
a number of classical operations by means of logic gates. We then introduce the
concept of reversible computing in terms of (1) a detailed description of conven-
tional reversible logic gates, (2) a redesign of conventional logic gates so that they
are reversible, (3) the construction of a simple reversible adder, (4) a fun example of
reversibility, and (5) a brief analysis of the requirements imposed by reversibility.
Next comes a more or less formal description of what we call reversible architec-
tures, and we analyze two examples in depth. In one example, a great deal of
disorder is generated, and in the other, none. This issue of disorder has important
implications for certain phenomena related to the fundamental and basic energy
required for an abstract computation. The discussion of reversibility draws greatly
Preface ix

on the Feynman Lectures on Computation, which, of course, is cited in the


Bibliography.
Next, we try to establish a relationship between three essential questions that
justify quantum approaches in the computer sciences: (1) the energy required to
perform a real-life computation, (2) the size of current processors, and (3) the
reversibility of quantum operations. We then offer a historical perspective on the
antecedents and basic concepts of quantum mechanics, the conundrum implied by
Heisenberg’s uncertainty principle for the concept of measurement, and the
description of quantum states by means of Schr€odinger’s equation. This all lays
the groundwork for what comes later in the book.
Based on the above concepts, we establish the conditions that justify the use of
quantum techniques for certain kinds of computational tasks. Next, we use formal
descriptions and formal argumentations—rather than a traditional approach—to
introduce key quantum mechanical concepts and approaches. Nevertheless, the
mathematical load is minimized as much as possible, and we adopt the axiomatic
formulation of quantum mechanics. After a review of certain fundamental prelim-
inary questions, we proceed directly to a description of the quantum unit of
information, the definition of certain essential elements in quantum computational
approaches, and the introduction of possible physical representations of quantum
computational systems. We also describe some fundamental properties of quantum
operators, explore the concept of quantum information, and suggest how to build
systems capable of handling several quantum bits (or qubits). Finally, we study the
problem of the collapse of information associated with the measurement of qubits
as a consequence of Heisenberg’s uncertainty principle.
The rest of the book is formally different. Whereas the earlier chapters navigated
the universe of concepts and ideas, we now enter the world of practical issues and
describe the universal quantum architecture proposed by Feynman in detail. We
begin with a discussion of a kind of peculiar matrices and show how these rather
curious matrices can be used to represent the behavior of reversible logic gates. We
also explore the Hamiltonian operator proposed by Feynman for quantum compu-
tation. The detailed approach followed here is illustrated with the original Feynman
example, analyzed in depth from different points of view.
Having explored the basic concepts and a universal architecture, we next
consider some remarkable quantum algorithms. The approach is based on “Quan-
tum Circuit Theory,” which, in our opinion, is more easily understood than, for
example, the “Adiabatic Computation” approach. We begin with Deutsch’s algo-
rithm and its versions, analyzed from several different points of view. We then
generalize this algorithm and introduce the Deutsch-Jozsa algorithm. We next
explore the algorithm proposed by Simon, developing an alternative, more trans-
parent version. We conclude our description of quantum algorithms with a discus-
sion of quantum teleportation, using spies to illustrate it. We close the circle with
something akin to pure speculation, based on developments in 2014 and 2015 in
relation to attempts to develop quantum computers. We also refer briefly to
thermodynamics, biology, and artificial intelligence and conclude with some
thoughts on the material presented in the book.
x Preface

Just to reiterate—although this book does not contain anything particularly new,
it is to be hoped that the reader will find novelty in the way the material is presented.
Enjoy!

A Coru~
na, Spain Vicente Moret-Bonillo
2017
Contents

1 The Universe of Binary Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


1.1 Looking for the Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Number Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Single Bits Represented with Stickers . . . . . . . . . . . . . . . . . . . . . 10
1.4 Binary Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5 Logic Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.6 Some Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.7 A Peculiar Way to Compute . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.8 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.9 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 25
2 Back and Forth Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1 Introducing Reversibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2 The Toffoli Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3 The Fredkin Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4 Building Reversible Gates from Reversible Gates . . . . . . . . . . . . 33
2.5 Adding in a Reversible Way . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.6 Back to Billiards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.7 A Simple Analysis of Reversibility . . . . . . . . . . . . . . . . . . . . . . . 36
2.8 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.9 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 37
3 Reversible Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1 Basic Reversible Logic Gate Architectures . . . . . . . . . . . . . . . . . 40
3.2 The Reversible Full Adder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.3 Architecture of the General-Purpose Reversible Computer . . . . . . 47
3.4 Energy Repercussions of Reversibility . . . . . . . . . . . . . . . . . . . . 49
3.5 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.6 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 50

xi
xii Contents

4 The Principles of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . . . 53


4.1 History and Basic Concepts of Quantum Mechanics . . . . . . . . . . 53
4.2 Heisenberg’s Uncertainty Principle . . . . . . . . . . . . . . . . . . . . . . . 56
4.3 Schr€odinger’s Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.4 Schr€odinger’s Equation Revisited . . . . . . . . . . . . . . . . . . . . . . . . 64
4.5 The Postulates of Quantum Mechanics . . . . . . . . . . . . . . . . . . . . 66
4.6 Some Quantum Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.8 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 72
5 Introducing Quantum Computing . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.1 A Brief Overview of Quantum Computing . . . . . . . . . . . . . . . . . 75
5.2 The Formalism of Quantum Computing . . . . . . . . . . . . . . . . . . . 81
5.3 Systems of Qubits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5.4 Qubits and Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.5 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.6 Constructing Algorithms with Qubits . . . . . . . . . . . . . . . . . . . . . 98
5.7 Summary of the Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
5.8 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 116
6 Feynman’s Quantum Computer Machine . . . . . . . . . . . . . . . . . . . . 119
6.1 Playing with Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
6.2 Quantum Computer Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.3 The Quantum Computer at Work . . . . . . . . . . . . . . . . . . . . . . . . 130
6.4 Setting Up the Quantum Computer . . . . . . . . . . . . . . . . . . . . . . . 131
6.5 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
6.6 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 133
7 Some Quantum Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
7.1 Deutsch’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.2 The Deutsch-Jozsa Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
7.3 Simon’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
7.4 Quantum Teleportation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
7.5 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
7.6 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 163
8 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
8.1 What Are We Talking About? . . . . . . . . . . . . . . . . . . . . . . . . . . 165
8.2 The Situation in 2014 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.3 Human Brains and Computers . . . . . . . . . . . . . . . . . . . . . . . . . . 167
8.4 Artificial Intelligence, Parallelism and Energy Efficiency . . . . . . . 168
8.5 Energy Restrictions on Information Processing . . . . . . . . . . . . . . 169
8.6 Some Things to Ponder on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Contents xiii

8.7 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176


8.8 Glossary of Terms and Notation Used in This Chapter . . . . . . . . . 176

Appendix A: Mathematical Background . . . . . . . . . . . . . . . . . . . . . . . 179


A.1. Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
A.2. Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
A.3. Hermitian and Unitary Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 184

Appendix B: Glossary of Terms Used in the Book . . . . . . . . . . . . . . . . 187

Suggested Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Chapter 1
The Universe of Binary Numbers

A large part of mathematics which becomes useful developed


with absolutely no desire to be useful, and in a situation
where nobody could possibly know in what area it would
become useful; and there were no general indications that it
ever would be so. By and large it is uniformly true in
mathematics that there is a time lapse between a
mathematical discovery and the moment when it is useful;
and that this lapse of time can be anything from 30 to
100 years, in some cases even more; and that the whole
system seems to function without any direction, without any
reference to usefulness, and without any desire to do things
which are useful.
John von Neumann

Before we start reflecting on difficult problems, we will review certain more or less
trivial concepts that are related to the peculiar entities and techniques already
implemented in our computers so that they can compute. Our computers are based
on binary logic, which uses the concept of bit to represent something that is true
(denoted by |1〉) or false (denoted by |0〉). As for the strange bar-and-angle-bracket
symbol, its exact meaning will become clear later. For the moment accept that if
the state of something is true, then the representation of that state is |1〉, and if the
state of something is false, then the representation of that state is |0〉. But let we
pose two questions:
• What kind of a thing is a bit?
• Is there a formal definition for the concept of bit?

© Springer International Publishing AG 2017 1


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_1
2 1 The Universe of Binary Numbers

1.1 Looking for the Bit

A common definition of the term bit is “a unit of measure of information by means


of which the election between two equally likely possibilities can be represented.”
This definition is strictly true but it seems (at least to me) to be rather dense. We will
spend some lines analyzing this definition:
• “Measure of information. . .” (There are no problems with this statement)
• “Election between two equally likely possibilities. . .” (We can go deeper into
this last statement)
The meaning of the phrase “Two equally likely possibilities. . .” is quite obvious.
For example, if we have A and we have B, and only have A and B, then the
probability of A, P(A), is equal to the probability of B, P(B). Assume the following
notation:

X  fPð AÞ ¼ Pð BÞ g

That is to say, we denote by X the circumstance that events A and B are equally
likely. According to this, the official definition of bit could be translated as follows:

BIT  Election fA; B=Xg

In this expression, {A,B/X} means A or B given X, and, from our point of view,
the problem of the official definition lies in the term ‘election’. The interpretation of
this term might be confusing.
The definition given by the “Diccionario de Computación (In Spanish)”
published by McGraw-Hill in 1991 establishes that a bit is “the unit of information
equivalent to a binary decision.” This definition is almost the same as the previous
definition, with “election,” however, replaced by the stronger term “decision.” This
definition seems to be also ambiguous and imprecise.
A second meaning of the term given in the same dictionary establishes that “a bit
is a non-dimensional unit of the capacity of storage that expresses the capacity of
storage as the base 2 logarithm of X, X being the number of possible states of the
device”. This statement goes directly to the domain of axiomatic definitions. But. . .
what “device” is referred to here? And. . . why “base 2” and not, for example, “base-
5”? The reason for this base will be discussed later on in the text.
Let us leave aside academic sources of definitions for the moment. The author of
this text did once an experiment consisting of asking some of his closest col-
leagues—all professionals in the computer sciences—for their own definitions of
bit. Their definitions are as follows:
• A mathematical representation of the two possible states of a switch that uses a
base 2 number system.
• A minimum unit of information of an alphabet with just two symbols.
• The smallest unit of information in a machine.
1.1 Looking for the Bit 3

• A binary digit.
• A unit of numbering that can take the values 0 or 1.
• The minimum quantity of information that can be stored and transmitted by a
computer system.
The full list of definitions, included the academic ones, can be classified into
three different categories:
(a) Those that emphasize conceptual nuances.
(b) Those that focus on units of information.
(c) Those that highlight the binary nature of the bit.
It is clear that the bit exists by definition, exactly for the same reason that the
color red is red because scientists decided that, in the visible spectrum of light, the
700–635 nm wavelength interval corresponds exactly to the color red. But do we
really need scientists to identify colors? After all, ordinary people recognized colors
long before scientists formally defined them.
Following this rather crazy line of reasoning, there must be something essential
and intuitive in colors that means that they can be recognized without needing a
definition or some kind of formal characterization. And this is exactly what we are
going to explore regarding the bit. In particular we will try to find answers to the
following questions:
(a) Is there something apart from its own definition that justifies the concept of bit?
(b) Is there something that allows us to identify the bit as a basic unit of
information?
(c) Is there something that allows us to establish the binary nature of the bit?
But first let us digress briefly. In almost all scientific problems it is possible to
reason following one of two different strategies:
• From data to conclusions. In artificial intelligence, this is data-driven reasoning.
• From a hypothesis to data that confirm the hypothesis. In artificial intelligence,
this is backward reasoning.
In both cases knowledge is necessary, and the only difference is in how this
knowledge is applied.
In data-driven reasoning, if we know that our knowledge base Θ includes five
rules (or chunks of knowledge) as our axioms:

Θ ¼ fR 1 ; R2 ; R3 ; R4 ; R5 g

and if we know that these rules are

R1  Axiom1 : IF A THEN B
R2  Axiom2 : IF B AND C THEN D
4 1 The Universe of Binary Numbers

R3  Axiom3 : IF D AND E AND F THEN H


R4  Axiom4 : IF A AND Z THEN V
R5  Axiom5 : IF V AND X AND G THEN W

and if we also know that the set of data Δ for our problem is

Δ ¼ fA; C; E; Fg

then we can conclude B, D and H by directly applying Axiom1, Axiom2 and


Axiom3—in that order—to our set of data Δ. Thus

Axiom1 ðΔÞ ! Δ0 ¼ fA; C; E; F; Bg


00
Axiom2 ðΔ0 Þ ! Δ ¼ fA; C; E; F; B; Dg
 00  000
Axiom3 Δ ! Δ ¼ fA; C; E; F; B; D; Hg

But now we have to stop since we have no further knowledge that will yield new
information. This is the way data-driven reasoning works.
If, on the other hand, we want to apply a backward-reasoning process, we first
need a working hypothesis, for example D, and then have to use our axioms to look
for information that will confirm or reject this hypothesis.
Using the same example as above, to confirm D we need to use Axiom2 (because
D is in the conclusion part of the axiom). Since all the axioms are true, we require
the condition component of Axiom2 also to be true. But for B and C in the condition
component, C but not B is in Δ, and so we need B in order to confirm our initial
working hypothesis D. B therefore has to be considered as a new working hypoth-
esis. In order to confirm B, we have to use Axiom1, which needs A in its condition
component. Since A is in Δ, then we can apply Axiom1 to deduce B. Once we know
that B is true, then we can apply Axiom2 and deduce D. This is how backward
reasoning works.
Note that the set of axioms Θ and the initial set of data Δ are exactly the same in
both cases, yet the final result is different. Thus, denoting by Ψ the information
obtained after reasoning with our data and axioms, the results are

ΨDATA DRIVEN REASONING ¼ fA; C; E; F; B; D; H g


ΨBACKWARD REASONING ¼ fA; C; E; F; B; Dg

The difference between the two processes is not related to the actual information
used, but to the way in which this information is used. Something similar occurs in
physics with electromagnetism. We can begin with Coulomb’s law and arrive at
Maxwell’s equations, or we can start with Maxwell’s equations and arrive at
Coulomb’s law. Again, the way we apply our knowledge is different.
And what link is there between the above arguments and the concept of bit?
None, in fact. The idea was to highlight how information and knowledge can be
1.1 Looking for the Bit 5

used in many different ways to produce different results (if you have trouble
believing that, ask a politician!).
Returning now to the bit, let us explore some ideas. Suppose that we do not know
what exactly a bit is, that is to say, we have no definition. Could we justify its
existence or even find some kind of proof to demonstrate that there is a formal
definition?
Assume that we have a problem about which, initially, we know almost nothing
other than
1. We know we have a problem.
2. The problem may have a solution.
If there is a solution, it has to be one of the solutions si in a given space S of
possible solutions.
Since we do not know the solution to our problem, all si 2 S are equally likely
(that is to say, any possible solution may be the real solution.) What we can do is
gradually seek out information that can be used to discard some of the initial
options in S. The more relevant the information collected and applied to our
problem, the smaller the remaining space of possible solutions. This situation is
illustrated in Fig. 1.1.
We will now formalize the problem in mathematical terms. Let N be the a priori
number of equally likely possible solutions to our problem that can be represented
with n symbols. We will use information to reduce the size of N, assuming all
information is relevant. Therefore, the more information we use, the more options
can be discarded, thereby reducing the size of N. We define the quantity of
information Ψ using Claude Shannon’s formula:

Ψ ¼ k loge ðN Þ

where k is a constant whose value is determined by the unit of information used.


This is an assumption almost as strong as the definition without justification of the
bit, but we merely want to obtain results by means of a different way of thinking.
Let us analyze what has been just stated. In the definition of the quantity of
information Ψ , using the logarithm can be justified by considering two independent

INFORMATION

SPACE OF SPACE OF
SPACE OF POSSIBLE SOLUTIONS POSSIBLE POSSIBLE SOLUTION
SOLUTIONS SOLUTIONS

Fig. 1.1 Increasingly smaller spaces of possible solutions


6 1 The Universe of Binary Numbers

systems (or spaces of different solutions) with N1 and N2 equally probable events,
respectively. If we consider the system as a whole, the entire space of solutions will
be

N ¼ N1  N2

The situation is similar to what happens when we have two different and
independent sets of elements:

Ω1 ¼ fa; b; c; dg; Ω2 ¼ fx; y; z; t; vg

Although not strictly necessary, we will assume that each element in Ω1 and Ω2
has a given probability of occurring:

PðaÞ, PðbÞ, PðcÞ, Pðd Þ for the elements in Ω1


PðxÞ, PðyÞ, PðzÞ, PðtÞ, PðvÞ for the elements in Ω2

The joint probability of (a, z), for example, will thus be

Pða; zÞ ¼ PðaÞ  PðzÞ

We go back to the justification of the logarithm, which requires us to make


{N ¼ N1  N2} compatible with the fact that information is additive (that is, the
quantity of information increases as new information appears). Thus, since

Ψ ¼ k loge ðN Þ

then

Ψ ¼ k loge ðN Þ ¼ k loge ðN 1  N 2 Þ
¼ k loge ðN 1 Þ þ k loge ðN 2 Þ ¼ Ψ1 þ Ψ2

And that’s it. Thanks to the logarithm we were able to build something coherent
and nicely structured. We will go a step further in our thinking. Above we said “Let
N be the a priori number of equally likely possible solutions to our problem that can
be represented with n symbols.” But if we have n symbols then how many equally
likely states can be represented?
The answer is evident: N ¼ 2n. Thus, if n ¼ 3 (for example, A, B, C such that A,
B, C 2 {0, 1}), then the N equally likely states are those reflected in Table 1.1.
Thus, if we take N ¼ 2n to be equivalent to the quantity of information in a given
system, then

Ψ ¼ kloge ðN Þ ¼ kloge ð2n Þ ¼ k  n  loge ð2Þ ¼ n½k loge ð2Þ


1.1 Looking for the Bit 7

Table 1.1 Eight equally A B C


likely states that can be
1 0 0 0
represented with three
symbols 2 0 0 1
3 0 1 0
4 0 1 1
5 1 0 0
6 1 0 1
7 1 1 0
8 1 1 1

Simplifying this equation in order to yield Ψ ¼ n (remember that we have


defined k as a constant whose value is determined by the unit of information
used), then

1
kloge ð2Þ ¼ 1 ! k ¼
loge ð2Þ

Going back to Ψ ¼ k loge(N ), with some further work we obtain the following
result:

loge ðN Þ
Ψ ¼ k loge ðN Þ ¼ ¼ log2 ðN Þ ¼ n
loge ð2Þ

And here we have the formal definition of the bit! If the reader does not believe
the mathematical equality

loge ðN Þ
¼ log2 ðN Þ
loge ð2Þ

then we can try this. Assume that

loge ðN Þ
A¼ ! loge ðN Þ ¼ A  loge ð2Þ
loge ð2Þ

Then

N ¼ 2A ! log2 ðN Þ ¼ A  log2 ð2Þ ¼ A


8 1 The Universe of Binary Numbers

1.2 Number Bases

How can we use a single bit? What is it about bits that justifies their use? Both
questions are academic, of course, since we already know that bits perform their job
in computers, and computers do quite a lot of things. However, it is clear by now
that a bit is nothing more than a binary digit that is expressed in the base 2 number
system. We can also do the same things with bits that can be done with any other
number written in any other number base. The reason for using bits is fundamen-
tally practical; among many other things, they enable fast computation. In any case,
it is easy to change from one to another number base. In our examples and
discussion, we will focus mainly, although not exclusively, on whole numbers
(integers).
Base 10 to Base 2

To convert a base 10 integer to a base 2 integer, we first divide the base 10 number
by two. The remainder of this quotient is referred to as the least significant bit. We
divide the resulting integer by two successively until the quotient becomes zero.
This is illustrated below with the example of the base 10 integer 131, which we
want to represent in base 2:

131  2 ¼ 65 and remainder ¼ 1


65  2 ¼ 32 and remainder ¼ 1
32  2 ¼ 16 and remainder ¼ 0
16  2 ¼ 8 and remainder ¼ 0
8  2 ¼ 4 and remainder ¼ 0
4  2 ¼ 2 and remainder ¼ 0
2  2 ¼ 1 and remainder ¼ 0
1  2 ¼ 0 and remainder ¼ 1

Now, starting with the most significant bit and ending with the least significant
bit, we can write the remainders to obtain

ð131Þ10 ¼ ð10000011Þ2

The eight-bit representation of the number 131 in base 2 is thus

1 0 0 0 0 0 1 1

Another conversion procedure is to use the numbers 1 and 0 with successive


powers of two (that is, 20, 21, 22 etc.) so that the resulting sum is the number we
want to convert. For example, to represent the base 10 number 151 in base 2, we
first have to look for the nearest power of two below 151, in this case, 7 (since
1.2 Number Bases 9

128 ¼ 27). However, we still need 23 to obtain 151 (because 151  128 ¼ 23). This
value will be achieved by distributing more numbers 1 and 0 among the powers of
two, in such a way that the sum yields the result we are seeking. In the example, the
correct powers of two are 4, 2, 1 and 0, and the resulting numbers are 16, 4, 2 and
1, respectively. In other words

ð151Þ10 ¼ 1  27 þ 0  26 þ 0  25 þ 1  24 þ 0  23
þ1  22 þ 1  21 þ 1  20 ¼ ð10010111Þ2

The procedure for transforming a base 10 non-integer between 0 and 1 into


binary is as follows:
1. Multiply the number by two; if the integer part is greater than 0, the
corresponding bit will be 1 and otherwise it will be 0.
2. Discard the integer part and recursively perform 1. with the non-integer part just
obtained. When there are only 0s to the right of the decimal point, stop.
3. Finally, arrange the resulting numbers in the same order in which they were
obtained (note that we have to take into account the minor issue that some
numbers can be transformed into periodic digits).
By way of an example, the conversion (0.3125)10 ¼ (0.0101)2 will look like this:

0:3125  2 ¼ 0:625 ! 0
0:6250  2 ¼ 1:250 ! 1
0:2500  2 ¼ 0:500 ! 0
0:5000  2 ¼ 1:000 ! 1

Base 2 to Base 10

If we want to do the reverse and convert an integer from base 2 to base 10, we do the
following:
Beginning on the right side of the binary number, multiply each bit by 2 and then
raise the result to the consecutive power, according to the relative position of the
corresponding bit and beginning with the power of 0. After completing the multi-
plications, add all the partial results to obtain the number in base 10.
By way of an example,

ð110101Þ2 ¼ ð1  2Þ0 þ ð0  2Þ1 þ ð1  2Þ2 þ ð0  2Þ3 þ ð1  2Þ4 þ ð1  2Þ5


¼ 1 þ 0 þ 4 þ 0 þ 16 þ 32 ¼ 53

Therefore

ð110101Þ2 ¼ ð53Þ10
10 1 The Universe of Binary Numbers

Table 1.2 Number Base 10 Base 2 Base 8 Base 16


equivalences in base 10, base
0 0 0 0
2, base 8 and base 16
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10

The procedure is the same for a non-integer, except that we need to take into
account that, because 0 is to the left of the decimal, the digits to the right are raised
to negative powers. For example,

ð110:101Þ2 ¼ ð1  2Þ2 þ ð1  2Þ1 þ ð0  2Þ0 þ ð1  2Þ1 þ ð0  2Þ2


þ ð1  2Þ3 ¼ ð6:625Þ10

Note that we can work with many different number bases, although computer
science, for practical and historical reasons, works with base 2, base 8 or base 16.
To conclude this section, Table 1.2 shows conversions between the main number
bases.

1.3 Single Bits Represented with Stickers

We are now going to look at bits from a totally different perspective. Imagine we
have the circuits illustrated in Figs. 1.2 and 1.3 and Table 1.3.
According to the circuit analogy, bits can be represented as follows:
 
1
Bit 0 
0
1.3 Single Bits Represented with Stickers 11

Fig. 1.2 An OFF circuit


with a sticker

Fig. 1.3 An ON circuit


with a sticker

Table 1.3 Tabular OFF circuit ON circuit


representation of Figs. 1.2 A¼0 A¼1
and 1.3
OFF circuit TRUE FALSE
B¼0 1 0
ON circuit FALSE TRUE
B¼1 0 1

 
0
Bit 1 
1

Let us try to explain what we did. Up to now, we have considered the concept of
bit from a very static point of view:
1. A bit is 1 if something is true.
2. A bit is 0 if something is false.
But bits need to be implemented in some physical device, for example, in
circuits as depicted above. If the circuit is ON the sticker is happy. Conversely, if
the circuit is OFF then the sticker is sad. However, the ON or OFF state applies to
the whole circuit; in other words, it is not possible for half the circuit to be in the ON
12 1 The Universe of Binary Numbers

state and the other half to be in the OFF state. Let us put two marks, A and B, in the
circuit in such a way that A is before the sticker and B is after the sticker. A and
B must always be in the same state, independently of the state of the whole circuit.
In other words
If A ¼ 0 and B ¼ 0 ! Bit is 0 ! Circuit OFF
If A ¼ 1 and B ¼ 1 ! Bit is 1 ! Circuit ON
If A ¼ 0 and B ¼ 1 ! Illogical
If A ¼ 1 and B ¼ 0 ! Illogical
Now, looking at Table 1.3 and remembering that A is located before the sticker,
and B is located after the sticker, the following cases are represented:
Case 1: Circuit is ON  There is a Bit 1
A ¼ 1 and B ¼ 0 is false
A ¼ 1 and B ¼ 1 is true
Case 2: Circuit is OFF  There is a Bit 0
A ¼ 0 and B ¼ 0 is true
A ¼ 0 and B ¼ 1 is false
The above cases can clearly be represented as a matrix. From Table 1.3 we can
verify that this is true, because if a bit is represented by a column matrix then
 
1
Bit is 0  j0i when, given A ¼ 0, then B ¼ 0 )
0
 
0
Bit is 1  j1i when, given A ¼ 1, then B ¼ 1 )
1

This notation—somewhat similar to Paul Dirac’s proposed bra-ket notation for


the quantum arena—is particularly useful for representing systems with two possi-
ble states. We need to remember that single bits, whether single classical bits or
single quantum bits, are units of information that need to be stored in physical
systems, for example, in a circuit (in the case of a classical system) or in the spin of
an electron (in the case of a quantum system). Thus

Classical system ) jstate of a circuiti ¼ jOFFi ¼ j0i


Classical system ) jstate of a circuiti ¼ jONi ¼ j1i
Quantum system ) jspin of an electroni ¼ j"i ¼ j0i
Quantum system ) jspin of an electroni ¼ j#i ¼ j1i

This represents an interesting way to introduce bra-ket notation from a classical


perspective.
1.4 Binary Logic 13

1.4 Binary Logic

Up to now we have learned something about bits and about how number bases can
be changed in order to be able to work with bits. Now we take things further and
discuss binary logic, without which current computers could not work. Binary logic
was developed at the beginning of the nineteenth century by the mathematician
George Boole in order to investigate the fundamental laws of human reasoning.
In binary logic, variables can only have two values, traditionally designated as
true and false, and usually represented as 1 and 0, respectively. At a given moment,
the same variable can only be in one of these states. This is why binary logic
handles logic states, not real quantities. In other words, 0 and 1, even though they
are numbers, do not represent numerical quantities. They are, rather, symbols of
two different states that cannot coexist at the same time (at least in a classical
system; matters are different in quantum systems).
In binary logic systems, variables are represented in base 2. The reason is almost
trivial, since the establishment of a direct relationship between the numerical values
and their corresponding logic states is immediate. Nevertheless, base 2 (or any
another number base) and binary logic are totally different concepts. This is one of
the reasons why, for the moment, we will use the following notation:

jstate of somethingi ¼ jfalsei ! j0i


jstate of somethingi ¼ jtruei ! j1i

An important feature of logic values is that they allow logic operations. A logic
operation assigns a true or false value to a combination of conditions for one or
more factors. The factors in a classical logic operation can only be true or false, and
consequently the result of a logic operation can also only be true or false. Table 1.4
depicts some of these logic operations.
Let us now experiment with these logic operations. Let R be the result of some
logic operation and let x, y, z. . . be the variables involved in the logic operation.

Table 1.4 Some logic operations


Operation Operator Symbol Comments
Tautology T T Always true
Exclusion NAND " Incompatibility
Simple implication IMP ! Condition
Negation NOT Ø Changes the logic state
Double implication XNOR $ Equivalence
Disjunction OR _ One has to be true
L
Exclusive disjunction XOR Exactly one has to be true
Conjunction AND ^ All have to be true
Conjoint negation NOR # All have to be false
Contradiction F F Always false
14 1 The Universe of Binary Numbers

Table 1.5 Truth table for |x〉 |R〉 ¼ |x〉


binary equality
|1〉 |1〉
|0〉 |0〉

Table 1.6 Truth table for |x〉 |R〉 ¼ Ø |x〉


binary negation
|1〉 |0〉
|0〉 |1〉

Binary Equality

The result for R after applying binary equality to a variable x is very simple:
If x is true, then R is true.
If x is false, then R is false.
If we use the particular notation introduced at the beginning of this chapter,
Table 1.5 is the truth table that illustrates binary equality.
To visualize how binary equality works, suppose that we have a car with an
automatic light detector: when it is dark the car lights turn on, and when it is not
dark the car lights turn off. The logic representation of this example is thus

jDarknessi ¼ j1i ) jLightsi ¼ j1i


jDarknessi ¼ j0i ) jLightsi ¼ j0i

Binary Negation

Binary negation is obtained by applying the NOT operator (symbol Ø) to the


variable x that we want to negate. The net result is a change in the logic state of
the variable, as shown in Table 1.6.
If x is true, then R is false.
If x is false, then R is true.

The car example can also be used to illustrate binary negation; we only need to
change ‘darkness’ to ‘brightness’. Thus

jBrightnessi ¼ j1i ) jLightsi ¼ j0i


jBrightnessi ¼ j0i ) jLightsi ¼ j1i

Binary Disjunction

Binary disjunction is obtained by applying the OR operator (symbol _) to the x and


y variables that we want to evaluate to obtain the result R.

If x is true, or y is true, or both x and y are true, then R is true, otherwise R is false.
1.4 Binary Logic 15

Table 1.7 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 _ |y〉
binary disjunction
|0〉 |0〉 |0〉
|0〉 |1〉 |1〉
|1〉 |0〉 |1〉
|1〉 |1〉 |1〉

Table 1.8 Truth table for |x〉 |y〉 |R〉 ¼ |x〉  |y〉
binary exclusive disjunction
|0〉 |0〉 |0〉
|0〉 |1〉 |1〉
|1〉 |0〉 |1〉
|1〉 |1〉 |0〉

A logic operation involving two variables has four possible combinations.


Results for binary disjunction are shown in Table 1.7.
To illustrate using the car example, let us assume we are driving our car, when
we are stopped for a routine alcohol and drug test. The police officer makes us blow
through a breathalyzer, which sounds an alarm if we are under the influence of toxic
substances. In this case, the binary disjunction would work as follows:

j Drugs〉 ¼j 1〉 and j Alcohol〉 ¼j 1〉 )j Alarm〉 ¼j 1〉


j Drugs〉 ¼j 0〉 and j Alcohol〉 ¼j 1〉 )j Alarm〉 ¼j 1〉
j Drugs〉 ¼j 1〉 and j Alcohol〉 ¼j 0〉 )j Alarm〉 ¼j 1〉
j Drugs〉 ¼j 0〉 and j Alcohol〉 ¼j 0〉 )j Alarm〉 ¼j 0〉

Binary Exclusive Disjunction

Binary exclusive disjunction is obtained by applying the XOR operator (symbol )


to the variables x and y that we want to evaluate in order to obtain the result R.

If x is true, or y is true, as long as x and y are not true simultaneously, then R is


true, otherwise R is false.

Since the logic operation involves two variables there are four possible combi-
nations. Table 1.8 depicts the truth table for binary exclusive disjunction.
To illustrate again using the car example, we are on a long trip and decide to
listen to some music to make our trip less boring. The car has both a radio and a CD
player and we can choose between the radio or an Eric Clapton CD. We cannot
connect both simultaneously since we would only hear what would sound like a
swarm of crickets. Thus

j Radio〉 ¼j 1〉 and j Eric Clapton CD〉 ¼j 1〉 )j Music〉 ¼j 0〉


j Radio〉 ¼j 0〉 and j Eric Clapton CD〉 ¼j 1〉 )j Music〉 ¼j 1〉
j Radio〉 ¼j 1〉 and j Eric Clapton CD〉 ¼j 0〉 )j Music〉 ¼j 1〉
j Radio〉 ¼j 0〉 and j Eric Clapton CD〉 ¼j 0〉 )j Music〉 ¼j 0〉
16 1 The Universe of Binary Numbers

Table 1.9 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 # |y〉
binary conjoint negation
|0〉 |0〉 |1〉
|0〉 |1〉 |0〉
|1〉 |0〉 |0〉
|1〉 |1〉 |0〉

Table 1.10 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 ^ |y〉
binary conjunction
|0〉 |0〉 |0〉
|0〉 |1〉 |0〉
|1〉 |0〉 |0〉
|1〉 |1〉 |1〉

Binary Conjoint Negation

Binary conjoint negation is the negation of binary disjunction, an operation


performed using the NOR operator (symbol #). The result R of binary conjoint
negation of two variables x and y is the following:

If x is false and y is false, then R is true, otherwise R is false.

The results for binary conjoint negation are shown in Table 1.9.
Again we use our car to illustrate. We are driving through the desert of Arizona.
It is three o’clock in the afternoon and a merciless sun is shining in a cloudless sky.
The temperature outside the car is 110  F (43  C). Disastrously, both a conventional
electric fan we have installed in our car and the air conditioning stop working. Thus

j Fan〉 ¼j 1〉 and j Air conditioning〉 ¼j 1〉 )j Heat〉 ¼j 0〉


j Fan〉 ¼j 0〉 and j Air conditioning〉 ¼j 1〉 )j Heat〉 ¼j 0〉
j Fan〉 ¼j 1〉 and j Air conditioning〉 ¼j 0〉 )j Heat〉 ¼j 0〉
j Fan〉 ¼j 0〉 and j Air conditioning〉 ¼j 0〉 )j Heat〉 ¼j 1〉

Binary Conjunction

Binary conjunction is performed using the AND operator (symbol ^). The result
R of binary conjunction applied to two variables x and y is the following:

If x is true and y is true, then R is true, otherwise R is false.

Again we have two variables with four possible combinations. Table 1.10 shows
the truth table for binary conjunction.
Let us go back to the previously mentioned example of a toxic-substance test
while driving. After the breathalyzer test, the police officer can record the results as
follows:
1.4 Binary Logic 17

Table 1.11 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 " |y〉
binary exclusion
|0〉 |0〉 |1〉
|0〉 |1〉 |1〉
|1〉 |0〉 |1〉
|1〉 |1〉 |0〉

j No drugs〉 ¼j 1〉 and j No alcohol〉 ¼j 1〉 )j Negative test〉 ¼j 1〉


j No drugs〉 ¼j 0〉 and j No alcohol〉 ¼j 1〉 )j Negative test〉 ¼j 0〉
j No drugs〉 ¼j 1〉 and j No alcohol〉 ¼j 0〉 )j Negative test〉 ¼j 0〉
j No drugs〉 ¼j 0〉 and j No alcohol〉 ¼j 0〉 )j Negative test〉 ¼j 0〉

Binary Exclusion

Binary exclusion, the negation of binary conjunction, is performed using the NAND
operator (symbol "). The result R of binary exclusion applied to two variables x and
y is as follows:

If x is false, or if y is false, or if both x and y are false, then R is true, otherwise


R is false.

The two variables again mean four possible combinations. Table 1.11 depicts the
results for binary exclusion.
We have been driving for a long time and are tired so we decide that now is a
good moment to stop at a gas station to eventually refuel or to add water to the
radiator.

j Petrol〉 ¼j 0〉 and j Radiator〉 ¼j 0〉 )j Fill〉 ¼j 1〉


j Petrol〉 ¼j 0〉 and j Radiator〉 ¼j 1〉 )j Fill〉 ¼j 1〉
j Petrol〉 ¼j 1〉 and j Radiator〉 ¼j 0〉 )j Fill〉 ¼j 1〉
j Petrol〉 ¼j 1〉 and j Radiator〉 ¼j 1〉 )j Fill〉 ¼j 0〉

Simple Binary Implication

Simple binary implication, performed by the operator IMP (symbol !), is a rather
different logic operation from those described above, as it relies greatly on its own
definition, as follows:

IMP : x ! y  NOT ðxÞ OR ðyÞ

Therefore, the result R of the implication (x ! y) is true if x is false, and


otherwise equal to the state of y.
To understand simple binary implication we need to consider the logical expres-
sion as a whole: what is true or false is the logical expression itself. The implication
relies on the eventuality of a possible causal relation, as depicted in Table 1.12.
18 1 The Universe of Binary Numbers

Table 1.12 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 ! |y〉
simple binary implication
|0〉 |0〉 |1〉
|0〉 |1〉 |1〉
|1〉 |0〉 |0〉
|1〉 |1〉 |1〉

Table 1.13 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 $ |y〉
double binary implication
|0〉 |0〉 |1〉
|0〉 |1〉 |0〉
|1〉 |0〉 |0〉
|1〉 |1〉 |1〉

Table 1.14 Spelling error detection by means of double binary implication


Four-letter word Binary code associated with each letter written as a word of eight bits
With error 01101100 | 01101111 | 01110110 | 01101111
Without error 01101100 | 01101111 | 01100010 | 01101111
$ 11111111 | 11111111 | 11101011 | 11111111

Assume we park the car for a time and look up at the sky, analyzing the causal
relation between rain and the presence of clouds, bearing in mind that whenever it
rains there are clouds, but that it does not always rain when there are clouds.

j Rain〉 ¼j 0〉 and j Clouds〉 ¼j 0〉 )j Rain ! Clouds〉 ¼j 1〉


j Rain〉 ¼j 0〉 and j Clouds〉 ¼j 1〉 )j Rain ! Clouds〉 ¼j 1〉
j Rain〉 ¼j 1〉 and j Clouds〉 ¼j 0〉 )j Rain ! Clouds〉 ¼j 0〉
j Rain〉 ¼j 1〉 and j Clouds〉 ¼j 1〉 )j Rain ! Clouds〉 ¼j 1〉

Double Binary Implication

Double binary implication, performed using the XNOR operator (symbol $),
indicates equivalence. Again we need to consider the logical expression as a
whole, so that what is true or false is the logical expression itself. The result R of
double binary implication applied to two variables x and y is as follows:

If |x〉 ¼ |y〉, then R is true, otherwise R is false.

The truth table of the XNOR operation is shown in Table 1.13.


An important application of double binary implication is to the automatic
correction of texts, for example, spellcheckers in word processing programs. The
spellchecker uses double binary implication to compare a word as written with its
correct spelling in a dictionary. If a letter does not match, the system detects and
indicates the error. This is because the double binary implication result does not
return 1 in all the bits. Table 1.14 illustrates an example of error detection for a four-
letter word where the mistake is in the third letter.
1.5 Logic Gates 19

Table 1.15 All binary logic operations that can be defined for two binary variables, x and y
x y 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0
0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0

Fig. 1.4 Some logic gates with their associated symbols and functions

It is evident that we can obtain 24 (¼ 16) possible outcomes for logic operations
on two binary variables x and y, as represented in Table 1.15.
Left as a task for the reader is to associate the bold numbers in Table 1.15 with
the logic operations they represent.

1.5 Logic Gates

We need one or more physical devices, which we call logic gates, in order to
implement logic operations in a computer. Logic gates are elementary units used in
the design of current computers to enable these to compute. These logic gates have
one or more input lines and one output line. The basic logic gates are NOT (also
called INV), AND, NAND, OR, NOR, XOR and XNOR. These gates have associ-
ated symbols, as illustrated in Fig. 1.4.
We can do many things with these logic gates, as we will see shortly. However,
our main interest is in special sets of universal gates that allow us to implement
absolutely any logic function. For example, the set formed by the gates {AND, OR,
NOT} is universal, as are the sets {AND, NOT}, {OR, NOT}, {NAND} and
{NOR}. A group of logic gates is also universal when it can implement all the
gates belonging to another universal set. We will return to these universal logic gate
sets below.
20 1 The Universe of Binary Numbers

1.6 Some Practice

With the resources presented above we can perform some simple but interesting
computations. The only requirement is to put our neurons to work and use our skills
to connect up logic gates so as to build the architecture necessary to resolve a given
problem. Since we are dealing with binary systems, we will use digits that can be
either 0 or 1.
The Half Adder

Suppose we want to add two binary numbers:

A ¼ 001101
B ¼ 010110

The result R is obviously

R ¼ 100011

We can visualize this by considering conveyor belts (A, B and R) that transport
boxes. A box may contain a ball (the bit of this box is 1) or may be empty (the bit of
this box is 0). Figure 1.5 illustrates this example.
The following restrictions apply:
1. A and B must have the same number of boxes.
2. The number of boxes in A and B must be at least as large as the number of bits
reflecting the largest number we want to sum.
3. The result of the sum will be represented by the contents of R.
4. R must have at least one box more than A and B (why?).
5. Each box in A, B or R must either contain a single ball or be empty.
6. Addition must be performed from right to left by emptying the contents of
A and B into the corresponding box in R, which must initially be empty.
7. No box may have more than one ball.

Fig. 1.5 Conveyor belts A, B and R with boxes and balls


1.6 Some Practice 21

1 1
0 0 1 0 0 0 1 0
0 1 1 0 0 1 1 0 0 0 1 0 0 0 1 0
0 1 1 0 0 1 1 0
0 0 0
0 0 0 1 0 0 0

Fig. 1.6 Another example of how a Half Adder works

Table 1.16 Basic rules for |Bit_1〉 |Bit_2〉 |S〉 |K〉


the binary sum of two
|0〉 |0〉 |0〉 |0〉
single bits
|0〉 |1〉 |1〉 |0〉
|1〉 |0〉 |1〉 |0〉
|1〉 |1〉 |0〉 |1〉

Fig. 1.7 Schematic


representation of the Half
Adder

8. In the case of one ball entering an already occupied box, the second ball is
placed in the nearest empty box to the left and the ball already present in R is
discarded.
9. In the case of two balls entering an empty box, one ball is placed in the nearest
empty box to the left and the other is discarded.
10. In the case of two balls entering an already occupied box, one of the three is
placed in the nearest empty box to the left, one is discarded, and one remains in
this box.
11. The process continues until there are no more balls to add.
Another example, shown in Fig. 1.6, clarifies this sum-and-carry movement to
the left.
We should now be able to establish the basic rules for the binary sum of two bits,
Bit_1 and Bit_2. In Table 1.16 illustrating the process, |S〉 means sum and |K〉
means carry.
Above we built a device capable of summing two sequences of bits. Figure 1.7
depicts the basic architecture of what is called, for obvious reasons, a Half Adder
(think why!). The generalization of the Half Adder, called the Full Adder, will be
analyzed in depth later.
22 1 The Universe of Binary Numbers

Table 1.17 Truth table for |x〉 |y〉 |R〉 ¼ |x〉 ^ |y〉
binary conjunction
|0〉 |0〉 |0〉
|0〉 |1〉 |0〉
|1〉 |0〉 |0〉
|1〉 |1〉 |1〉

Table 1.18 Truth table for |x〉 |y〉 |R〉 ¼ |x〉  |y〉
exclusive disjunction
|0〉 |0〉 |0〉
|0〉 |1〉 |1〉
|1〉 |0〉 |1〉
|1〉 |1〉 |0〉

We now return to the logic operation called binary conjunction, whose truth
table is reproduced again in Table 1.17.
It can be observed that binary conjunction and the carry operation in the Half
Adder are one and the same. The Half Adder carry can be directly obtained using
the inputs of the Half Adder as the inputs of the logic gate AND. We can also obtain
the bit for the sum using exclusive disjunction, whose truth table is reproduced in
Table 1.18.

1.7 A Peculiar Way to Compute

One of the stated goals of this book was to stimulate reasoning by analogy. In all
areas of human learning there are smart, creative people capable of converting the
learning of abstract notions—usually tedious—into something fun and fascinating.
One such individual was Arthur Compton, a US physicist, who, by playing billiards
with electrons, discovered the laws that govern the decrease in energy (increase in
wavelength) in electromagnetic radiation resulting from electron scattering. For this
discovery, of what came to be called Compton scattering, he was awarded the
Nobel Prize in Physics in 1927.
Edward Fredkin and Tommaso Toffoli did something similar when they used
billiard balls (bits) on a billiard table (computer) to simulate bit movement through
logic gates. They imposed the following restrictions:
The launching of balls represents the input to the system.
The distribution of balls represents the output of the system.
The balls move diagonally through a flat mesh.
The balls obey classical mechanical laws.
There is no friction.
Collisions are perfectly elastic.
Let us now consider the schematic representation in Fig. 1.8.
1.7 A Peculiar Way to Compute 23

Fig. 1.8 Computing with


billiard balls as bits

We assume that Ball_1 and Ball_2 (which look exactly the same) can be absent
or present. If we use our particular notation for possible states, then

j Ball 1〉 ¼j 0〉 ! There is no Ball 1


j Ball 1〉 ¼j 1〉 ! Ball 1 is ready to be launched
j Ball 2〉 ¼j 0〉 ! There is no Ball 2
j Ball 2〉 ¼j 1〉 ! Ball 2 is ready to be launched

We have exactly the same situation for both Output_1 and Output_2. Thus

j Output 1〉 ¼j 0〉 ! No ball exits the system via Output 1


j Output 1〉 ¼j 1〉 ! One ball exits the system via Output 1
j Output 2〉 ¼j 0〉 ! No ball exits the system via Output 2
j Output 2〉 ¼j 1〉 ! One ball exits the system via Output 2

But how are the inputs and outputs related? Bearing in mind that we cannot
distinguish between Ball_1 and Ball_2, we can verify the following relations:

jOutput 1〉 ¼j0〉
jBall 1〉 ¼j0〉 and jBall 2〉 ¼j0〉 Case 1
jBall 1〉 ¼j1〉 and jBall 2〉 ¼j0〉 Case 2
jOutput 2〉 ¼j0〉
jBall 1〉 ¼j0〉 and jBall 2〉 ¼j0〉 Case 3
jBall 1〉 ¼j0〉 and jBall 2〉 ¼j1〉 Case 4
jOutput 1〉 ¼j1〉
jBall 1〉 ¼j1〉 and jBall 2〉 ¼j1〉 Case 5
jBall 1〉 ¼j0〉 and jBall 2〉 ¼j1〉 Case 6
jOutput 2〉 ¼j1〉
jBall 1〉 ¼j1〉 and jBall 2〉 ¼j1〉 Case 7
jBall 1〉 ¼j1〉 and jBall 2〉 ¼j0〉 Case 8
24 1 The Universe of Binary Numbers

CASE 1 CASE 2 CASE 3 CASE 4

B1 O1 B1 O1 B1 O1 B1 O1

B2 O2 B2 O2 B2 O2 B2 O2

B1 O1 B1 O1 B1 O1 B1 O1

B2 O2 B2 O2 B2 O2 B2 O2

CASE 5 CASE 6 CASE 7 CASE 8

Fig. 1.9 All eight possible situations in our peculiar billiard game

Simplifying somewhat and renaming (B1 is Ball_1, B2 is Ball_2, O1 is Output_1


and O2 is Output_2), we can visualize the entire set of eight possible situations as
depicted in Fig. 1.9.
Let us now represent the eight situations in logical terms. It is easy to verify that

Ø O1 ¼ ðØB1 ^ ØB2 Þ  ðB1 ^ ØB2 Þ


Ø O2 ¼ ðØB1 ^ ØB2 Þ  ðØB1 ^ B2 Þ
O1 ¼ ðØB1 ^ B2 Þ  ð B1 ^ B2 Þ
O2 ¼ ðB1 ^ ØB2 Þ  ð B1 ^ B2 Þ

Recall that, some lines ago, we referred to the fact that the set of logic gates
formed of {AND, OR, NOT} is universal and also that the logic gate sets formed of
{AND, NOT}, {OR, NOT}, {NAND} and {NOR} are complete. Could we then not
claim that our system of billiard balls is, in reality, a universal set of binary
operators? We will return to this question and to billiard ball computing later,
after we have explored what is referred to as reversible computation.

1.8 Chapter Summary

Our main goal in this chapter is to stimulate reasoning by analogy and to show that
the same concept can be viewed from several different perspectives. The material
presented here is illustrated with a good number of examples. Some of the sections
are very speculative, and may appear chaotic. Conversely, the rest of the sections
follow a very strict organization. The choice depended on the type of material
presented and discussed in each section. We start with an almost surprising ques-
tion: what is a bit? Rather that define it, we introduce it by using Shannon’s amount
1.9 Glossary of Terms and Notation Used in This Chapter 25

of information theorem and then progress to a discussion of several different


number bases. The circuit is used to represent the bit from a dynamic point of
view (to be referred to later in the book in terms of bra-ket notation). We then focus
on the basic concepts of binary logic, progressing to basic logic operations that can
be performed through logic gates and focusing on special universal sets of gates
with which we can do very many things. The chapter concludes with two applica-
tions: the Half Adder as a physical summing device, and a billiard game represen-
tation of a number of basic operations with bits.

1.9 Glossary of Terms and Notation Used in This Chapter

Terms
• Axiom: a proposition that is assumed without proof for the sake of studying its
consequences.
• Backward reasoning: proving a goal by recursively breaking it down into
sub-goals and trying to prove these until facts are derived. Facts are goals with
no sub-goals and are therefore always true.
• Binary logic: classical propositional two-valued logic, often called Boolean
logic in engineering.
• Data-driven reasoning: the construction of goals or the drawing of inferences
from a set of facts.
• Joint probability: given at least two random variables x, y,... defined in a
probability space, the joint probability distribution for x, y,... gives the proba-
bility that each of x, y,... falls within a particular range or discrete set of values
specified for that variable.
• Logarithm: the exponent of the power to which a base number must be raised to
equal a given number.
• Remainder: the portion of the dividend that is not evenly divisible by the divisor.
• Rule base: a set of rules that apply to a given inferential process. Each rule has an
IF-part (the condition), a THEN-part (the conclusion) and, optionally, an ELSE-
part.
• Symbol: a letter, figure, or other character or mark or combination thereof used
to designate something.

Notation

P(A) Probability of event A


Θ Rule base
Δ Set of data
Ω Set of elements
|〉 ¼ |0〉 State () is false
|〉 ¼ |1〉 State () is true
Chapter 2
Back and Forth Computing

A black cat crossing your path signifies that the animal is


going somewhere.
Groucho Marx

The conjunction, disjunction and binary exclusive disjunction logic operators


accept binary variables as inputs and then calculate a binary function. As we have
already seen, {AND, OR, NOT} is a universal set whose elements can, in theory, be
used to build any logical function. We have also seen that a few operators by
themselves form a universal set, for example, {NAND} and {NOR}. However, to
continue on our journey through the intricacies of computer science, we need to
understand a key concept called reversibility.

2.1 Introducing Reversibility

To be able to talk about reversible computing, we need to define two new logic
operations called fanout and exchange.
Fanout (FO) is an operation that divides a single input into two or more outputs
with the same value as the input value, as illustrated in Fig. 2.1.
Exchange (EX) is an operation in which the pair of input connections in a
two-line system is exchanged, as illustrated in Fig. 2.2.
These two simple operations are ideal for a discussion of reversibility concepts
and reversible computation and, in the remainder of this chapter, we will broadly
draw on Feynman Lectures on Computation. Accordingly, we will assume that we
have a sufficient number of |0〉and |1〉bits to design our reversible system.
First of all, the logic operations AND, NAND, OR and XOR are not reversible;
in other words, we cannot reconstruct the inputs from the outputs. In fact, it is
evident that, with irreversible operations, we lose information that cannot be
retrieved. But is there some way to avoid this information loss? Let us try to define
a reversible operation as a logic operation that has sufficient information in the
outputs to allow the inputs to be reconstructed.

© Springer International Publishing AG 2017 27


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_2
28 2 Back and Forth Computing

Fig. 2.1 The fanout


operation, FO A

Fig. 2.2 The exchange


operation, EX A B

B A

Reversibility is a basic property that has to be considered if we want to under-


stand certain very important questions related to the thermodynamics of computa-
tion. This is because reversibility allows us to calculate free energy
(a thermodynamic property) and so determine the physical efficiency of computa-
tions. This all makes for a nice analogy between reversible computing and revers-
ible thermodynamics. Charles H. Bennett and Edward Fredkin were the first
scientists who independently studied the possibility of building reversible com-
puters, which need to be equipped with reversible logic gates.
The first reversible logic operation we analyze is binary negation (logic operator
NOT). To simplify the notation, we will denote the NOT operation by the letter
N and represent it using the symbols ♦, or ▄, which will remind us of the
reversibility of this operation. It is obvious that binary negation is reversible:

j1i ¼ NOT j0i ¼ N j0i


j0i ¼ NOT j1i ¼ N j1i

Similar to the N gate, but not identical, is a gate usually called controlled binary
negation or, more simply, controlled-NOT (CN), a device that operates on two
inputs to generate two outputs. Figure 2.3 illustrates a standard representation of the
CN gate.
In the CN reversible logic gate, the symbol ♦ is a NOT operation that is
controlled by the input of the control line •. The way CN operates is as follows:

j A0 i ¼ j Ai, always
Ifj Ai ¼ j 0i, thenj B0 i ¼ j Bi
Ifj Ai ¼ j 1i, thenj B0 i ¼ NOTj Bi
2.2 The Toffoli Gate 29

Fig. 2.3 The controlled-


NOT gate, CN

Table 2.1 Truth table for the |A〉 |B〉 |A0 〉 |B0 〉
CN gate
|0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |1〉
|1〉 |1〉 |1〉 |0〉

We have to interpret the above rules as follows: if the input to the control line
A (•) is |1〉
, then the output of the controlled line B (♦) is the negation of the input
value of B. Conversely, if the input to the control line A (•) is |0〉, then the output of
the controlled line B (♦) has the same value as its input value. The value of the input
in the control line (•) activates a NOT in the controlled line (♦), but the output of the
control line (•) is always the same as the input value. Table 2.1 is the truth table of
the CN gate.
0
Lcan interpret B as the output of a binary exclusive disjunction, or
Clearly we
XOR, gate ( ), with inputs A and B:
M
B0 ¼ A B

However, note that the two operations are not the same, since the CN gate
generates two outputs, whereas the XOR gate generates only one output. And what
about the reversibility of CN? We can easily verify that CN is perfectly reversible
since, once its outputs are known, we can always reproduce the inputs. We can
check the reversibility of CN just by applying this gate twice, as illustrated in
Fig. 2.4 and in Table 2.2.
We can do many things with CN gates, but this gate is not universal. We want to
do “everything” with our computers, but in a reversible manner, so, as well as the
NOT and CN gates, we need a universal set of operators.

2.2 The Toffoli Gate

The controlled-controlled-NOT (CCN) gate, also called the Toffoli gate, is a


reversible device with three lines: two control lines and a conventional NOT line.
The CCN gate performs reversible operations and, like the conventional NAND and
NOR gates, is in itself a universal set of (reversible) binary operators. The usual
representation of the CCN reversible gate is as shown in Fig. 2.5.
The CCN gate works as follows:

There are two control lines, A and B, such that


30 2 Back and Forth Computing

Fig. 2.4 CN reversibility in graphic form

Table 2.2 CN reversibility in tabular form


|A〉 |B〉 |A0 〉 |B0 〉 |A00 〉 |B00 〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |1〉 |1〉 |0〉
|1〉 |1〉 |1〉 |0〉 |1〉 |1〉

Fig. 2.5 The CCN reversible gate

j A0 i ¼ j Ai always
j B0 i ¼ j Bi always
j Ai ¼ j 1i and j Bi ¼ j 1i ! j C0 i ¼ NOT j Ci
j Ai ¼ j 0i or j Bi ¼ j 0i or ðjAi ¼ j0i and jBi ¼ j0iÞ ! j C0 i ¼ j Ci

Thus:

If we set |A〉¼ |B〉¼ |1〉 , then the corresponding CCN output is the negation of
the input state of line C.
If at least one of the control lines, A or B, is in state |0〉
, then the CCN gate does
not change the value on line C. Table 2.3 shows the truth table for the CCN gate.
We can check the reversibility of the corresponding operation by applying CCN
twice, as illustrated in Fig. 2.6 and Table 2.4.
2.3 The Fredkin Gate 31

Table 2.3 Truth table for the CCN gate


|A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉

Fig. 2.6 CCN reversibility in graphic form

Table 2.4 CCN reversibility in tabular form


|A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉 |A00 〉 |B00 〉 |C00 〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉 |1〉 |1〉 |0〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉

2.3 The Fredkin Gate

Another gate of interest for reversible computing is the Fredkin controlled


exchange (or swap) gate, which also has also three lines. The first line is the control
line and the other two lines perform a controlled exchange, as depicted in Fig. 2.7.
The Fredkin reversible gate operates as follows:

j A0 i ¼ j Ai always
If j Ai ¼ j 0i, then j B0 i ¼ j Bi and j C0 i ¼ j Ci
If j Ai ¼ j 1i, then j B0 i ¼ j Ci and j C0 i ¼ j Bi
32 2 Back and Forth Computing

Fig. 2.7 The Fredkin gate

Table 2.5 Truth table for the |A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉
Fredkin gate
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|1〉 |0〉 |1〉 |1〉 |1〉 |0〉
|1〉 |1〉 |0〉 |1〉 |0〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |1〉

Table 2.6 Initial Fredkin |A0〉 |B0〉 |C0〉 |D0〉 |E0〉


gate configuration to
|0〉 |0〉 |0〉 |1〉 |1〉
reproduce a
conventional NAND |0〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |0〉 |1〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉

Arriving at a deep understanding of the Fredkin gate is enjoyable and highly


recommendable. Table 2.5 shows the truth table for the Fredkin gate.
Let us demonstrate that the Fredkin gate is universal as well as reversible. We
will design a circuit capable of reproducing the NAND gate, which we already
know to be universal. For this circuit we will only use Fredkin gates. Assume we
have a circuit with five lines (A, B, C, D and E), with the initial configuration shown
in Table 2.6.
We will denote by FXY, Z the application of the Fredkin gate in such a way that
the exchange of the states of lines X and Y is controlled by the state of line Z.
Thinking through a little, we can verify that the following sequence of operations
gives us the NAND gate in line C: FB0C0, A0 ! FC1D1, E1 ! FB2C2, D2. The
intermediate results are as shown in Table 2.7 (a–c).
We will leave it to the reader to draw the actual circuit.
2.4 Building Reversible Gates from Reversible Gates 33

Table 2.7 Intermediate results for the Fredkin gate used to reproduce a conventional NAND
following the procedure: FB0C0, A0 ! FC1D1, E1 ! FB2C2, D2. The NAND gate appears in |C3〉
(a)
|A1〉 |B1〉 |C1〉 |D1〉 |E1〉
|0〉 |0〉 |0〉 |1〉 |1〉
|0〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |1〉
(b)
|A2〉 |B2〉 |C2〉 |D2〉 |E2〉
|0〉 |0〉 |1〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |1〉 |1〉
(c)
|A3〉 |B3〉 |C3〉 |D3〉 |E3〉
|0〉 |0〉 |1〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |0〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉

Table 2.8 Construction of |A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉


conventional AND from
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
reversible CCN
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉

2.4 Building Reversible Gates from Reversible Gates

As mentioned earlier, CCN is a universal reversible gate. We will now configure


CCN so that it will function like other, more conventional, logic gates. We will just
configure a few of these gates, leaving the remainder as an exercise for the curious
reader.
Construction of AND from CCN

The logic operator AND can be built from CCN by setting |C〉¼ |0〉and feeding the
gate with A and B, as illustrated in Table 2.8. Note that |C0 〉is the result of |A〉^ |B〉
.
Construction of NAND from CCN

The logic operation NAND can be built from CCN by setting |C〉¼ |1〉and feeding
the gate with A and B, as illustrated in Table 2.9.
34 2 Back and Forth Computing

Table 2.9 Construction of |A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉


conventional NAND from
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉
reversible CCN
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉

Table 2.10 Construction of |A〉 |B〉 |C〉 |A0 〉 |B0 〉 |C0 〉


conventional XOR from
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉
reversible CCN
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉

Construction of XOR from CCN

The logic operator XOR can be built from CCN, by setting |A〉¼ |1〉(or |B〉¼ |1〉 )
and feeding the gate with B and C (A and C), as illustrated in Table 2.10.
We will return later to the construction of logic gates from reversible operators.

2.5 Adding in a Reversible Way

We have already looked at the Half Adder, an architecture capable of adding single
bits. We also stated that we wanted to generalize the Half Adder and turn it into a
full adder, that is to say, a new device that can accept the carry of previous
operations. However, we will go further and design a reversible full adder; as a
consequence, we will know both the result of the operation and the corresponding
inputs.
Figure 2.8 shows the basic architecture of a single-bit full adder, where C is a bit
that represents an input carry whose value comes from previous additions (hence
the name full adder). Nevertheless, since this operation requires three inputs and
generates two outputs, it is not reversible, as it is not possible to reconstruct the
three inputs from the result S and the new carry K (the output carry).
The problem is that if we want a reversible full adder, we need more information
in the output. More precisely, we need two extra lines in the output, and one extra
line in the input configured with a fixed value, for example, |0〉 . We can proceed as
follows:
1. Use N, CN and CCN, or only CCN, which, as we already know, is a universal
reversible gate.
2. Build the AND, OR and XOR operators with which to design the full adder.
3. Include the two extra lines of output necessary for the system to work properly.
2.6 Back to Billiards 35

Fig. 2.8 A conventional


full adder of single-bit
numbers A
S
B ∑
K
C

Fig. 2.9 A reversible full


adder of single-bit numbers. A X=A
The number of output and Y=B
B

input lines has to be equal C S
0 K

4. Organize the whole system so that the four output lines are the results of the
operations S and K and of the original inputs A and B.
Figure 2.9 illustrates the basic architecture of the full adder (to be analyzed later
in greater detail). In the meantime, the reader can try to develop the proper internal
structure for the full adder, taking into account the explanation above.

2.6 Back to Billiards

Let us return to computation with billiard balls, but now adopting a reversible
perspective. We first have to make some changes to allow reversible operations and
so will work with the conventional (reversible) FO operation.
Figure 2.10 illustrates how FO is very simple to implement with billiard balls:
the only thing to remember is the basic structure for a collision between balls A and
B and to include a new restriction: |A〉¼ |1〉 . In other words, we need a ball in A.
With the new restriction, |A〉¼ |1〉 , line A behaves as a control line in the input to
the system. Clearly, therefore

If j Bi ¼ j 1i, then j Wi ¼ j 1i and j Zi ¼ j 1i ðFO in line BÞ


If j Bi ¼ j 0i, then j Wi ¼ j 0i and j Zi ¼ j 0i ðnothing happensÞ

Following the same philosophy as described earlier, it is also possible to


configure the billiard ball setup to obtain a reversible CN. However, with the
elements we have considered to this point (necessary though they be), a real
computer cannot be simulated with billiard balls, as we are missing components
that will control our computer from a mechanical perspective.
One such component is a collision gate. Using such gates, when two moving
balls collide with two static balls, we have two inputs and four outputs and the net
36 2 Back and Forth Computing

A
W
X

B Z

Fig. 2.10 An alternative way of representing the basic structure of a collision between two billiard
balls. A and B are the inputs of the system. W, X, Y, and Z are the corresponding possible outputs

Fig. 2.11 Four basic redirection gates

result is a double FO. Another component is a redirection gate, which reflects a ball
that bumps against it and changes its direction. Figure 2.11 illustrates four of these
redirection gates.
The devices we still need are not so many and can be easily implemented in our
billiard engine. These components will enable us to build all types of gates for the
billiard ball setup, including CCN and Fredkin gates, which, as we already know,
are universal reversible operators. The conclusion is clear: it is possible to design a
reversible computer with billiard balls!

2.7 A Simple Analysis of Reversibility

We have seen that we can build CN, CCN and Fredkin gates with billiard balls. We
have also seen that if we can build universal gates, such as the Fredkin gate, then we
can build everything, and, besides, the system will be reversible.
Looking now at reversibility from another point of view, how much information
do we need in the output of our device to be able to reproduce the input and,
therefore, to perform reversible computing? We answer this question by recalling
that
1. N accepts one input and gives back one output.
2.9 Glossary of Terms and Notation Used in This Chapter 37

2. CN accepts two inputs and gives back two outputs.


3. CCN accepts three inputs and gives back three outputs.
4. The Fredkin gate accepts three inputs and gives back three outputs.
5. FO accepts one input and gives back two identical outputs.
The above five operations are reversible. Moreover, it seems that to work in a
reversible way, we need as a necessary condition the same number of distinct input
and output lines. We will discuss this in the next chapter.

2.8 Chapter Summary

We introduced the basic concepts necessary to perform reversible computations.


We defined FO and EX as two operations central to reversibility and also described
the CN gate, with which we can do many things. But to do everything in a reversible
way we need universal reversible gates, such as the CCN (Toffoli) gate, or the
Fredkin gate, which is a controlled exchange (or controlled swap) gate. We built
new reversible logic gates that operate in a similar way to conventional logic gates,
as practice in dealing with the problem of designing devices that are capable, for
example, of adding single-bit numbers in a reversible way. We then simulated
reversible computation with billiard balls. In a concluding brief analysis of revers-
ibility, we arrived at the conclusion that the number of distinct inputs and outputs
has to be the same in a device that operates in a reversible manner.

2.9 Glossary of Terms and Notation Used in This Chapter

Terms
• Free energy: a thermodynamic property that expresses the capacity of a system
to perform work under certain conditions.
• Full adder: an adder of binary numbers that accounts for values carried in as well
as out. A one-bit full adder adds three one-bit numbers, often written as A, B and
Cin; A and B are the operands, and Cin is a bit carried in from the previous less
significant stage. The full adder is usually a component in a cascade of adders
that sum binary numbers (eight-, 16-, 32-bit etc.). The circuit produces a two-bit
output: output carry and sum.
• Half Adder: a combinational arithmetic circuit that adds two numbers, producing
a sum bit (S) and a carry bit (C) as output.
• Reversible computing: a model of computing where the computational process
is to some extent reversible (in time). In a computational model that uses
transitions from one state of the abstract machine to another, a necessary
condition for reversibility is a one-to-one mapping from states to their
successors.
38 2 Back and Forth Computing

• Universal gate: AND, NOT and OR are basic gates which we can combine to
create any logic gate or any Boolean expression. NOR and NAND gates have the
particular property that either one of them can create any logical Boolean
expression if arranged properly. We examine the operation of each gate sepa-
rately as universal gates.

Notation
FO fanout operation
EX exchange operation
N, NOT NOT operator
♦, ▄ NOT operation in a controlled line
(•) control line
CN controlled-NOT gate
CCN controlled-controlled-NOT gate
F Fredkin gate
S SUM bit
K CARRY bit
Chapter 3
Reversible Architectures

As we live and as we are, Simplicity—with a capital S—is


difficult to comprehend nowadays. We are no longer truly
simple. We no longer live in simple terms or places. Life is a
more complex struggle now. It is now valiant to be simple: a
courageous thing to even want to be simple. It is a spiritual
thing to comprehend what simplicity means.
Frank Lloyd Wright

We have defined the reversible computer as a computer system that, after


performing a given computation, gives us both the results of the computation and
the original inputs. An interesting property of reversibility is that reversible com-
putations can be performed with almost no loss of energy (more on this topic later).
The only energy cost is when the computer is reinitialized in order to prepare it for
another computation. Moreover, the cost of reinitializing does not depend on the
complexity of the computation but only on the number of bits in the answer. We can
therefore affirm that reversible computation needs no energy.
As mentioned earlier, it is possible to design all conventional logic operators so
that they behave, when properly designed, in a reversible manner. We demonstrated
by showing some examples, leaving the reader to reversibly design other conven-
tional logic operators. For readers who have not done their homework, the new
challenge is to try to achieve alternative representations that improve our designs.
To build reversible logic operators we will freely combine the reversible gates
N (now represented by the symbol ▄), CN and CCN. Our purpose in the first part of
this chapter is to practice with reversible logic combinations.

© Springer International Publishing AG 2017 39


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_3
40 3 Reversible Architectures

3.1 Basic Reversible Logic Gate Architectures

Below we focus on reversible architectures for the most useful conventional logic
gates.
Reversible NAND

The steps for designing a reversible NAND are as follows:


1. Use CCN, in which lines A1 and B1 are the control lines.
2. Set |C1〉¼ |1〉always.
The reversible NAND is obtained in output line C2.
Figure 3.1 and Table 3.1 show the corresponding architecture and the results,
respectively.
Reversible Simple Implication

The steps for designing a reversible simple implication are as follows:


1. Use CCN, in which lines A1 and B1 are the control lines.
2. Set |C1〉¼ |1〉always.
3. Obtain the intermediate outputs A2, B2 and C2.
4. Apply CN using A2 as the control line and C2 as the controlled line.
The implication is obtained in output line C3.
Figure 3.2 and Table 3.2 show the corresponding architecture and the results,
respectively.

Fig. 3.1 Reversible NAND


architecture

Table 3.1 Reversible NAND |A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉
truth table
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉
3.1 Basic Reversible Logic Gate Architectures 41

Fig. 3.2 Reversible simple


implication architecture

Table 3.2 Reversible simple implication truth table


|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |0〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉

Fig. 3.3 Reversible inverse


implication architecture

Reversible Inverse Implication

The steps for designing a reversible inverse implication are as follows:


1. Use CCN, with lines A1 and B1 as control lines.
2. Set |C1〉¼ |1〉always.
3. Obtain outputs A2, B2 and C2.
4. Apply CN using B2 as the control line and C2 as the controlled line.
The inverse implication is obtained in output line C3.
Figure 3.3 and Table 3.3 show the corresponding architecture and the results,
respectively.
Reversible XNOR

The steps for designing a reversible XNOR are as follows:


1. Use three input lines: A1, B1 and C1.
2. Set |C1〉¼ |1〉always.
42 3 Reversible Architectures

Table 3.3 Reversible inverse implication truth table


|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |0〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉

Fig. 3.4 Reversible XNOR


architecture

Table 3.4 Reversible XNOR truth table


|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |0〉
|1〉 |0〉 |1〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉

3. Use CN with lines A1 (control line) and C1 (controlled line).


4. Obtain outputs A2, B2 and C2.
5. Use CN with lines B2 (control line) and C2 (controlled line).
The reversible XNOR is obtained in output line C3.
Figure 3.4 and Table 3.4 show the corresponding architecture and the results,
respectively.
Reversible NOR

The steps for designing a reversible NOR are as follows:


1. Use three input lines: A1, B1 and C1.
2. Set |C1〉¼ |1〉always.
3. Use CCN with lines A1 and B1 as the control lines.
4. Obtain outputs A2, B2 and C2.
5. Negate C2 and obtain A3, B3 and C3.
6. Apply CN using A3 as the control line and C3 as the controlled line.
7. Apply CN using B4 as the control line and C4 as the controlled line.
8. Negate C5.
3.1 Basic Reversible Logic Gate Architectures 43

Fig. 3.5 Reversible NOR architecture

Table 3.5 Reversible NOR truth table


(a)
|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |0〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |0〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |0〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉
(b)
|A4〉 |B4〉 |C4〉 |A5〉 |B5〉 |C5〉 |A6〉 |B6〉 |C6〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |1〉
|0〉 |1〉 |0〉 |0〉 |1〉 |1〉 |0〉 |1〉 |0〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |0〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉 |1〉 |1〉 |0〉

The reversible NOR is obtained in output line C6.


Figure 3.5 and Table 3.5(a, b) show the corresponding architecture and the
results, respectively.
Reversible OR

The steps for designing a reversible OR are as follows:


1. Use three input lines: A1, B1 and C1.
2. Set |C1〉¼ |1〉always.
3. Use CCN, with A1 and B1 as the control lines.
4. Obtain outputs A2, B2 and C2.
5. Negate C2 and obtain A3, B3 and C3.
6. Apply CN using A3 as the control line and C3 as the controlled line.
7. Apply CN using B4 as the control line and C4 as the controlled line.
The reversible OR is obtained in output line C5.
Figure 3.6 and Table 3.6(a, b) show the corresponding architecture and the
results, respectively.
44 3 Reversible Architectures

Fig. 3.6 Reversible OR architecture

Table 3.6 Reversible OR truth table


(a)
|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |0〉
|0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |0〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉 |1〉 |0〉 |0〉
|1〉 |1〉 |1〉 |1〉 |1〉 |0〉 |1〉 |1〉 |1〉
(b)
|A4〉 |B4〉 |C4〉 |A5〉 |B5〉 |C5〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |0〉 |1〉 |1〉
|1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉

Reversible XOR

The steps for designing a reversible XOR are as follows:


1. Use three input lines: A1, B1 and C1.
2. Set |C1〉¼ |0〉always.
3. Use CN with line A1 as the control line and C1 as the controlled line.
4. Obtain outputs A2, B2 and C2.
5. Use CN with line B2 as the control line and C2 as the controlled line.
The reversible XOR is obtained in output line C3.
Figure 3.7 and Table 3.7 show the corresponding architecture and the results,
respectively.
Reversible AND

The steps for designing a reversible AND are as follows:


1. Use three input lines: A1, B1 and C1.
2. Set |C1〉¼ |0〉always.
3.1 Basic Reversible Logic Gate Architectures 45

Fig. 3.7 Reversible XOR


architecture

Table 3.7 Reversible XOR truth table


|A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉 |A3〉 |B3〉 |C3〉
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉 |0〉 |1〉 |1〉
|1〉 |0〉 |0〉 |1〉 |0〉 |1〉 |1〉 |0〉 |1〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉 |1〉 |1〉 |0〉

Fig. 3.8 Reversible AND


architecture

Table 3.8 Reversible AND |A1〉 |B1〉 |C1〉 |A2〉 |B2〉 |C2〉
truth table
|0〉 |0〉 |0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |0〉 |1〉 |0〉
|1〉 |0〉 |0〉 |1〉 |0〉 |0〉
|1〉 |1〉 |0〉 |1〉 |1〉 |1〉

3. Use CCN with control lines A1 and B1.


4. Obtain outputs A2, B2 and C2.
The reversible AND is obtained in output line C2.
Figure 3.8 and Table 3.8 show the corresponding architecture and the results,
respectively.
46 3 Reversible Architectures

3.2 The Reversible Full Adder

We should now be able to perform reversible computations of some complexity,


using reversible operations. For example, a reversible two-bit adder could have the
architecture depicted in Fig. 3.9.
Figure 3.10 shows a generalization of this reversible two-bit adder to a reversible
full adder.
Now, using notation similar to that used to explain the construction of the NAND
operation by means of Fredkin gates—CCNA,BC means that the state of lines B and
C controls the negation of line A—we can represent the logical structure of the
reversible full adder as follows (remember that D0 ¼ 0):

fCCND0 ¼0, A0 B0 g fCNB1 , A1 g fCCND2 , B2 C2 g fCNC3 , B3 g fCNB4 , A4 g

In this chain of operations, the initial input state is

Fig. 3.9 Reversible two-bit adder architecture

Fig. 3.10 Reversible full adder architecture


3.3 Architecture of the General-Purpose Reversible Computer 47

jA0 ; B0 ; C0 ; D0 i ¼ j0; 0; 0; 0i

and the representation of the reversible full adder is read from left to right.

3.3 Architecture of the General-Purpose Reversible


Computer

Reversible computations require far more information to be stored than conven-


tional computations. Part of this information is the result of the computation, but the
rest is, simply, the information stored in order to be sure that our computation is
reversible.
If we want a given computation to be useful and effective, and simultaneously
reversible, then our computer has to respect a set of important restrictions related to
the direction of the computation process. When we use a conventional computer,
and it performs a single operation to obtain a result, we have to be sure that there is
no forward ambiguity. Analogously, if we are using a reversible computer, we have
to be sure that there is neither forward nor backward ambiguity.
Assume now that we have a system of reversible logic units that are
interconnected so that they can do something interesting—reversible, of course—
and we feed this system with a set of input data. In order to control our computation,
we will need a number of bits in state |0〉 . We leave our reversible logic system to
work with the input information and when the computations are complete we have
the following information:
The answer to our problem.
A number of bits referring to the history of the process.
It may not seem like much, but if we analyze what happened, issues of great
importance arise, related to what might be called “recreational computation.”
Consider the architecture depicted in Fig. 3.11, where M is a set of ordered
reversible logic operations.

Fig. 3.11 A general-purpose reversible architecture


48 3 Reversible Architectures

Fig. 3.12 Basic architecture of a general-purpose reversible computer system that does not
generate disorder

This reversible machine starts in a situation in which we know everything: the


data set and the zeros for controlling operations. However, it finishes with some-
thing entirely amorphous—reversible but still amorphous. It is reversible because
applying the logical sequence of M counter-clockwise will reproduce the input, but
it is amorphous because the result is disorder in the form of garbage information.
Curiously, this disorder can be used to physically move the machine, at least in
theory—but that is another story.
To understand how we can perform the computation without generating disor-
der, we only need to recall the definition of a reversible computer: a computer
system that yields the results of a computation and also the original input. The
solution to our problem is the obvious one of including in our architecture the
sequence of the counter-clockwise reversible logic operations, which we will call
W (or M1). Let us analyze in detail the architecture represented in Fig. 3.12, which
includes elements that will allow us to configure a general-purpose reversible
computer that is also free of garbage.
The key elements in the architecture are listed as follows:
1. Register X, called the copy register
2. Register Y, called the data register
3. Register Z, called the control register
4. The reversible computer system M, that is, the reversible logic system that
performs the computation
5. The FO reversible operation
6. The reversible computer system W, that is, the reversible logic system that runs
the operations of M backwards.
We can simplify the description of the reversible computation process by
breaking it down into three different phases.
Phase 1
a. The copy register, X, initially in the state |X1〉¼ |0〉(all the copy register bits are
0) goes directly to the next phase without any modification. Thus, |X2〉¼ |0〉 .
3.4 Energy Repercussions of Reversibility 49

b. The data register, Y, initially in the state |Y1〉¼ |data〉(0-bits and 1-bits
that define our problem), is processed by M, which performs the reversible
computations on Y1. Y1 is then transferred to the next phase with a new state
|Y2〉¼ |result〉 .
c. The control register, Z, initially in the state |Z1〉¼ |0〉(all the control register bits
are 0), is also processed by M and will be used to control the computation
process. Z1 is transferred to the next phase with a new state |Z2〉¼ |garbage〉 ,
containing the process history necessary to ensure reversibility.

Phase 2
a. Register X, up to now in the state |X2〉¼ |0〉 , receives the pertinent information
regarding the FO operation on Y2. The result of the computations is copied from
Y to X. X2 is then transferred to the next phase with its new state |X3〉¼ |result〉.
b. Register Y, which is in the state |Y2〉¼ |result〉 , is transferred after the FO
operation to the next phase with the state |Y3〉¼ |result〉 .
c. Register Z goes directly to the next phase with the state |Z3〉¼ |garbage〉 .

Phase 3
a. Register X is no longer modified. Its final state is |X*〉¼ |result〉 .
b. Register Y, which is actually in the state |Y3〉¼ |result〉 , is now processed by W,
which undoes, in reverse order, the operations of M, thereby reconstructing the
data set. Its final state is |Y*〉¼ |data〉.
c. Register Z, which is actually in state |Z3〉¼ |garbage〉 , is now processed by W,
which undoes, in reverse order, the operations of M, thereby reconstructing the
set of zeros. Its final state is |Z*〉¼ |0〉 .
The final result of the computation—absolutely reversible—includes a register
with the initial data, a register with the results of the computation, and a register
with the control zeros. Everything is perfectly neat and tidy and there is no garbage
information. This was possible because we used an extra register initially filled with
zeros. Note that M is a reversible logic system capable of making computations as
complicated as we wish. W is not only capable of undoing M’s operations in reverse
order but is also itself reversible.

3.4 Energy Repercussions of Reversibility

In terms of the energy used in computations, we can classify computational


processes into two different categories: (a) irreversible operations, and
(b) reversible operations.
A logic gate whose output information is less that the input information is
irreversible. This situation implies a loss of energy of some type. In contrast, a
50 3 Reversible Architectures

logic gate whose output information is the same as the input information is
reversible, and, furthermore, the information remains constant, which means that
the necessary energy to perform a computation (ideally) also remains constant. In
other words, reversible computing can be performed with no loss of energy.
The mathematical idea of conventional reversible computation was introduced
by Yves Lecerf in 1963 and further developed by Charles H. Bennett in 1973. These
authors showed that it is theoretically possible to construct a reversible Turing
machine with no energy restrictions. Bennett also showed that irreversible gates are
not essential in computation processes. However, reversibility is fundamental to
quantum computation. In building quantum machines, we have to take into account
the laws of quantum physics, and, because these laws are reversible in time, we are
forced to perform reversible operations.
In reversible machines the bits are likely to go back and forth in an uncontrolled
way. Therefore, in order to drive computation in a given direction the system needs
a push, and for this it needs energy and some disorder. Before we go on to consider
these ideas in more depth, we need to understand what happens when computer
components are small enough for quantum phenomena to acquire importance. This
will be discussed in the next chapter.

3.5 Chapter Summary

Reversibility is put into practice in accordance with the basic principles described
in the previous chapter. Several architectures are proposed to convert the conven-
tional non-reversible logic operators into reversible operators. We also design an
architecture for a reversible full adder, a physical device that does something. We
then generalize these ideas in order to define a general-purpose reversible computer.
Our first attempt works perfectly, but generates a great deal of garbage information
(disorder), so we design a second architecture that does not generate disorder, and
explore it in some depth. We conclude with some comments concerning the energy
used in reversible computations and briefly mention reversibility in relation to
quantum computing. In this sense, reversibility acts as a bridge between conven-
tional computing and quantum computing.

3.6 Glossary of Terms and Notation Used in This Chapter

Terms
• Quantum computation: a kind of computation that makes direct use of quantum
mechanical phenomena, such as superposition and entanglement, to perform
operations on data. Quantum computers are different from our digital electronic
computers based on transistors. Whereas digital computers require data to be
3.6 Glossary of Terms and Notation Used in This Chapter 51

encoded in binary digits (always in one of two states, 0 or 1), quantum compu-
tation uses quantum bits, which can be in a superposition of states.
• Turing machine: a hypothetical device with a set of logical rules of computation,
used in mathematical studies of the computability of numbers and in mathemat-
ical theories of automata and computers.

Notation
▄ NOT operator in a controlled line
M A set of reversible operations
W (or M1) Counter-clockwise operations of M
Chapter 4
The Principles of Quantum Mechanics

A scientific truth does not triumph by convincing its


opponents and making them see the light, but rather because
its opponents eventually die and a new generation grows up
that is familiar with it.
Max Planck

In the 1960s, Rolf Landauer tried to find out whether physical laws imposed
limitations on computation. More precisely, he was interested in the reason for
energy loss in computers: was it inherent to the laws of physics or due to a defect in
the available technology?
One of the problems of current high-speed computers is eliminating the heat
produced during computation. On the other hand, as technology evolves, it also
increases the scale of integration of electronic devices; thus, for example, more
transistors can fit in a given space. Engineers design progressively smaller compo-
nents with which to build computers. Indeed, we might say that we are already
living in the microscopic world. In this context, the restrictions usually imposed by
quantum mechanics are extremely important.
It is clear that we cannot build infinitely small computers, since we always need
something on which to write and store growing amounts of information. We also
need some physical property that allows the writing and storage of such informa-
tion. In this context, a physical property of some microscopic systems (such as the
atom), called spin, can be used for our purposes. Systems with natural spin have
measurable physical attributes to which we can assign numbers in such a way that
each number represents a state. But before we go any further, we need to make a
historical detour into the field of Quantum Mechanics.

4.1 History and Basic Concepts of Quantum Mechanics

Going back in time to the nineteenth century, certain experiments and the discovery
of natural radioactivity confirmed that atoms and molecules are, at least in part,
composed of charged particles. In 1909, Ernest Rutherford demonstrated the

© Springer International Publishing AG 2017 53


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_4
54 4 The Principles of Quantum Mechanics

nuclear nature of atoms by observing the deflection of alpha particles passing


through a thin gold foil. The results of this experiment underpinned the hypothesis
of the planetary structure of atoms, according to which atoms consist of a dense
nucleus formed of neutrons and protons, with electrons orbiting very far from the
nucleus. The properties of atoms, motion and energy thus depend on their electronic
structure.
However, the planetary model of the atom is neither compatible nor consistent
with James Clerk Maxwell’s classical electromagnetic theory, which predicts that
charged particles, when accelerated, will lose energy. Obviously the electron is an
accelerated particle, because the direction of its velocity changes constantly. This
circumstance inevitably leads to a loss of energy by radiation. In other words,
according to the planetary model, atoms would not be stable, as the electron would
draw a spiral orbit around the nucleus that would finally lead to its collapse. But this
is not what happens, as electrons remain stable.
In the first decade of the twentieth century, Max Planck was trying to solve the
apparently strange behavior of energy in what came to be called the black-body
radiation problem. Albert Einstein, meanwhile, was studying the photoelectric
effect, which reveals the corpuscular character of light. Both their contributions
made the quantum nature of the universe evident. According to this new conception
of the universe, the stability of atoms can be explained if we assume stationary
states in the electron orbits, as depicted in Fig. 4.1.
In 1923 Louis de Broglie demonstrated that electrons also have wave-like
behavior. Surprisingly, therefore, particles can behave like waves and waves can
behave like particles. Figure 4.2 illustrates these behaviors with an example that
involves photons (particles of light), where hν is energy, h is Planck’s constant, ν is
frequency, and electrons are represented as e. Figure 4.3 is a photographic image
that reflects this duality.
Going into more detail, for the moment assume that we have an electron e with
mass m and moving at velocity v, and also assume that λ is the associated wave-
length, defined by

Energetic State 2

Energetic State 1
Emission of a Absorption of a
quantum of energy quantum of energy

Fig. 4.1 Quantum nature of the universe. Emission and absorption of discrete quantities of energy
between two allowed energy states
4.1 History and Basic Concepts of Quantum Mechanics 55

Fig. 4.2 The dual particle-wave nature of light: left, photons behaving as particles, and right,
photons behaving as waves

Fig. 4.3 An image showing particle-wave duality. In the microscopic world, all depends on how
we look at something, but a cylinder remains a cylinder

h h
λðeÞ ¼ ¼
mðeÞ  vðeÞ pðeÞ

In this equation
• h is the Planck constant
• λ(e) is the electron wavelength
• m(e) is the electron mass
• p(e) is the linear momentum of the electron
• v(e) is the electron velocity
Assume now that v(e) ¼ c, where c is the speed of light in a vacuum. In
accordance with Einstein, the total energy of a particle (in our case, an electron e)
is therefore

E ¼ m  c2

And, in accordance with Planck, the total energy of a wave is therefore


E¼hv

In the previous equation, ν is the frequency of the wave. Therefore


56 4 The Principles of Quantum Mechanics

Table 4.1 Some photon and electron physical properties


Physical entity Type Velocity Mass Treatment
Photon Particle of light c in vacuum None Always relativistic
Electron Wave of matter Less than c >0 Not always relativistic

hc h
m  c2 ¼ h  ν ¼ !λ¼
λ mc

But since v(e) < c


h h
λðeÞ ¼ ¼
mðeÞ  vðeÞ pðeÞ

In view of these results, in 1932 Otto Stern postulated that the wave-like effects
were the result of a general law of motion. Almost at the same time that these ideas
were being consolidated, engineers started to consider new applications. Electronic
microscopy, for instance, is a practical application of the dual nature of particles.
However, despite this dual nature, photons (particles of light) are not the same as
electrons (waves of matter). The difference is summarized in Table 4.1.

4.2 Heisenberg’s Uncertainty Principle

We will now look at one of the most important, and controversial, concepts in
Quantum Mechanics: the uncertainty principle introduced by Werner Heisenberg.
The questions we need to answer are
How can we describe the position of a particle?
What is the right procedure for determining this position?
The obvious answer to both questions would seem to be “by observing the
particle.” But in the world of very small things, observing is not that easy. Imagine
a microscope that can be used to observe an electron. To see the electron, we have
to project a beam of light or some kind of appropriate radiation onto it. But an
electron is so small that even a single photon of light would change its position. So
in the precise instant we want to measure the position, the position changes.
Heisenberg demonstrated that it was not possible to contrive a method to locate
the position of a subatomic particle unless we admitted some absolute uncertainty
with regard to its exact velocity, since it is impossible to simultaneously and
accurately measure both position and velocity. This is also the reason why we
cannot achieve complete absence of energy, even at the absolute zero point.
Particles at the zero point with absolutely no energy would remain totally motion-
less (zero velocity), so their position could easily be measured. However, in
4.2 Heisenberg’s Uncertainty Principle 57

accordance with Heisenberg’s uncertainty principle, we have to expect some zero-


point energy.
In 1930, Einstein showed that the uncertainty principle—which affirms the
impossibility of reducing error in the measurement of position without increasing
error in the measurement of linear momentum—also implied the impossibility of
reducing error in the measurement of energy without increasing uncertainty in the
measurement of time. For a particle moving in direction x, if we express uncertainty
in both position and linear momentum as
Δpx  Δx

and if we express uncertainty in both energy and time as


ΔE  Δt

then a very simple dimensional analysis shows that both uncertainties have the
same dimensional result: M  L2  T1, where M is mass, L is length and T is time.
In an attempt to demonstrate that the Heisenberg uncertainty principle was
wrong, Einstein proposed the experiment depicted in Fig. 4.4.

Fig. 4.4 Einstein’s experiment to intend to demonstrate that the Heisenberg uncertainty principle
was wrong
58 4 The Principles of Quantum Mechanics

Einstein’s experiment is described as follows:


1. A box is hanging from a spring.
2. A clock is hanging from the box.
3. The box has a small hole.
4. A particle is moving inside the box.
5. A ruler measures elongation of the spring.
6. An observer is looking simultaneously at the spring, clock and ruler.
7. The particle exits the box through the hole.
8. The observer knows exactly when this happens because the spring shortens at a
time indicated by the clock.
Einstein’s satisfaction at disproving the Heisenberg uncertainty principle only
lasted until Niels Bohr demonstrated, using Einstein’s own theory of general
relativity, that the principle was correct. When the particle exits the box, the spring
shortens, and this is how the observer knows that the particle is outside the box.
However, the gravitational field acting on the clock is now different, so time runs
differently compared to the initial state.
Returning to the fundamentals of the uncertainty principle, although formal and
rigorous demonstrations exist, we will prove it using a geometrical approach.
Consider the diagram in Fig. 4.5, which shows a beam of particles hitting a wall
with a small slit whose diameter is W. Situated behind the slit is photographic film,
which will detect motion.
As a consequence of the wave-like properties of matter, the beam of particles
diffracts, causing the momentum to be changed by a given angle α (in other words,
part of the momentum is transferred elsewhere). Formally

There is a slit in the axis OX.


The slit diameter is W.
p is the momentum vector.
p is the modulus of p.

Fig. 4.5 An experiment to illustrate Heisenberg’s uncertainty principle


4.2 Heisenberg’s Uncertainty Principle 59

A
W/2 C
a
O O

W/2
B

Fig. 4.6 A geometrical outline of Heisenberg’s uncertainty principle

Δx ¼ W is the uncertainty of the position.


Δpx ¼ p  sin(α) is the uncertainty in the momentum.
Δx  Δpx ¼ W  p  sin(α)

In accordance with the condition of the first diffraction minimum, the difference
between the distance traveled by the particles going through A and going through O
has to be one half of the associated wavelength (λ/2), as illustrated in Fig. 4.6.
The proof is as follows:
1. We calculate the value of α corresponding to the first diffraction minimum.
2. We draw AC such that AD ¼ CD, with OC representing the difference between
the distances traveled by the particles going through A and through O.
3. The distance OD is large relative to W, so AD and OD are almost parallel,
meaning that the angle ACO is almost a right angle. Hence, OAC ¼ α.
4. Steps 2 and 3 imply that

W
OC ¼  sin ðαÞ
2

5. If we say that OC ¼ λ/2, then we have that

λ ¼ W  sin ðαÞ

We previously stated that

Δx  Δpx ¼ W  p  sin ðαÞ ! Δx  Δpx ¼ p  λ

Recall now that


h
λ¼ ! Δx  Δpx ¼ h
p
60 4 The Principles of Quantum Mechanics

However, since the uncertainties have not been defined with precision, we have
to conclude that
Δx  Δpx  h

From the above result we can conclude that the simple fact of measuring causes a
change in the state of a system which is of the order of magnitude of the Planck
constant h.

4.3 Schr€odinger’s Equation

In 1925 Erwin Schr€odinger developed an equation that describes how a


non-relativistic massive particle changes with time. Schr€odinger’s equation—of
central importance in quantum mechanics—represents for microscopic particles
what Newton’s second law of motion represents for classical mechanics. For a
one-dimensional system of a single particle, Newton’s second law establishes that

d2 x
F¼m
dt2

Then

d2 x ¼ F  m1  dt2

Assuming that
x ¼ gðt; c1 ; c2 Þ

if the particle is in position x0 at an arbitrary initial time t0, then


x0 ¼ gðt0 ; c1 ; c2 Þ

Recall that the velocity v of a moving particle can be represented as


dx d
v¼ ¼ f gðt; c1 ; c2 Þ g
dt dt

If the particle is moving with velocity v0 at an arbitrary initial time t0, then
d
v0 ¼ f gðt; c1 ; c2 Þ gt¼t0
dt

In the above equations


• F is the net force
• m is the particle mass
• x is the particle position
4.3 Schr€odinger’s Equation 61

• t is time
• g is a generic function
• v is the particle velocity
• c1 and c2 are integration constants
We can now easily calculate c1 and c2. In classical mechanics, if we know x,
v and F we can predict the state of a particle in motion. However, matters are
somewhat different in the microscopic world. In quantum mechanics the state of a
system is described by means of a wave function:
Ψ ¼ Ψ ðx; tÞ

Bearing in mind the wave-like behavior of small particles, the starting point for
developing an equation to describe waves of matter is the equation developed by
Louis de Broglie:
h
p¼mv¼
λ

As a first restriction, the equation we want to define must be consistent with de


Broglie’s equation. Our second restriction, given the wave-like properties of micro-
scopic particles, will be that the mathematical formula to describe the behavior of a
particle with wavelength λ must be a trigonometric function. For example,
 
2πx
ΨðxÞ ¼ sin
λ

We also have to take into account that the total energy E of the particle is the sum
of its kinetic energy K and its potential energy V:
E¼KþV

However
1
K ¼ m  v2
2

Thus
1
m  v2 þ V ¼ E
2

And
h h2
v¼ ! ¼EV
mλ 2  m  λ2
1 2m
¼ ðE  V Þ
λ 2
h2
62 4 The Principles of Quantum Mechanics

To obtain a differential equation with a sinusoidal solution (the case of the


classical approach), we have to differentiate and make some substitutions. Thus
 
d 2π 2πx
Ψð x Þ ¼ cos
dx λ λ
 2  
d2 2π 2πx
Ψ ð x Þ ¼  sin
dx 2 λ λ
 
d2 2π 2
Ψ ð x Þ ¼  Ψð x Þ
dx2 λ

d2 8π 2 m
2
Ψð x Þ ¼  2 ð E  V Þ Ψð x Þ
dx h

This last equation is valid when potential energy V is constant. However, let us
consider the above equation to be also valid when V is not constant. Conversely,
V can vary along the x-axis. In mathematical terms this is represented as
V ¼ V ðxÞ

We can thus obtain Schr€odinger’s equation independent of time:

d2 8π 2 m
2
ΨðxÞ ¼  2 ½E  V ðxÞ ΨðxÞ
dx h

If we include time in the potential energy of our system, then the basic equation
reflecting a one-dimensional quantum system for a single time-dependent particle is
as follows:

h dΨðx; tÞ h2 d2 Ψðx; tÞ


¼ þ V ðx; tÞΨðx; tÞ
i dt 2m dx2

It thus follows that, given


h

then
h dΨðx; tÞ h2 d2 Ψðx; tÞ
¼ 2 þ V ðx; tÞΨðx; tÞ
2πi dt 8π m dx2

In this equation, V(x, t) is the potential energy of our quantum system. But
Schr€
odinger’s equation is not only difficult to interpret, but also (with the exception
4.3 Schr€odinger’s Equation 63

Fig. 4.7 An attempt to introduce the concept of probability density

of some very rare quantum systems) impossible to solve analytically. There is also
another question: what is the real physical sense of the Schr€odinger equation?
Heisenberg indicated that the classical state and the quantum state have to be
interpreted differently since they are concerned with different things. The problem
of the physical interpretation of Schr€odinger’s equation was finally resolved by the
mathematician Max Born. For a given time t,

jΨðx; tÞj2

is the probability density function. Probability density, in Quantum Mechanics,


refers to the probability that a particle is in the interval (x, x + dx). If g(x) is the
probability density, with g(x) 2 R such that g(x)  0, then, in accordance with
Fig. 4.7,
ðb
gðxÞ ¼ jΨj2 ! ProbðxÞ ¼ jΨj2 dx
a
ð1
jΨj2 dx ¼ 1
1

We can now establish an interesting relationship between |Ψ|2 and experimental


measurements:
a. N is a collection of identical systems that do not interact with each other
b. 8i 2 N, 8j 2 N: Ψi ¼ Ψj
c. The position of each i 2 N is measured
d. dnx ¼ number of particles in the interval (x, x + dx)
e. dnx/|N| ¼ probability ¼ P(x, x + dx) ¼ |Ψ|2 dx
However, we cannot make many measurements of a single particle since, in
accordance with Heisenberg’s uncertainty principle, each measurement changes the
state of the system.
64 4 The Principles of Quantum Mechanics

4.4 Schr€odinger’s Equation Revisited

Let us approach the same problem from a different point of view and obtain a
similar result. Our starting point will be the time-dependent Schr€odinger equation:

h d Ψðx; tÞ h2 d2 Ψðx; tÞ


¼ þ V ðx; tÞΨðx; tÞ
2πi dt 8  π2  m dx2

In the words of Ira Levine, this equation is no less than impressive. Nevertheless,
there are situations in which potential energy does not vary over time. In such cases
we can experiment to see what happens. Assume that

Ψðx; tÞ ¼ f ðtÞ  ψðxÞ

Then
dψðx; tÞ df ðtÞ
¼ ψ ðxÞ
dt dt

And

d2 Ψðx; tÞ d2 ψ ðxÞ
¼ f ð tÞ
dx2 dx2

Separating variables and operating

h d f ðt Þ h2 d2 ψ ðxÞ
ψ ðxÞ ¼ f ð tÞ þ V ðxÞψ ðxÞf ðtÞ
2πi dt 8  π2  m dx2

Dividing this last expression by ψ(x)f(t) we obtain

h d f ðtÞ h2 d2 ψ ð x Þ
f 1 ðtÞ ¼ ψ 1
ð xÞ þ V ðxÞ
2πi dt 8  π2  m dx2

Now we have a term that is independent of x:


h d f ðtÞ
f 1 ðtÞ
2πi dt

And we also have a term that is independent of t:

h2 1 d2 ψ ð x Þ
ψ ð x Þ þ V ðxÞ
8  π2  m dx2

Since the two terms are independent and are related by equality, they must
represent a constant magnitude (energy, perhaps?). So, if we denote this constant
magnitude by E, the result is
4.4 Schr€odinger’s Equation Revisited 65

h d f ðtÞ h2 d2 ψ ð x Þ
E¼ f 1 ðtÞ ¼ ψ 1 ðxÞ þ V ðx Þ
2πi dt 8π m
2 dx2

We can now operate with the term that is independent of x as follows:


2πi
f 1 ðtÞd f ðtÞ ¼  E  dt
h

And
2πi
loge f ðtÞ ¼  E  t þ cte
h

Therefore

f ðtÞ ¼ ecte  e ¼ A  e
2πi 2πi
h Et h Et

In this last equation, the arbitrary constant A ¼ ecte can be omitted since it does
not affect the generality of the formula. We therefore conclude that

f ðt Þ ¼ e 
2πi
h Et

Analogously, if we operate with the term that is independent of time t

h2 d2
Eψ ðxÞ ¼  ψ ðxÞ þ V ðxÞψ ðxÞ
8  π 2  m dx2

Tidying up we obtain the following equation:

d2 8π 2 m
ψ ð x Þ þ ½E  V ðxÞψ ðxÞ ¼ 0
dx2 h2

We have seen this equation before. It is, in fact, the one-dimensional, time-
independent Schr€odinger equation, where E represents the total energy in the
system. Recalling the equation that defines f(t), we can obtain the wave function
for the probability density steady state as follows:

f ðt Þ ¼ e 
2πi
h Et

yields
If : V ¼ V ðxÞ ! Ψ ðx; tÞ ¼ ψ ðxÞ  e
2πi
h Et

Note that quantum equations work with complex numbers, which are also at the
heart of quantum computing. This issue will be discussed later in some detail.
66 4 The Principles of Quantum Mechanics

4.5 The Postulates of Quantum Mechanics

To understand quantum computing we need to understand some elementary prin-


ciples of quantum mechanics. It was not possible to properly describe the behavior
of very small particles such as electrons, atoms or molecules until physicists
(among them Niels Bohr, Max Born, Louis de Broglie, Paul Dirac, Albert Einstein,
Werner Heisenberg, Pascual Jordan, Wolfgang Pauli and Erwin Schr€odinger)
mathematically formalized the theory of quantum mechanics in the closing years
of the 1920s.
Quantum Mechanics can be approached in two different ways. The first way is to
analyze physical problems that quantum mechanics but not classical mechanics can
resolve, for instance:
The strange behavior of black-body spectral radiation
The photoelectric effect
The atomic spectrum of the hydrogen atom
Compton scattering
The second approach is axiomatic: we define fundamental postulates from which
we deduce the behavior of microscopic physical systems and then compare the
theory with experimental observations. By quantifying the level of agreement
between theoretical predictions and experimental results we can obtain a direct
measure of the validity of the theory.
We will use the second, axiomatic, approach to quantum mechanics. The best-
known phenomenological formulation is that by Schr€odinger, based on the wave-
like description of matter. However, we will use the formulation of Heisenberg and
Dirac, based on vectors, operators and matrices. Genius is genius: Schr€odinger
demonstrated that the two approaches are equivalent and interchangeable.
The axiomatic formulation of Heisenberg and Dirac is based on the postulates
described below.
Postulate I The state of a physical system is described by a function Ψ(q, t) of
coordinates (q) and time (t). This function, called the state function or wave
function, contains all the information that can be obtained on the system in
question.
Postulate II The temporal evolution of the state of the system is given by the time-
dependent Schr€
odinger equation:
dΨðq; tÞ b Ψðq; tÞ
ih ¼H
dt
b is the Hamiltonian operator. For a single particle
In this equation, h ¼ h/2π and H
b
moving along axis x, H is given by

b ¼  h dΨðq; tÞ þ V ðx; tÞΨðx; tÞ


2
H
2m dx
4.6 Some Quantum Operators 67

Postulate III For each observable (physical) property, quantum mechanics defines
a linear Hermitian operator. To find this operator, we have to write the classical
expression of the observable property in terms of the Cartesian coordinates and the
corresponding linear momentum. We then have to replace each x coordinate by the
operator x (that is, multiply by x) and replace each linear momentum px by the
operator ihd/dx.
Postulate IV Independently of the state function of the system, the only values that
we can obtain from a measurement of the observable A are the eigenvalues a of
b fi ¼ a  fi
A

Postulate V If Ab is a linear Hermitian operator that represents a given observable,


then the eigenfunctions ψ i of
b ψi ¼ a  ψi
A

form a complete set. This last statement means that any state function Ψ that
satisfies the selfsame conditions can be represented as the linear combination of
the eigenstates of A:
X
Ψ¼ ci ψ i
i

Postulate VI If ψi(q, t) is the normalized state function of the system at a given


time t, then the mean value of the observable A at time t is:
ð
b ψ dq
hA i ¼ ψ ∗ A

where the symbol (*) means conjugate (remember that we are working with
complex numbers).

Postulate VII If Ab is a linear Hermitian operator that represents a given physical


b form a complete set.
magnitude, then the eigenfunctions fi of the operator A

4.6 Some Quantum Operators

An operator is a rule or procedure that, given one function, allows us to calculate


another function. What follows is a list of operations and their properties applying
b
to quantum operators, denoted here by means of capital letters with a hat (that is, A,
b b
E, I etc.)
68 4 The Principles of Quantum Mechanics

 
bþE
A b ðxÞ þ Ef
b f ðxÞ ¼ Af b ðx Þ
  n o
bE
A b Ef
b f ðx Þ ¼ A b ðx Þ

We need to take into account that, generally speaking


   
bE
A b f ðxÞ 6¼ E bA b f ðx Þ

We can also define an algebra of quantum operators using the following ele-
b and E
ments: Assume we have two operators A b

b¼E
A b ¼ Ef
b $ 8f Af b

• The identity operator is defined.


• The null operator is defined. It holds that
   
b E
A bb
I ¼ AbE
b b I

bE
• Not always A b¼E b  Ab
• The commutator of two operators is defined:
 
b E
A; b ¼AbE
bE b
bA

b2 ¼ A
A bA
b

Quantum operators have some interesting properties:

• Ab½ f ðxÞ þ gðxÞ ¼ Af


b ðxÞ þ Ag
b ðxÞ, where f and g are functions
b½c f ðxÞ ¼ c A
• If f is a function and c is a constant: A b f ðx Þ

 
bþE
A b b bb
I ¼A bb
I þE I
 
b E
A bþb
I ¼A bE
bþA bbI

In the quantum approach all operators are linear.


Other important characteristics of quantum operators are related to the concepts
of eigenfunctions and eigenvalues (to be discussed further below). Assume that Ab is
an operator, f(x) is a function and k is a constant. If
b ðx Þ ¼ k  f ðx Þ
Af
4.6 Some Quantum Operators 69

then f(x) is an eigenfunction and k is an eigenvalue of the operator A. b The


eigenfunctions of any linear operator also verify that, given a constant c,
bðc  f Þ ¼ c  Af
A b ¼ c  k  f ¼ k ðc  f Þ

Thus:
If f(x) is an eigenfunction of A b with eigenvalue k, then c  f(x) is also an
eigenfunction.
Also associated with the quantum operators is the notion of average value.
Consider a physical magnitude E. When the state function Ψ is not an eigenfunction
of the associated operator E, b measuring E gives us just one possible value. We now
consider the average value of E for a system whose state is Ψ. Since the experi-
mental result of the average value of E forces us to consider a large number of
systems, all in the same state Ψ, we need to measure E for each system. The average
value of E is the arithmetical average of the observed values. For example,
if e1, e2,. . . are the values observed for E, then the average value of E, denoted
by〈E〉 , for a large number N of systems is as follows:
PN
ei
hEi ¼ i¼1
N

The same result can be obtained if we sum all the possible values of E, that is to
say, if we sum the different ei that can be obtained, multiplying each by the number
of times that it has been observed:
P
ne  e X  ne X
h Ei ¼ e ¼ e¼ Pe  e
N e
N e

In this last expression, Pe is the probability of observing the value e, since, as we


have said, N is very large. We can use these results to study the behavior of a
one-dimensional particle system in, for example, the state Ψ(x, t). More specifi-
cally, we consider the average value for the coordinate x.
Let us assume a given particle, which could perfectly well be a bit, in the state
Ψ(x, t). Let us also assume that this particle is moving along the x-axis in such a way
that x takes continuous (non-discrete) values. Under these assumptions,

Pbit ðx; x þ dxÞ ¼ jΨj2 dx

is the probability of observing the particle under consideration between (x) and
(x + dx). Therefore
ð
þ1

hxi ¼ x jΨðx; tÞj2 dx


1
70 4 The Principles of Quantum Mechanics

b is the operator
On the other hand, if E(x) is a property that depends on x, and if E
associated with E(x), then
ð
hEi ¼ Ψ ∗ E Ψ dx

The associated probability density is defined as follows:

Ψ∗ Ψ

Furthermore, if F and G are two different properties, it turns out that


• hF + Gi ¼ hFi + hGi
• hF  Gi 6¼ hFi  hGi
A problem with this approach is that the mathematical background involves
numerous integrals that can make understanding the approach difficult. The solu-
tion to this notation problem was provided by Paul Dirac.
Let us assume that τ indicates the integration space. If φm and φn are functions
and Ab is an operator, then
ð
 
b φn dτ  hφm j A
φ∗ A b j φn i  φ m j Ab j φn  hm j Ab j ni  A
bmn
m
ð
φ∗
m φn dτ  hφm j φn i  hm j ni

In the above equations, hm | ni is the Dirac representation of the inner product


between the vectors m and n. Using Dirac bra-ket notation, for a given state
described as a row vector or a column vector, then the bra notation or the ket
notation, respectively, can be used:
 
a
Ketðψ Þ ¼j ψ i ¼
b

Braðψ Þ ¼ h ψ j¼ ða bÞ

The inner product for m and n is as follows.


If
 
m1
m ¼j m i ¼ ! hm j¼ ð m∗
1 m∗
2 Þ
m2

and
 
n1
n ¼j n i ¼ ! hn j¼ ð n∗
1 n∗
2 Þ
n2
4.6 Some Quantum Operators 71

Then  
n1
hm j ni ¼ ð m∗
1 m∗
2 Þ ¼ m∗ ∗
1  n1 þ m2  n2
n2

Let us illustrate this with an example. Assume that


 
1þi
j mi ¼ ! hm j¼ ð 1  i 2 þ i Þ
2i
 
2i
j ni ¼ ! hn j¼ ð 2 þ i 1 þ 2i Þ
1  2i

Then
 
2i
hm j ni ¼ ð 1  i 2 þ i Þ
1  2i

¼ ð1  iÞ  ð2  iÞ þ ð2 þ iÞ  ð1  2iÞ ¼ 5  6i

Note that it is very easy to prove the following two equations:


• hm j ni∗ ¼ hn j mi
• hm j mi∗ ¼ hm j mi
These are verified as follows:
!
1þi
hn j mi ¼ ð 2 þ i 1 þ 2i Þ ¼
2i
ð2 þ iÞ  ð1 þ iÞ þ ð1 þ 2iÞ  ð2  iÞ ¼ 5 þ 6i
ð5  6iÞ∗ ¼ ð5 þ 6iÞ

And
!
1þi
hmjmi ¼ ð 1  i 2 þ i Þ ¼
2i
ð1  iÞ  ð1 þ iÞ þ ð2 þ iÞ  ð2  iÞ ¼ 7
ð 7Þ ∗ ¼ ð 7Þ

As mentioned earlier, it is not our purpose to comprehensively describe quantum


mechanical principles. However, the concepts described above are probably suffi-
cient to understand the basic principles of quantum computing.
72 4 The Principles of Quantum Mechanics

4.7 Chapter Summary

Since quantum computing is based on concepts and techniques developed in


quantum mechanics, some understanding of the latter is necessary, starting with a
history of its development. At the microscopic level, we discuss Louis de Broglie’s
proposal that waves behave like particles and particles behave like waves. We then
discuss Heisenberg’s uncertainty principle—using a geometrical approach—and
explore the Schr€ odinger equation that underpins the entire framework of quantum
mechanics, obtaining several results. Schr€odinger’s equation is difficult to interpret,
however. A reasonable interpretation of quantum mechanics in probabilistic terms
was provided by Max Born. We progress to formulation in quantum mechanics,
basing our approach on the axiomatic point of view proposed by Heisenberg and
Dirac. To provide a framework for quantum mechanics we list seven postulates,
which we define, in turn, in terms of operators. Quantum mechanics works with
complex numbers, vectors and other entities that are defined in what is called the
Hilbert space. We do not explicitly define this space, but introduce the bracket
notation of Paul Dirac and describe certain properties—such as the inner product—
as groundwork for dealing with concepts in the chapters ahead.

4.8 Glossary of Terms and Notation Used in This Chapter

Terms
• Absolute zero point: the point at which the fundamental particles of nature have
minimal vibrational motion, retaining only quantum mechanical, zero-point-
energy-induced particle motion.
• Alpha particle: positively charged particle consisting of two protons and two
neutrons, emitted in radioactive decay or nuclear fission. Also the nucleus of a
helium atom.
• Average value: a quantity intermediate to a set of quantities.
• Black body: a hypothetical body that absorbs but does not reflect electromag-
netic radiation incident on its surface.
• Complex number: a mathematical expression (a + bi) in which a and b are real
numbers and i2 ¼ 1.
• Differential equation: an equation involving differentials or derivatives.
• Diffraction: the spreading of waves around obstacles.
• Eigenfunction: any non-zero function f for a linear operator A defined in some
function space that returns from the operator exactly as is, except for a multi-
plicative scaling factor.
• Eigenstate: a quantum-mechanical state corresponding to an eigenvalue of a
wave equation.
4.8 Glossary of Terms and Notation Used in This Chapter 73

• Eigenvalue: a special set of scalars associated with a linear system of equations


(that is, a matrix equation) that are sometimes also known as characteristic roots,
characteristic values, proper values or latent roots.
• General relativity: a generalization of special relativity and Newton’s law of
universal gravitation that provides a unified description of gravity as a geometric
property of space and time (or space-time). The curvature of space-time is
directly related to the energy and momentum of the matter and radiation that
are present.
• Hamiltonian: the operator (in most cases) corresponding to the total energy of
the system.
• Heisenberg’s uncertainty principle: in Quantum Mechanics, any of a variety of
mathematical inequalities asserting a fundamental limit to the precision with
which certain pairs of physical properties of a particle (complementary vari-
ables), such as position x and momentum p, can be known simultaneously.
• Hermitian: in mathematics, a self-adjoint matrix or square matrix with complex
entries that is equal to its own conjugate transpose. Thus, the element in the i-th
row and j-th column is equal to the complex conjugate of the element in the j-th
row and i-th column, for all indices i and j. In mathematical analysis, a Hermitian
function is a complex function with the property that its complex conjugate is
equal to the original function with the variable changed in sign.
• Hilbert space: an abstract vector space possessing the structure of an inner
product that allows length and angle to be measured.
• Inner product space: in linear algebra, a vector space with an additional structure
called an inner product that associates each pair of vectors in the space with a
scalar quantity known as the inner product of the vectors. Inner products allow
the rigorous introduction of intuitive geometrical notions such as vector length
and the angle between two vectors and also provide the means of defining
orthogonality between vectors (zero inner product).
• Linear momentum: the product of the mass and velocity of an object.
• Matrix: in mathematics, a rectangular array of numbers, symbols or expressions,
arranged in rows and columns.
• Operator: a mapping from one vector space or module to another. Operators are
of critical importance in both linear algebra and functional analysis, and have
applications in many other fields of pure and applied mathematics. For example,
in classical mechanics, the derivative is used ubiquitously, and in quantum
mechanics, observables are represented by Hermitian operators. Important prop-
erties of operators include linearity, continuity and boundedness.
• Photoelectric effect: the observation that light shone on many metals produces
electrons called photoelectrons. The effect is commonly studied in electronic
physics and in chemical disciplines such as quantum chemistry and
electrochemistry.
• Photon: a particle representing a quantum of light or other electromagnetic
radiation.
• Planck’s constant: a physical constant that is the quantum of action and central to
quantum mechanics.
74 4 The Principles of Quantum Mechanics

• Probability density: a function that describes the relative likelihood of a random


variable taking on a given value.
• Spin: in quantum mechanics and particle physics, an intrinsic form of angular
momentum carried by elementary particles, composite particles (hadrons) and
atomic nuclei.
• Trigonometric (circular) function: in mathematics, any function of an angle that
relates the angles of a triangle to the lengths of its sides.
• Wave function: a quantum state of an isolated system of one or more particles,
whereby one wave function contains all information on the entire system (not
separate wave functions for each particle in the system). Its interpretation is that
of a probability amplitude and it can be used to derive quantities associated with
measurements, such as the average momentum of a particle.

Notation
λ Wavelength
h Planck constant
c Speed of light in a vacuum
ν Frequency
Ψ(x, t) Wave function
b
H Hamilton operator or Hamiltonian
b
A A generic operator
 
b E
A; b Commutator of two operators
h-i Average value
m A vector m
Chapter 5
Introducing Quantum Computing

Nobody understands Quantum Mechanics. No, you’re not


going to be able to understand it. You see, my physics
students don’t understand it either. That is because I don’t
understand it. Nobody does. . . The theory of quantum
electrodynamics describes Nature as absurd from the point of
view of common sense. And it agrees fully with experiment.
So I hope you can accept Nature as she is: Absurd!
Richard P. Feynman

Microchips are small and they will become even smaller, because the smaller an
electronic device, the faster its processing speed. However, we can neither design
nor implement infinitely small chips, since there is a limit beyond which they will
not work properly. When we reach the nanometer scale, electrons escape from the
channels through which they circulate because of a typically quantum phenomenon
called the tunnel effect. Colloquially we can say that a classical particle cannot
breach an obstacle (like a wall). But since electrons are quantum particles and have
wave-like behavior, a part of them can penetrate walls that confine them. The signal
can thus escape from the channel where it is supposed to circulate, and the chip fails
to work.
Because traditional digital computation has arrived at scales of only some tens of
nanometers, it is now approaching its limits. The evidence that this is the case
sowed the seed for current ideas about quantum computation and quantum
computers.

5.1 A Brief Overview of Quantum Computing

The essential ideas underpinning quantum computing arose in the early 1980s in the
mind of Paul Benioff, who was working on some fundamental principles of
quantum mechanics using traditional computers (Turing machines). In 1981 Rich-
ard Feynman proposed a quantum approach to computation, suggesting that com-
plex calculations could be performed faster by a quantum computer. In 1985 David

© Springer International Publishing AG 2017 75


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_5
76 5 Introducing Quantum Computing

Deutsch described the first universal quantum computer that could simulate any
other quantum computer (the extended Church-Turing principle). The idea thus
arose that a quantum computer could execute quantum algorithms, and by the early
1990s, the theory began to produce practical results in the form of the first quantum
algorithms, the first quantum applications and the first quantum computers.
In 1993 Dan Simon highlighted the advantages of the quantum computer over
the traditional computer, and also compared classical and quantum probability. The
foundations were thus laid for the development of genuinely practical algorithms.
In the same year Charles Bennett expounded the idea of quantum teleportation,
which opened the door to the development of quantum communications.
Between 1994 and 1995 Peter Shor developed a quantum algorithm capable of
calculating the prime factors of numbers much faster than a traditional computer.
Shor’s algorithm, which enabled many of the systems currently used in cryptogra-
phy to be broken, served to demonstrate, once and for all, that the quantum
approach was a research field with great potential. Shor also proposed a system
for quantum error corrections.
In 1996 Lov Grover proposed a quantum mechanical algorithm for data retrieval
from large databases. Although the improvement implied by Grover’s algorithm
was not as spectacular as that achieved with factorial calculations or physical
simulations, its range of applications is much greater. Like other quantum algo-
rithms, Grover’s algorithm is probabilistic in nature.
In 1997 the first practical experiments opened the door to the implementation of
theoretically described quantum calculations and quantum approaches. These
experiments included safe communication using quantum cryptography (success-
fully performed to a distance of 23 km) and quantum teleportation of a photon. In
1998 Los Alamos and Massachusetts Institute of Technology (MIT) researchers
propagated the first qubit through a solution of amino acids in an experiment that
was the first step in analyzing the information that could be transported by a qubit.
Switching our focus now to quantum computers, in 1998 the first two-qubit
machine was built at University of California, Berkeley. A year later, IBM built the
first three-qubit machine, capable of executing, for the first time, Grover’s
algorithm.
In 2000 IBM went further and built a five-qubit quantum computer, capable of
running a research algorithm forming part of Shor’s algorithm and performing the
corresponding task in one simple step (when a conventional computer would have
required numerous iterations). In the same year, Los Alamos scientists developed a
seven-qubit quantum computer, which, in 2001, scientists from IBM and Stanford
University successfully used to demonstrate Shor’s algorithm. The experiment
involved using 1018 molecules, each with seven active nuclear spins, to yield the
correct result of 3 and 5 for factorization of the number 15.
In 2005 the Institute of Quantum Optics and Quantum Information of the
University of Innsbruck (Austria) announced that their scientists had created the
first qubyte (a series of eight qubits) using ion-trapping techniques. In 2006
scientists from the University of Waterloo, the Perimeter Institute for Theoretical
Physics (both in Canada) and MIT developed a 12-qubit system.
5.1 A Brief Overview of Quantum Computing 77

In September 2007, the National Institute of Standards and Technology in


Boulder (Colorado) and Yale University at New Haven designed the first quantum
bus, which can also be used as a quantum memory capable of retaining quantum
information during a short period before transfer to another device.
According to the US National Science Foundation, in 2008 a team of scientists
stored a qubit, for the first time, in the nucleus of an atom of phosphorus. The stored
information remained intact for 1.75 s, a period that theoretically could be extended
by means of error correction methods. This represented a major advance in infor-
mation storage.
In 2009 a team of American researchers led by Robert Schoelkopf of Yale
University created the first quantum processor. This device works in a similar
way to a conventional microprocessor, although it is only capable of performing
very simple arithmetical operations and basic data searches. Communication in this
device was by means of photons confined in the quantum bus.
In 2011, what was claimed to be the first commercial quantum computer—D-
Wave One—was sold by the company D-Wave Systems to Lockheed Martin for US
$10 million. In the same year, IBM announced that it had created a chip that was
stable enough to hold out the promise that quantum computing would soon arrive in
homes and companies. It is expected that, from the date this book has been written,
the first affordable quantum systems will be commercialized in 10 or 12 years.
Research continues despite many technical difficulties. A major brake on the
development of quantum computers is the concept of decoherence (discussed further
below). In 2015, a possible solution was proposed by researchers at Google and the
University of California, Santa Barbara. These researchers showed that they could
program groups of qubits to detect certain types of errors that might disrupt compu-
tation. Although there are still technical issues to be overcome, it is thought that their
solution to quantum decoherence could be an important step towards the develop-
ment of a fully functional quantum computer, technically capable of performing
calculations that would take a conventional computer many thousands of years.
The quantum computing paradigm is different from the classical computation
approach, primarily in the use of qubits instead of bits and in the use of new kinds of
logic gates that make it possible to design and implement new algorithms. Com-
plexity is also different in classical computation and in quantum computation, and
certain problems that cannot be solved using a conventional paradigm become
tractable in a quantum paradigm. In fact, a classical computer is like a classical
Turing machine, and a quantum computer is like a quantum Turing machine.
Whereas in conventional digital computing a bit only takes the values of 0 or
1, in quantum computing a qubit can be 0 or 1 or both simultaneously (two
orthogonal states of the subatomic particle). This coherent superposition makes it
possible to perform several operations simultaneously, with the number of opera-
tions only dependent on the number of qubits, which indicates the number of bits
that can be in superposition.
Let us illustrate with an example. Using three conventional bits, a system can be
in one, and only one, of the eight possible combinations of zeros and ones.
However, for a vector with three qubits, the particle can take the eight different
78 5 Introducing Quantum Computing

values at the same time (the coherent superposition property). The three-bit vector
can thus perform eight parallel operations, which is to say that the number of
operations is exponential in the number of qubits. This parallelism (to which we
will return later) is an intrinsic characteristic of quantum computing.
Quantum computing therefore represents an impressive advance over conven-
tional computing. A quantum computer with 30 qubits, for example, is equivalent to
a conventional processor working at a speed of 10 teraflops (a teraflop is equal to
one trillion floating-point operations per second). Compare this to today’s com-
puters, which work in the order of the gigaflop (one billion floating-point operations
per second).
From a practical perspective, the main focuses of interest are issues related to
physical support, data transmission, quantum algorithm design and quantum
architectures.
The problem of physical support is still unresolved. Quantum computation
requires the following conditions to be satisfied:
1. The system has to be initialized, that is, we have to start from a well-known and
controlled state.
2. It must be possible to manipulate qubits in a controlled way, with operations that
form a universal set of logic gates in order to be able to reproduce any other
possible logic gate.
3. The quantum system has to maintain its quantum coherence throughout the
experiment.
4. It must be possible to read the final state of the system after a computation.
5. The system has to be scalable, so that the number of qubits can be increased to
tackle problems implying a greater computational burden.
As for data transmission, scientists from the Max Planck and Niels Bohr
laboratories have obtained interesting results on the transmission of quantum
information to distances of about 100 km using just beams of light. The results
point to close to 70% success in transmissions.
Quantum algorithms as designed so far—including the Shor, Grover and
Deutsch-Jozsa algorithms—are very reliable and comparable to those used in the
conventional machines of today. Finally, several notable models and architectures
exist, such as the quantum computers proposed by Benioff, Feynman and Deutsch.
Undoubtedly, quantum computing has attracted great interest due to its great
potential. Quantum computers have been proposed as an alternative to classical
computers for solving specific kinds of problems such as the factorization of
integers, discrete logarithm issues and the simulation of quantum systems. Feyn-
man wrote, as far back as 1982, that quantum computers would be effective as
universal simulators of quantum systems; by 1996 Feynman’s conjecture was
shown to be correct. However, as in any emerging discipline, appropriate solutions
still need to be found to many problems.
As mentioned, a major problem is decoherence, which causes the quantum
system to lose its unitary properties; more specifically, quantum algorithm steps
become irreversible. The ratio of errors is proportional to the ratio between the time
5.1 A Brief Overview of Quantum Computing 79

employed to perform a given computation and the decoherence time of the quantum
system, so quantum computations ideally need to be completed in a shorter time
than the decoherence time. However, if errors are few, quantum error correction
procedures can be effectively used and, in this case, the time needed to perform the
computation can be longer that the decoherence time (in theory, even
arbitrarily long).
Another major problem is scalability, especially bearing in mind the large
number of qubits necessary to perform calculations that involve error corrections.
The design of a quantum architecture capable of handling a sufficient number of
qubits is currently a necessary next step for progress in this area.
In order to discuss concepts defining the basic unit of information used in
quantum computing (the qubit), we must first explore Schumacher compression,
which can be considered the quantum analogy of Shannon’s classical information
formula. Benjamin Schumacher, one of the physicists accredited with coining the
term “qubit,” discovered that quantum states can be interpreted as a type of
information and proposed a method for encoding this information and storing it
in the smallest possible number of quantum states.
A qubit is a system with two quantum states that can only be adequately
described by the laws of quantum mechanics. When we make a measurement, the
quantum states of the qubit collapse and the qubit becomes a conventional bit
(a direct consequence of Heisenberg’s uncertainty principle). We can also say that a
qubit is the information contained in a two-state quantum system. In this sense, a
qubit is a unit of quantum information and therefore must be consistent with the
corresponding theory. The concept of qubit is fundamental to quantum computing
and quantum cryptography. Its importance is related to both the amount of infor-
mation contained in a qubit and how this information can be manipulated. Both
these features of a qubit are critical and render it qualitatively different from a
classical bit. Some logic operations performed with qubits are not possible with
bits. The qubit, moreover, is an abstract concept and is not associated with any
particular physical system.
Mathematically, a qubit can be described as a vector of module 1 in a
two-dimensional complex vector space. The two basic states of a qubit—corresponding
to the conventional bits 0 and 1—are ket zero ¼ |0〉 and ket one ¼ |1〉. However,
the qubit can exist in a state of quantum superposition, which is a linear combination of
the two basic states:
jφi ¼ α0 j0iþ α1 j1i

In the above equation, the following restrictions apply to α0 and α1 (called


amplitudes):
• The amplitudes are complex numbers: α0 , α1 2 C
• Quantum mechanics is probabilistic: |α0|2 + |α1|2 ¼ 1
These restrictions imply significant differences compared to the state of a
classical bit, which, as mentioned, can take only the values 0 and 1. The values
represented by a qubit are of a continuous nature.
80 5 Introducing Quantum Computing

Another important question is quantum parallelism, which we briefly referred to


earlier. Parallelism underpins the power of quantum computations, as it allows the
values 0 and 1 to be represented simultaneously. In other words, the quantum
algorithms that operate on states of superposition simultaneously operate on all
combinations of inputs.
Another important feature is that multiple qubits may be present in a state of
quantum entanglement, used to achieve quantum teleportation. Entanglement
allows a system of qubits to be in a state of higher correlation than can be found
in conventional systems of bits. Two qubits that are entangled cannot be
decomposed into independent qubits.
It has been argued that the strangest aspect of quantum information theory is the
concept of quantum information, usually represented by the qubit. A new perspec-
tive on physics complements the geometric perspective—reflecting a quantum
analogy to the classical information theory developed by Shannon. In classical
physics several physical entities are closely related to the concept of information,
for instance, entropy and Maxwell’s demon (a thought experiment). In quantum
mechanics such relationships are even stronger. For example, the no-cloning
theorem, which prevents quantum states from being copied, has profound implica-
tions for quantum computing and is clearly related to Heisenberg’s uncertainty
principle. These peculiarities oblige us to consider certain basic concepts, some
already mentioned, in a new perspective.
The first important concept is that of a quantum register, composed of several
qubits. Quantum computers run quantum algorithms, which perform computations
by means of quantum gates with low computational complexity in time and space.
Another issue to consider is the continuous nature of qubits; whereas bits take
discrete values, qubit values are continuous.
Another important feature, mentioned earlier, is parallelism, reflecting the abil-
ity of quantum systems to simultaneously represent the values 0 and 1. In this
context, and as stated before, quantum algorithms that operate on qubits in quantum
superposition states perform operations simultaneously on all combinations of
inputs.
We also mentioned that multiple qubits can be in a state of quantum Entangle-
ment, a peculiar non-local characteristic. A quantum system of two entangled
qubits cannot be decomposed into independent factors for each of the qubits.
As for quantum computing models, one of the main models is the quantum
circuit, in which a quantum algorithm is represented as a series of quantum logic
gates that act on one or more qubits. A typical example is the CN reversible gate.
Quantum logic gates are different from the gates used in conventional digital
circuits. For one thing, all quantum logic gates are reversible, meaning that the
computation can be reversed through another gate. In practice, this means that the
number of qubits in the output must match the number of qubits in the input.
Finally, each quantum logic gate is represented by a unitary matrix.
5.2 The Formalism of Quantum Computing 81

5.2 The Formalism of Quantum Computing

The classical theory of computation usually did not refer to the physics of the device,
as it was assumed that the theory was independent of actual construction. However,
Deutsch and Feynman, among others, demonstrated that this idea was false by
showing how information and, more precisely, computation, was linked to the laws
of physics. This connection established between two apparently independent fields—
computation and quantum mechanics—was the origin of quantum computing.
Generally speaking, we can say that computation is the creation of sets of
symbols (results) from some other initial sets of symbols (data). If we interpret
the symbols as physical objects, the computation corresponds to the evolution of the
states of the system. If the evolution follows the laws of quantum mechanics, then
we have quantum computing.
The possibility that a quantum Turing machine could do something of a specif-
ically quantum nature was suggested by Richard Feynman in 1982. This is because
the dimension of the Hilbert space accessible to the system increases exponentially
in line with the number of amplitudes that have to be processed and stored.
Accordingly, what Feynman described was a universal quantum simulator of the
behavior of any finite physical system.
Quantum computing is based on the quantum properties of qubits, and qubits
have to be manipulated in accordance with the laws and restrictions of quantum
mechanics. Therefore, before continuing to explore this new computational para-
digm, we need to recall the basic principles and terminology of the quantum
approach, but this time from a more formal perspective.
We will start with the classical model of computation and its basic unit of
information, the bit, with its two values 0 and 1. From a formal point of view, a
bit is an element of the set:

V ¼ f0; 1g

A chain of n bits can be considered to be an element of the Cartesian product:


Vn ¼ V      V

A chain of bits can represent any information, provided we establish a mecha-


nism of coding. An algorithm is a mechanism to manipulate chains of bits; from the
formal point of view we can say that the algorithm evaluates Boolean functions.
Thus, given a chain of n bits α, the algorithm modifies the original chain to generate
another chain of n bits β. If we denote by f the Boolean function of
V n ! V n =f ðαÞ ¼ β

then the algorithm is a mechanism to evaluate f. From a functional perspective, the


algorithm needs to reflect the mechanism for manipulating the chain of bits in order
to represent the problem as a sequence of logic gates. This is because classical
computers are only capable of evaluating logic gates, not generic Boolean
82 5 Introducing Quantum Computing

functions. Recall that the set of logic gates {NOT, OR, AND} is universal and so
allows us to define any Boolean function.
In the quantum computation model the basic unit of information is the qubit,
which can be in two different states, denoted |0〉 and |1〉. Physically a qubit can be
considered to be a quantum system of two states. The best-known quantum system
of two states is the spin of an electron. In a system of this type we can represent the
spin (½) by the state |0〉 and the spin +(½) by the state |1〉.
Formalizing, we will call a qubit the elementary quantum system, that is to say,
the quantum system of two states. Quantum systems of n qubits are described by
means of vectors in a Hilbert space whose dimension is 2n. This allows us to encode
an exponential quantity of information in the state of a quantum system of n qubits.
Any transformation of the state of the system results in the simultaneous modifica-
tion of all the stored information. In order to know the state of a qubit, we have to
interact with it, that is, make a measurement. However, in accordance with
Heisenberg’s uncertainty principle, the measurement of a quantum state is a core
problem for quantum computations. Quantum measurements are not deterministic
and if we measure two identical states the results may not necessarily be the same.
For this reason, measurement in quantum computation is a random experiment.
Now for some formal definitions, starting with the qubit. The qubit is the
simplest non-trivial element in the Hilbert space of wave functions of two dimen-
sions, generated by the kets {|0〉, |1〉}. These kets—elements in the basis space—
are represented as follows:
   
1 0
j0i ¼ ; j 1i ¼
0 1

These two column vectors are orthonormal, which means that under the scalar
(or inner) product 〈x | y〉 defined in the space, they behave as follows:
h0j0i ¼ h1j1i ¼ 1;h0j1i ¼ h1j0i ¼ 0

In these equations the bra row vectors {〈0|, 〈1|} are represented as follows:
h0j ¼ ð1 0Þ;h1j ¼ ð0 1Þ

Thus
 
1
h0j0i ¼ ð1 0Þ  ¼1
0
 
0
h1j1i ¼ ð 0 1Þ  ¼1
1

and
 
0
h0j1i ¼ ð 1 0Þ  ¼0
1
5.2 The Formalism of Quantum Computing 83

 
1
h1j0i ¼ ð 0 1Þ  ¼0
0

However, qubits, in general, are in a state of superposition (or linear combination


of the basic states |0〉 and |1〉), such that, if φ is a qubit, then
jφ〉 ¼ α0 j0〉 þ α1 j1〉

In the above representation, the probability amplitudes α0 and α1 are complex


numbers. As with any measurement in Quantum Mechanics, the square of these
coefficients determines the probability of obtaining, for a measurement, the results
|0〉 or |1〉, respectively. Since the total probability has to sum to 1, α0 and α1 have to
be related through the equation

jα0 j2 þ jα1 j2 ¼ 1

This equation simply ensures that we obtain one state or the other after mea-
surement. Because of its quantum nature, any measurement of the qubit inevitably
alters the state and breaks superposition, resulting in collapse into the basis state
resulting from the measurement, with {α0, α1} transformed irreversibly into {0, 1}.
We will return to this question later.
The qubit may alternatively be described by means of a density matrix. In this
case, for a qubit in state |φ〉, the corresponding operator is as follows:
ρφ ¼ jφi hφj

In contrast with the state vector, the density matrix is clearly defined. Density
matrices describe qubits whose states are not well known (that is, mixed states). In
general, we can write the density matrix of any qubit in the form
!
1 X 3
ρ¼ 1þ ci σ i
2 i¼1

c21 þ c22 þ c23  1

In the above equation, 1 is the identity matrix (22) and σi are the Pauli
matrices, which, in their linear representation for the case of spin ½, take the
following form:
     
0 1 0 i 1 0
σx ¼ ; σy ¼ ; σz ¼
1 0 i 0 0 1
The probability of finding the state |φ〉 after a given measurement is given by
Pφ ¼ hφ jρjφi
84 5 Introducing Quantum Computing

The space of qubit states can be represented by means of a two-dimensional


complex vector space of module 1. Likewise, we can represent points on the surface
of what is called a Bloch sphere. Each state of the qubit corresponds to a point on
the surface of the sphere of radius 1. This essentially means that a qubit has two
degrees of local freedom, which could be length and latitude, or, as is more usual,
two spherical coordinate angles as shown in Fig. 5.1.
An intuitive case for use of the Bloch sphere is that of the particle with spin ½:
the point on the sphere indicates the direction in which the qubit is an eigenfunction
of the projection of the spin.

5.3 Systems of Qubits

The most general normalized one-qubit that can be built is the linear superposition
of two elements of the basis:

jxi ¼ α0 j0iþ α1 j1i; α0 , α1 2 C; jα0 j2 þ jα1 j2 ¼ 1

As mentioned, a qubit can be in two possible states but can also be in interme-
diate states, that is to say, in states that are linear combination of |0〉 and |1〉. Thus,
for example, the spin of an electron can be in the state
 
φ ¼ ð1=2Þj0iþ √3=2 j1i

We conclude, therefore, that a qubit is a vector of the vector space

Fig. 5.1 Spherical


coordinates
5.3 Systems of Qubits 85

V ¼ Lðj0i; j1iÞ

According to quantum mechanics, V is a complex Hilbert space, where


B ¼ ½j0i; j1i

is an orthonormal basis and the states are unitary vectors. A qubit can therefore be in
any state (the coefficients designate amplitudes):

jxi ¼ α0 j0iþ α1 j1i; α0 , α1 2 C; jα0 j2 þ jα1 j2 ¼ 1

It is relatively easy to understand the basis states but not so easy to understand
the intermediate states. Returning to the example of electron spin and analyzing an
intermediate state, the qubit φ does not have a well-defined spin. Remember that the
spin of an electron is a physical magnitude that is quantified, which is why the
intermediate state φ does not have a defined spin.
We return now to the issue of information. The information contained in a qubit
is obviously very small, so, to be able to represent greater amounts of information,
we need n-qubit systems. If we want to describe the state of a system that consists
not only of a qubit but of a set of n qubits, the laws of quantum mechanics tell us
that we have to obtain the tensor product of the n single qubits.
To start with a simple example, suppose that n ¼ 2 represents the spin of a
system of two electrons. The spin of each electron can be in two states. When
combined, four states for the two-qubit system are generated: |00〉, |01〉, |10〉 and
|11〉.
For this two-qubit, the space dimension is 22 and the space basis is as follows:
     
jxi i vj ¼ xi ; vj ¼ xi vj

The relations expressed by this equation allow us to define the basis of the four-
dimensional space as follows:
fj0i j0i; j0i j1i; j1i j0i; j1i j1ig

This can be written in equivalent form as


fj00i; j01i; j10i; j11ig

Like single qubits, a two-qubit can be in an intermediate state, that is to say, it


can be a linear combination of the four previous states. For example, a two-qubit
can be in the state
   
φ ¼ ð1=4Þj00iþ √3=4 j01iþ √3=4 j10iþ ð3=4Þj11i
86 5 Introducing Quantum Computing

Hence, a two-qubit is a vector of the following vector space:

V 2 ¼ Lðj00i; j01i; j10i; j11iÞ

which, according to quantum mechanics, is a complex Hilbert space in which

B2 ¼ ½j00i; j01i; j10i; j11i

This is an orthonormal basis with states that are unitary vectors. Hence, a
two-qubit can be found in any state of the form
φ ¼ α0 j00iþ α1 j01iþ α2 j10iþ α3 j11i
α0 , α1 , α2 , α3 2 C

jα0 j2 þ jα1 j2 þ jα2 j2 þ jα3 j2 ¼ 1

With this description of two-qubit systems now complete, however, we still do


not know the relationship between the vector space V2 and the vector spaces
V associated with the two qubits when considered as independent systems. How-
ever, V2 is the tensor product
VV

The vectors of the basis B2 correspond to the different tensor products of the
vectors of B:

|00〉 = |0〉  |0〉


|01〉 = |0〉  |1〉
|10〉 = |1〉  |0〉
|11〉 = |1〉  |1〉

Assume we have a two-qubit and that this two-qubit is entangled, that is it cannot
be described in terms of the states of the single qubits that compose the system.
From a more formal point of view, this means that the two-qubit cannot be
represented as the tensor product of two states for single qubits. For example, the
two-qubit
   
φ ¼ ð1=4Þj00iþ √3=4 j01iþ √3=4 j10iþ ð3=4Þj11i

is not in an entangled state since it can be written as the tensor product


 pffiffiffi   pffiffiffi 
1 3 1 3
φ¼ j0iþ j 1i  j0iþ j 1i
2 2 2 2
5.3 Systems of Qubits 87

To demonstrate why, let us assume that


φ ¼ φ1  φ2
φ1 ¼ α0 j0iþ α1 j1i
φ2 ¼ β0 j0iþ β1 j1i

Both φ1 and φ2 have to fulfil the normalization condition

jα0 j2 þ jα1 j2 ¼ 1 and jβ0 j2 þ jβ1 j2 ¼ 1

On the other hand


α0  β0 ¼ 1=4

α0  β1 ¼ √3=4

α1  β0 ¼ √3=4
α1  β1 ¼ 3=4

And this system of equations has a solution, for example


pffiffiffi pffiffiffi
1 3 1 3
α0 ¼ ; α1 ¼ ; β0 ¼ ; β1 ¼
2 2 2 2

However, it can easily be verified that the following two-qubit is in an entangled


state:
     
φ ¼ 1=√3 j00iþ 1=√3 j01iþ 1=√3 j10i

In fact, almost all states are entangled. If we choose the coefficients α, β, c and
d (which define points on the sphere of radius 1 centered in the origin in R8) at
random, then the probability of an entangled state is 1.
Let us now try to generalize these ideas. Recall that the most general normalized
two-qubit |x1 x2〉 ¼ |x1〉  |x2〉 that can be built in R8 is the linear superposition of
the four elements of the basis, that is to say
jx1 x2 i ¼ α0 j00iþ α1 j01iþ α2 j10iþ α3 j11i
α0 , α1 , α2 , α3 2 C
2X
2
1
jαi j2 ¼ 1
i¼0
88 5 Introducing Quantum Computing

The generalization of two-qubits to n-qubits is now very simple. An n-qubit is a


unitary vector in the complex Hilbert space
Vn ¼ V      V

where
Bn ¼ ½j0  00〉; j0  01〉; j0  10〉 . . . j1  11〉

is an orthonormal basis called the computational basis. A generic vector of the basis
Bn can be viewed as a tensor product:
jx1 x2 . . . xn 〉 ¼ jx1 i jx2 i     jxn i
x1, x2 . . . xn 2 f0; 1g

Hence, the most general normalized n-qubit


jx1 . . . xn i ¼ jx1 i     jxn i

is nothing other than the linear superposition of the 2n elements of the basis, such
that
2X
n
1 2X
n
1
jx1 ; x2 . . . xn i ¼ αi jii; α0 . . . αn1 2 C; jαi j2 ¼ 1
i¼0 i¼0

In other words, the conjoint state of a system formed by n qubits is described as a


point in the Hilbert space of dimension 2n and is constructed by the tensor product
of the Hilbert spaces of each of the n qubits. We can represent the final state in a
more compact form as
j0100i ¼ j0i1  j1i2  j0i3  j0i4

where the positions or indexes {1–4} indicate each single qubit and the values {0,1}
indicate the state of each single qubit. The direct product between states of single
qubits allows the state of the n-qubit to be constructed, for example
   
1=√2 ðj0〉1 þ j1〉1 Þ  1=√2 ðj0〉2  j1〉2 Þ ¼ ð1=2Þðj00〉  j01〉 þ j10〉  j11〉Þ

Conversely, as stated earlier, we usually cannot do the reverse if the state is


entangled. In other words, there are states of n-qubits—referred to as entangled
states—that cannot be described from the tensor product of the individual states of
each of the n single qubits. By way of an example, let us take a look at the following
two-qubit form of entanglement (the Bell state):
5.3 Systems of Qubits 89

1=√2 fj00iþ j11ig

Decomposing it into single qubits is not possible—and this is precisely why such
states are used in quantum teleportation (discussed further below). What is impor-
tant to note here is that the states of qubits in entangled systems are not independent.
Qubits can be represented in other ways. Increasingly common is a quantum
computation convention, based on the following equivalence:
jx1 x2 . . . xm i  jxi

where x1, x2, . . . xm is the binary representation of the integer x:

x ¼ x1  2m1 þ x2  2m2 þ    þ xm1  21 þ xm  20

Accordingly, the basis of a space of n qubits whose dimension is 2n is formed by


fj0〉; j1〉; j2〉 . . . j2n  1〉g

The chain of bits x1 x2 . . . xn can be interpreted as a natural number x represented


in base 2. The vectors of the basis Bn can therefore be considered as natural numbers
x that fulfil 0  x < 2n (numbers with n binary digits). With the chain of bits x1 x2 . . .
xn denoted by the natural number x, we can write x in the decimal numbering system
as
Bn ¼ ½j0〉; j1〉; j2〉 . . . j2n  1〉

The relationship between basis vectors and chains of n single bits is important
for encoding the information in a given n-qubit. The use of natural numbers reflects
our predilection for using numbers in base 10. With this notation, a general n-qubit
can be written as follows:
2X
n
1 2X
n
1
φ¼ αx jxi; jαx j2 ¼ 1
x¼0 x¼0

Note that the dimension of the space is exponential, specifically 2n. This key
property of quantum parallelism reflects the enormous capacity of n-qubits to store
information. For example, the pair of numbers (131,211) can be encoded as a chain
of 16 bits (eight for each number) that can be represented by means of the 16-qubit
φ1 ¼ j1000001111010011i ¼ j27641i

A 16-qubit can encode much more information. For example, the state
90 5 Introducing Quantum Computing

X
1 65535
φ2 ¼ jxi
256 x¼0

is a linear combination of all the pairs of numbers of eight binary digits from (0,0) to
(255,255) inclusive: the first eight qubits encode the first number of the pair and the
other eight qubits encode the second number in the pair.
To facilitate information encoding, we can group qubits in registers. Formally a
register of size k is a consecutive set of k qubits, which we denote by |x〉, |y〉, |z〉,. . .,
where the numbers x, y, z,. . . are numbers with k binary digits. In the previous
example with 16 qubits, if we say that |x〉 is the complete register of 16 qubits, |y〉 is
the register of the first eight qubits and |z〉 is the register of the last eight qubits. The
states φ1 and φ2 can thus be written as follows:
φ1 ¼ j10000011i j11010011i ¼ j131i j211i

1 X255 X
255
φ2 ¼ jyi jzi
256 y¼0 z¼0

5.4 Qubits and Measurement

We are now going to talk about the problem of measuring qubits. Let us analyze
what happens when we try to measure the following qubit:
 
φ ¼ ð1=2Þj0iþ √3=2 j1i

To make the measurement we will use the device depicted in Fig. 5.2. We will
use electrons as the physical system on which to write information. Measurement
consists of launching the electron through the small hole in the first wall. When the
electron goes through the hole, it encounters a magnetic field that diverts its path
according to its spin until finally it manages to go through one of the two holes in
the second wall.
In the left part of Fig. 5.2, we have pure single qubits and we want the electron to
go through one of the two holes in the second wall. If the electron reaches an
intermediate position between these holes, then its spin is not quantified. In the right
part of Fig. 5.2, the qubit φ is in an intermediate state and so does not have well-
defined spin. In this case, the electron can be deflected downwards or upwards.
Let us try to explain why the electron has a given possibility of exiting through
the upper hole or the lower hole. If it is only possible to exit through one of the
5.4 Qubits and Measurement 91

⎪1〉
⎪0〉
⎪1〉

⎪0〉

⎪1〉 ⎪0〉

⎪1〉

⎪0〉

Fig. 5.2 Measuring the qubits |0〉, |1〉 and |φ〉. Because |φ〉 does not have a well-defined spin,
both the probabilities of exiting through the upper and lower hole in the wall are non-zero

holes, say the upper hole, then this means that the system is in the state |1〉 and the
electron would have a well-defined spin. But if the electron exits through the lower
hole, its spin after measurement can only be –½ and its state is |0〉. Analogously, if
the electron exits through the upper hole, its spin after measurement can only be +½
and its state is |1〉. Measurement, in addition to yielding incomplete information on
the qubit, modifies it. The process of measurement somehow forces the qubit to opt
for one of the two states of the basis.
Once measurement of the qubit has been qualitatively analyzed, it is now
appropriate to quantitatively describe the entire process. Returning to the quantum
mechanical postulates, we establish that the probability P0 or P1 that the final state
of the qubit is |0〉 or |1〉 is equal to the square of the module of the amplitude of |0〉
or |1〉, respectively, in the linear combination of the states of the basis. Thus, for the
qubit φ in the example the final result will be |0〉 with probability P0 ¼ ¼ and |1〉
with probability P1 ¼ ¾. Table 5.1 summarizes the process of measuring a qubit
and the result of the measurement is the conventional bit 0 or 1 if the final state is
|0〉 or |1〉, respectively.
In a two-qubit we can measure either the first or the second qubit (the process in
both cases is similar). Assume we measure the first qubit. The following example
illustrates the process:
     
φ ¼ 1=√3 j00iþ 1=√3 j01iþ 1=√3 j10i

After measurement, the first qubit has to be in state |0〉 or state |1〉. Therefore, the
two-qubit, after measurement, has to be in one of the following states:
92 5 Introducing Quantum Computing

Table 5.1 Summary of the Initial state Measurement Final state Probability
process of measuring a qubit
α |0〉 + β |1〉 0 (α/|α|) |0〉 P0 ¼ |α|2
α |0〉 + β |1〉 1 (β/|β|) |1〉 P1 ¼ |β|2

j0i ½α0 j0iþ α1 j1i ¼ α0 j00iþ α1 j01i


α0 , α1 2 C

jα0 j2 þ jα1 j2 ¼ 1

or
j1i ½β0 j0iþ β1 j1i ¼ β0 j10iþ β1 j11i
β0 , β1 2 C

jβ0 j2 þ jβ1 j2 ¼ 1

However, in order to obtain the state resulting from the measurement, we need to
write φ as the linear combination of two states, φ0 and φ1, in which the first qubit is
in state |0〉 and |1〉, respectively. When we apply the qubit restrictions, we obtain
the following expressions:

φ ¼ αφ0 þ βφ1 ; jαj2 þ jβj2 ¼ 1

φ0 ¼ α0 j00iþ α1 j01i; jα0 j2 þ jα1 j2 ¼ 1

φ1 ¼ β0 j10iþ β1 j11i; jβ0 j2 þ jβ1 j2 ¼ 1

Then

β1 ¼ 0 ðthe state j11〉 is not in φÞ ! β0 ¼ 1 ! β ¼ 1=√3

jαj2 þ jβj2 ¼ 1 ! α2 ¼ 1  ð1=3Þ ¼ 2=3 ! α ¼ √2=√3


   
√2=√3 α0 ¼ 1=√3 ^ √2=√3 α1 ¼ 1=√3 ! α0 ¼ α1 ¼ 1=√2

Therefore
   
φ ¼ √2=√3 φ0 þ 1=√3 φ1
   
φ0 ¼ 1=√2 j00iþ 1=√2 j01i

φ1 ¼ j10i

Accordingly, if the result of the measurement is 0 the final state is φ0 and if 1, φ1.
The probability P0 or P1 that the measure is 0 or 1 is equal to the square of the
5.4 Qubits and Measurement 93

module of the coefficient of φ0 or φ1, respectively. Table 5.2 depicts the measure-
ment process for this particular case.
The probability P0 and the final state φ0 also have another interpretation: φ0 is
the normalized orthogonal projection of φ in the subspace L (|00〉, |01〉), and P0 is
the square of the norm of this projection, that is, the sum of the squares of the
modules of the amplitudes of |00〉 and |01〉 in the state φ. Obviously, the interpre-
tation of P1 and φ1 is analogous. We will illustrate this with some examples.
Let |x〉 be a normalized qubit. If we perform a measurement on the basis {|u0〉,
|u1〉}, the probability of finding the qubit in the state |ui〉, denoted P(|ui〉), is
given by

Pðjui 〉Þ ¼ jhui j xij2

The measurement of the qubit |x〉 ¼ α0 |0〉 + α1 |1〉 in the canonical basis {|0〉,
|1〉} generates the following probabilities:

Pðj0iÞ ¼ jh0jxij2 ¼ jh0jðα0 j0iþ α1 j1iÞj2


¼ jα0h0j0iþ α1h0j1ij2 ¼ jα0 j2
Pðj1iÞ ¼ jh1jxij2 ¼ jh1jðα0 j0iþ α1 j1iÞj2
¼ jα0h1j0iþ α1h1j1ij2 ¼ jα1 j2

The measurement of the qubit |x〉 ¼ α0 |0〉 + α1 |1〉 in the non-canonical basis
{|0〉 + |1〉, |0〉  |1〉} generates the following probabilities:

Pðj0iþ j1iÞ ¼ jðh0j þh1jÞjxij2 ¼ jðh0j þh1jÞðα0 j0iþ α1 j1iÞj2


¼ jα0h0j0iþ α1h0j1iþ α0h1j0iþ α1h1j1ij2 ¼ jα0 þ α1 j2
Pðj0i j1iÞ ¼ jðh0j h1jÞjxij2 ¼ jðh0j h1jÞðα0 j0iþ α1 j1iÞj2
¼ jα0h0j0iþ α1h0j1i α0h1j0i α1h1j1ij2 ¼ jα0  α1 j2

The measurement of the qubits of the two-qubit


jx1 x2 〉 ¼ α0 j00〉 þ α1 j01〉 þ α2 j10〉 þ α3 j11〉

on the basis {|0〉, |1〉} generates the following probabilities:


• Probability of finding the first qubit in state |0〉 ! P1(|0〉)
• Probability of finding the first qubit in state |1〉 ! P1(|1〉)

Table 5.2 Process of measuring the qubit: φ ¼ (1/√3) |00〉 + (1/√3) |01〉 + (1/√3) |10〉
Initial state Measurement Final state Probability
φ ¼ (1/√3) |00〉 + (1/√3) |01〉 + (1/√3) |10〉 0 φ0 ¼ (1/√2) |00〉 + P0 ¼ 2/3
(1/√2) |01〉
φ ¼ (1/√3) |00〉 + (1/√3) |01〉 + (1/√3) |10〉 1 φ1 ¼ |10〉 P1 ¼ 1/3
94 5 Introducing Quantum Computing

• Probability of finding the second qubit in state |0〉 ! P2(|0〉)


• Probability of finding the second qubit in state |1〉 ! P2(|1〉)
These probabilities are given by

P1 ðj0〉Þ ¼ jα0 j2 þ jα1 j2


P1 ðj1〉Þ ¼ jα2 j2 þ jα3 j2
P2 ðj0〉Þ ¼ jα0 j2 þ jα2 j2
P2 ðj1〉Þ ¼ jα1 j2 þ jα3 j2

After the first qubit of the two-qubit is measured


jx1 x2 〉 ¼ α0 j00〉 þ α1 j01〉 þ α2 j10〉 þ α3 j11〉

If we obtain the state |0〉, then the two-qubit evolves to a new normalized state
given by
α0 j00〉 þ α1 j01〉
jx0 y0 〉 ¼ qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
jα0 j2 þ jα1 j2

If we obtain the state |1〉, then the two-qubit evolves to a new normalized state
given by
α2 j10〉 þ α3 j11〉
jx0 y0 〉 ¼ qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
jα2 j2 þjα3 j2

Similar expressions are obtained for the results of measurement of the second
qubit of the two-qubit.
Generalizing these ideas, in a system of n qubits we can measure any one of the
qubits, for example, the k-th qubit. The process, analogous to that for a two-qubit
system, can be described according to the following equations:
2X
n
1
Initial state ¼ αx j x〉; Measurement ¼ 0
x¼0

1 X
Final state ¼ φ0 ¼ pffiffiffiffiffi αx j x〉
P0 x¼0
0  x < 2n
X
P0 ¼ jαx j2
x¼0
0  x < 2n
5.5 Putting It All Together 95

2X
n
1
Initial state ¼ αx j x〉; Measurement ¼ 1
x¼0

1 X
Final state ¼ φ1 ¼ pffiffiffiffiffi αx j x〉
P1 x¼1
0  x < 2n
X
P1 ¼ jαx j2
x¼1
0  x < 2n

5.5 Putting It All Together

We have already mentioned that a particular and non-intuitive characteristic of


quantum systems is entanglement. The existence of entangled quantum states
means that the entire state of a quantum system cannot always be described by
means of a description of its primary elements.
A quantum state of n qubits is entangled if it cannot be expressed as the tensor
product of the states of each of the n constituent qubits. Let us now consider two
qubits |x〉 and |y〉 described by the expressions
jx〉 ¼ α j0〉 þ β j1〉
jy〉 ¼ c j0〉 þ d j1〉

such that α, β, c, d 2 C.
The tensor product of these two qubits generates the two-qubit
jxi jyi ¼ jx; yi ¼ ðαj0iþ βj1iÞ  ðcj0iþ dj1iÞ
¼ αc j0; 0iþ αdj0; 1iþ βcj1; 0iþ βdj1; 1i

A system of two qubits is entangled if it cannot be expressed in the form of the


previous equation. Thus, the system
jφi ¼ 1=2 ðj0; 0i j0; 1iþ j1; 0i j1; 1iÞ

is not in an entangled state because the system of equations


αc ¼ þ1=2; αd ¼ 1=2; βc ¼ þ1=2; βd ¼ 1=2
96 5 Introducing Quantum Computing

has the solution


1
α ¼ β ¼ c ¼ pffiffiffi
2
1
d ¼ pffiffiffi
2

and therefore
1
jφi ¼ ðj00i j01iþ j10i j11iÞ
2
   
1 1 1 1
¼ pffiffiffij0iþ pffiffiffij1i  pffiffiffij0i pffiffiffij1i
2 2 2 2

However, the system


 
1 1
jφi ¼ pffiffiffij01iþ pffiffiffij10i
2 2

is entangled because the system of equations


1 1
αc ¼ 0; αd ¼ pffiffiffi ; βc ¼ pffiffiffi ; βd ¼ 0
2 2

does not have a solution. Surprisingly, however, the analysis of the behavior of a
quantum system when measurement is made allows the observer to verify whether
or not the system is entangled. Thus, a system is entangled if the measurement of
one of its components affects the measurement of the other components, and
otherwise it is not entangled. To illustrate these ideas with some examples, consider
the following non-entangled system:
jφ〉 ¼ 1=2 ðj0; 0〉  j0; 1〉 þ j1; 0〉  j1; 1〉Þ

The probabilities after measurement of the first qubit (P1) and the second qubit
(P2) are as follows:
1
P1 ðj0〉Þ ¼ P1 ðj1〉Þ ¼ P2 ðj0〉Þ ¼ P2 ðj1〉Þ ¼
2

Therefore, as we saw above, after measuring the first qubit


• If we obtain the state |0〉, then the system evolves to the new normalized state
5.5 Putting It All Together 97

1
jφ〉 ¼ pffiffiffi ðj00〉  j01〉Þ
2

• If we obtain the state |1〉, then the system evolves to the new normalized state

1
jφ〉 ¼ pffiffiffi ðj10〉  j11〉Þ
2

In both cases the probabilities of measurement of the second qubit are


P2 ðj0〉Þ ¼ P2 ðj1〉Þ ¼ 1=2

In other words, the measurement of the first qubit does not affect the measure-
ment of the second qubit. But what happens when we measure an entangled system?
Consider the following:
1
jφ〉 ¼ pffiffiffi ðj01〉þj10〉Þ
2

The probabilities of the measurements are


1
P1 ðj0iÞ ¼ P1 ðj1iÞ ¼ P2 ðj0iÞ ¼ P2 ðj1iÞ ¼
2

However, if after measuring the first qubit we obtain |0〉, then the system evolves
to the new normalized state
jφ〉 ¼ j01〉

and the probabilities of measurement of the second qubit are


P2 j0〉 ¼ 0; P2 j1〉 ¼ 1

However, if after measuring the first qubit we obtain |1〉, then the system evolves
to the new normalized state
jφ〉 ¼ j10〉

and the probabilities of measurement of the second qubit are


P2 j0〉 ¼ 1; P2 j1〉 ¼ 0

In this case the measurement of the first qubit affects the measurement of the
second qubit.
98 5 Introducing Quantum Computing

5.6 Constructing Algorithms with Qubits

In the quantum model of computation an algorithm is a mechanism to manipulate n-


qubits. One way to do this is to measure qubits and the second way is to transform
an initial state φ1 into its corresponding final state φ2. The dynamic evolution of
an n-qubit is determined by unitary operators U in a Hilbert space, which have
to be considered as evolution operators. If we denote by U the function of Vn ! Vn
such that
Uφ1 ¼ φ2

then the application U transforms states into states, that is to say, it preserves the
norm and, according to the postulates of quantum mechanics, is linear. Therefore,
U can only be a unitary transformation, i.e., a linear operator whose inverse is its
adjoint, and the following property applies:

U{ U ¼ I

But no quantum computer is capable of applying a generic unitary transforma-


tion. It therefore has to be described as a sequence of elementary unitary trans-
formations through quantum gates. Hence, a quantum algorithm is a finite sequence
of quantum gates and quantum measurements.
In the definition of quantum algorithms, two restrictions need to be considered.
The first restriction affects the initial state, which must always be the same, that is,
φ1 ¼ |0〉. The second restriction is that quantum gates and quantum measurements
cannot alternate. Therefore, a sequence of quantum gates is first applied, followed
by a sequence of quantum measurements. These restrictions have the advantage of
simplifying quantum algorithms without affecting the computational model.
The No-Cloning Theorem

A major difference between quantum and classical computation models is related to


the nature of logic gates. Quantum gates, as unitary transformations, are bijections,
unlike conventional logic gates. The most important consequence of this property is
that quantum states cannot be copied: the no-cloning theorem. To copy an n-qubit
we need to find a unitary transformation U that fulfils the following:
Uðjxi j0iÞ ¼ jxi jxi, 8 0  x < 2n

In the above equation, the two registers have n qubits. The transformation, if it
exists, has to produce the following result:
U ðφ  j0iÞ ¼ φ  φ

However, the transformation U does not exist for all n-qubits φ. To understand
why, let us assume that U is a unitary transformation in a space of dimension 2n
such that
5.6 Constructing Algorithms with Qubits 99

U ðjαi j0iÞ ¼ jαi jαi


U ðjβi j0iÞ ¼ jβi jβi
α 6¼ β; 0  α, β < 2n

Also consider the following n-qubit:


 
φ ¼ 1=√2 ðjαiþ jβiÞ

Accordingly
 
U ðφ  j0iÞ ¼ 1=√2 ðU ðjαi j0iÞ þ U ðjβi j0iÞÞ
 
¼ 1=√2 ðjαi jαiþ jβi jβi Þ 6¼ φ  φ

The conclusion is clear: it is not possible to duplicate qubits.


Operations with Qubits

Consider an n-qubit |φ〉(t) ¼ |x1 . . . xn〉 and assume that the evolution of the quantum
system in a computation step, and after application of the operator U, is given by
Ujφð0Þ〉 !jφð1Þ〉

Also assume that, in general, the evolution of m computation steps is given by


Um jφð0Þ〉 !jφðmÞ〉

In the context of quantum computations, an evolution operator that operates on


an n-qubit is a unitary matrix of dimension 2n. Above we said that computation is
the creation of sets of symbols (results) from other initial sets of symbols (or data).
If we interpret the symbols as physical objects, then computation corresponds to the
evolution of the states of the system. We have already seen that, in quantum
computation, these evolutions are brought about by unitary operators. But—most
importantly—such unitary operators are the matrix representations of reversible
logic quantum gates, with which we can build quantum circuits.
Unlike conventional logic gates, which can operate from n-bits to m-bits,
quantum gates have to operate from n-qubits to n-qubits. However, this is a
necessary but not sufficient condition for the reversibility of quantum gates, a
consequence of the unitary nature of quantum operators. Assuming Uf is the unitary
matrix associated with a gate f, given the generic states |x〉, |y〉, we can write

Uf jxi ¼ jyi ) U{f U f jxi ¼ U{f jyi ) jxi ¼ U{f jyi


100 5 Introducing Quantum Computing

This means that the input information can be obtained from the output informa-
tion. Thus, from a function f of n bits to m bits a reversible function, fReversible, can
be built from m + n bits to m + n bits as follows:
f : x ! f ðxÞ ) f Reversible ; ðx; yÞ ! ðx; y f ðxÞÞ

In the above expression x has n bits, and y and f(x) both have m bits.
A function f can thus be implemented by means of a quantum circuit Uf provided
it fulfils the reversibility conditions. Uf performs the following transformation:
Uf jx, y〉 !jx, y f ðxÞ〉

Each quantum gate of n qubits can be represented by a unitary matrix of


dimension 2n, where the transformation performed by the quantum gate is accom-
plished by the associated matrix operator. Bearing in mind the transformation
performed by a quantum gate on the elements of the space basis, the associated
unitary matrix is described as follows:
• The matrix rows correspond to the basic input vectors.
• The matrix columns correspond to the basic output vectors.
• Matrix position ( j, i) , when the basic vector i is the gate input, corresponds to
the coefficient of the basic vector j in the gate output.

Unitary One-Qubit Transformations

The quantum gates that operate on a one-qubit (one qubit of input and one qubit of
output) have associated 22 matrices. We have already seen that, in order to
represent the kets 0 and 1 as vectors, the criteria are as follows:
   
1 0
j0〉 ¼ ; j1〉 ¼
0 1

Below we will perform operations with some of these gates, beginning with
identity (I ). Although the behavior of I does not modify the qubit on which it
acts, it is useful to illustrate how the associated unitary matrix is constructed.
The transformation that implements this gate and its unitary matrix are as
follows:
UIdentity j0〉 ! j0〉
UIdentity j1〉 ! j1〉

 
 ji j0i j1i   
  1 0
 j0i 1 
0  ! UIdentity ¼ 0
 1
 j1i 0 1 
5.6 Constructing Algorithms with Qubits 101

The behavior of the unitary I matrix is as follows:


     
1 0 1 1
UIdentity j0〉 ¼  ¼ ¼ j0〉
0 1 0 0
     
1 0 0 0
UIdentity j1〉 ¼  ¼ ¼ j1〉
0 1 1 1

We will now consider the behavior of the Hadamard gate, H, which transforms a
one-qubit into a superposition of the elements of the basis {|0〉, |1〉}. The descrip-
tion and transformations implemented by the Hadamard gate are as follows:
1
U Hadamard j0〉 ! pffiffiffi ðj0〉 þ j1〉Þ
2
1
U Hadamard j1〉 ! pffiffiffi ðj0〉  j1〉Þ
2

 
 ji j0i j1i 

   
 1 1  1 þ1 þ1
 j0i þpffiffiffi þpffiffiffi 
 2 2 ! U ¼ p ffiffi

2 þ1 1
Hadamard

 1 1 
 j1i þpffiffiffi pffiffiffi 
 2 2
    
1 þ1 þ1 1 1 þ1 1
UHadamard j0〉 ¼ pffiffiffi ¼ pffiffiffi ¼ pffiffiffi ðj0〉þj1〉Þ
2 þ1 1 0 2 þ1 2
    
1 þ1 þ1 0 1 þ1 1
UHadamard j1〉 ¼ pffiffiffi ¼ pffiffiffi ¼ pffiffiffi ðj0〉j1〉Þ
2 þ1 1 1 2 1 2

Other interesting gates are negation (N ), phase change (Z ) and negation with
phase change (Y ), expressed as follows:
 
0 1
N ! N j0〉 ¼j1〉; N j1〉 ¼j0〉 ! N ¼
1 0
 
1 0
Z ! Zj0〉 ¼j1〉; Z j1〉 ¼ j1〉 ! Z ¼
0 1
 
0 1
Y ! Y j0〉 ¼ j1〉; Y j1〉 ¼j0〉 ! Y ¼
1 0
102 5 Introducing Quantum Computing

The I and N matrices and the matrices associated with the transformations iY
and Z (the Pauli matrices referred to earlier in this chapter) are used to transport
quantum states and to build quantum corrector codes. In quantum algorithms the
most important transformations are H and N.
The following example illustrates how, using parametric quantum gates, to
obtain the transformation that results in a quantum gate on the elements of the
basis. Assume that
0    1
θ θ
B cos sin C
B 2 2 C
U ðθ Þ ¼ B    C
@ θ θ A
 sin cos
2 2

The behavior of this matrix regarding the elements of the basis {|0〉, |1〉} is as
follows:
0    1 0   1
θ θ θ
B cos 2 sin C   B cos
B 2 C 1 B 2 C C
UðθÞj0i ¼ B    C  ¼B  C
@ θ θ A 0 @ θ A
 sin cos  sin
2 2 2
   
θ θ
¼ cos j0〉  sin j1〉
2 2

0    1 0  1
θ θ θ
B cos 2 sin C   B sin 2 C
B 2 C 0 B C
UðθÞj1i ¼ B    C  ¼B  C
@ θ θ A 1 @ θ A
 sin cos cos
2 2 2
   
θ θ
¼ sin j0〉 þ cos j1〉
2 2

The transformation of the quantum gate U(θ) is as follows:


   
θ θ
U ðθÞj0i ¼ cos j0i sin j 1i
2 2
   
θ θ
U ðθÞj1i ¼ sin j0iþ cos j 1i
2 2
5.6 Constructing Algorithms with Qubits 103

Obviously, U(θ) can modify different states of qubits. It is therefore very useful
in the following transformation:
 
   
θ θ
U ðθÞ cos j0i sin j 1i
2 2
0    1 0   1
θ θ θ
B cos 2 sin C B cos C
¼B   2  C  B 2  C
@ θ θ A @ θ A
 sin cos  sin
2 2 2
 
cos ðθÞ
¼ ¼ cos ðθÞj0〉  sin ðθÞj1〉
 sin ðθÞ

This equation can easily be understood in terms of trigonometric relations:

sin ðα þ βÞ ¼ sin ðαÞ  cos ðβÞ þ cos ðαÞ  sin ðβÞ


sin ðα  βÞ ¼ sin ðαÞ  cos ðβÞ  cos ðαÞ  sin ðβÞ
cos ðα þ βÞ ¼ cos ðαÞ  cos ðβÞ  sin ðαÞ  sin ðβÞ
cos ðα  βÞ ¼ cos ðαÞ  cos ðβÞ þ sin ðαÞ  sin ðβÞ
sin ð2αÞ ¼ 2  sin ðαÞ  cos ðαÞ

cos ð2αÞ ¼ cos 2 ðαÞ  sin 2 ðαÞ

Above we said that transformation matrices, or operators, for quantum compu-


tations are unitary. In general, the nature of the matrix associated with a quantum
gate M allows us to build a new quantum gate M{ whose matrix is the Hermitian
conjugate matrix (M{) of M. Formally speaking, this is the reversibility property of
quantum gates. To verify this last statement, let us return to the Hermitian conjugate
matrix of U(θ) represented above, and also to the transformation performed by the
corresponding gate U{(θ).
   
θ θ
U { ðθÞj0〉 ! cos j0〉 þ sin j1〉
2 2
   
{ θ θ
U ðθÞj1〉 !  sin j0〉 þ cos j1〉
2 2
104 5 Introducing Quantum Computing

0    1
θ θ
B cos  sin
B 2 2 C
C
U{ ðθÞ ¼ B     C
@ θ θ A
sin cos
2 2

The interesting issue here is that, for the construction of certain quantum circuits,
the following transformations by U{(θ) are very useful:
0    1
θ θ
B cos 2  sin  
{ B 2 CC cos ðθÞ
U ðθÞð cos ðθÞj0〉  sin ðθÞj1〉Þ ¼ B     C
@ θ θ A  sin ðθÞ
sin cos
2 2
0   1
θ
B cos 2 C
B C
¼B  C
@ θ A
 sin
2
0    1 0   1
θ θ θ
      B cos  sin C B cos
θ θ B 2 2 C B 2 C C
U { ðθÞ cos j0〉  sin j1〉 ¼ B     CB  C
2 2 @ θ θ A @ θ A
sin cos  sin
2 2 2
 
1
¼ ¼ j0〉
0

Again, to fully understand this, it is useful to recall the trigonometric relations


listed above. Note that by now we are ready to build a generalized unitary 22
matrix. In fact, all unitary 22 matrices can be factorized using the four matrices
represented as follows:
0    1
iðδþα2þβ2Þ θ iðδþα2β2Þ θ
B e cos e sin
2 C
B 2 C
Uðα; β; δ; θÞ ¼ B    C
@ iðδαþβÞ θ θ A
eiðδ22Þ cos
α β
e 2 2 sin
2 2
0    1
! θ θ 0 1
 iδ  i
α B cos sin C i
β
e 0 e2 0 B 2 2 C e2 0 A
¼  α B    C  @ β
0 eiδ 0 e i2 @ θ θ A i
 sin cos 0 e 2
2 2

To conclude this discussion of unitary transformations of a one-qubit, we define


the matrix Ry(θ), useful in the construction of certain quantum circuits:
5.6 Constructing Algorithms with Qubits 105

0    1
θ θ
B cos 2 sin
2 C
B C
Ry ðθÞ ¼ B    C
@ θ θ A
 sin cos
2 2

Unitary Transformations of Two-Qubits

Before we turn to systems of two qubits, first recall that a two-qubit system |x, y〉 is
built from the tensor product |x〉  |y〉. Therefore, considering the vectors of the
basis |0〉 and |1〉, we have that
   
1 0
j0〉 ¼ ; j1〉 ¼
0 1
0 1
    1
1 1 B0C
j0i j0i ¼ j00i ¼  ¼B @0A
C
0 0
0
0 1
    0
1 0 B1C
j0i j1i ¼ j01i ¼  ¼@ C
B
0 1 0A
0
0 1
    0
0 1 B0C
j1〉j0〉 ¼ j10〉 ¼  ¼B @1A
C
1 0
0
0 1
    0
0 0 B0C
j1i j1i ¼ j11i ¼  ¼B @0A
C
1 1
1

The matrices required for unitary transformations in two-qubit systems have to


be matrices of dimension 44. To better understand this, recall some of the issues
raised regarding reversibility, including the exchange operator EX, which switches
two lines as illustrated in Fig. 5.3 and Table 5.3.
Recall that the truth table associated with this reversible gate is the one shown in
Table 5.3.
A and B represent inputs and C and D represent outputs. With conventional bits
EX behaves as follows:

EX (0,0) ! (0,0); EX (0,1) ! (1,0)


EX (1,0) ! (0,1); EX (1,1) ! (1,1)
106 5 Introducing Quantum Computing

Fig. 5.3 The exchange


operation, EX, again

Table 5.3 Truth table for the EX A B C D


exchange operation, EX
0 0 0 0
0 1 1 0
1 0 0 1
1 1 1 1

It is not difficult to see that if we substitute the bits with qubits, the transforma-
tion of EX will take the following form:
U Ex j00〉 ! j00〉; U Ex j01〉 ! j10〉
U Ex j10〉 ! j01〉; U Ex j11〉 ! j11〉

In terms of unitary matrices the previous expressions are no other than:

EX 00 01 10 11
1 0 0 0
00 1 0 0 0
0 0 1 0
01 0 0 1 0 U EX
0 1 0 0
10 0 1 0 0
0 0 0 1
11 0 0 0 1

0 1 0 1 0 1
1 0 0 0 1 0 0 0 1 0 0 0
B0 0 1 0C B0 0 1 0C B0 1 0 0C
UEX  UEX ¼B
@0
CB C¼B C ¼ UI
1 0 0A @0 1 0 0A @0 0 1 0A
0 0 0 1 0 0 0 1 0 0 0 1

U{EX ¼ UEX
5.6 Constructing Algorithms with Qubits 107

The two last conditions ensure the reversibility of this gate and also its coherence
with the postulates of quantum mechanics. Obviously
0 1 0 1 0 1
1 0 0 0 1 1
B0 0 1 0C B0C B0C
UEx j00i ¼ B C B C B C
@ 0 1 0 0 A  @ 0 A ¼ @ 0 A ¼ j00i
0 0 0 1 0 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 0 1 0C B1C B0C
UEx j01i ¼ B C B C B C
@ 0 1 0 0 A  @ 0 A ¼ @ 1 A ¼ j10i
0 0 0 1 0 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 0 1 0C B0C B1C
UEx j10i ¼ B C B C B C
@ 0 1 0 0 A  @ 1 A ¼ @ 0 A ¼ j01i
0 0 0 1 0 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 0 1 0C B0C B0C
UEx j11i ¼ B C B C B C
@ 0 1 0 0 A  @ 0 A ¼ @ 0 A ¼ j11i
0 0 0 1 1 1

Another gate analyzed in the discussion about reversibility was the CN gate,
whose truth table is represented in Table 5.4.
We also said that that one can interpret |Bout〉 as the output of an XOR gate, with
inputs |Ain〉 and |Bin〉 in such a way that |Bout〉 ¼ XOR (|Ain〉, |Bin〉). . . However,
recall that the device is not the same, since the CN gate generates two outputs
instead of one. In quantum terms
U XOR jx, y〉 ! jx, x y〉

U XOR 00 01 10 11
1 0 0 0
00 1 0 0 0
0 1 0 0
01 0 1 0 0 U XOR
0 0 0 1
10 0 0 0 1
0 0 1 0
11 0 0 1 0
108 5 Introducing Quantum Computing

Table 5.4 Truth table for the |A〉 |B〉 |A0 〉 |B0 〉
CN operation
|0〉 |0〉 |0〉 |0〉
|0〉 |1〉 |0〉 |1〉
|1〉 |0〉 |1〉 |1〉
|1〉 |1〉 |1〉 |0〉

U XOR j0; 0i ! j0; 0 0i ! j0; 0i


U XOR j0; 1i ! j0; 0 1i ! j0; 1i
U XOR j1; 0i ! j1; 1 0i ! j1; 1i
U XOR j1; 1i ! j1; 1 1i ! j1; 0i
0 1 0 1 0 1
1 0 0 0 1 1
B0 1 0 0C B0C B0C
UXOR j00〉 ¼ B C B C B C
@ 0 0 0 1 A  @ 0 A ¼ @ 0 A ¼ j00〉
0 0 1 0 0 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 1 0 0C B1C B1C
UXOR j01〉 ¼ B C B C B C
@ 0 0 0 1 A  @ 0 A ¼ @ 0 A ¼ j01〉
0 0 1 0 0 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 1 0 0C B0C B0C
UXOR j10〉 ¼ B C B C B C
@ 0 0 0 1 A  @ 1 A ¼ @ 0 A ¼ j11〉
0 0 1 0 0 1
0 1 0 1 0 1
1 0 0 0 0 0
B0 1 0 0C B0C B0C
UXOR j11〉 ¼ B C B C B C
@ 0 0 0 1 A  @ 0 A ¼ @ 1 A ¼ j10〉
0 0 1 0 1 0

The CN gate is usually represented by one of the circuits illustrated in Fig. 5.4.
This gate can also act on a qubit formed from any linear combination of qubits.
The change in the second qubit is controlled by the first qubit, as is shown in the
following example:
5.6 Constructing Algorithms with Qubits 109

| x> | x> | x> | x>

xor
| y> | x + y> | y> | x + y>

Fig. 5.4 Representations of the CN gate

0 1
1 0 0 0
B0 1    
B 0 0C
C 1 α
U XOR ðj0i ðαj0iþ βj1iÞÞ ¼B C 
@0 0 0 1A 0 β
0 0 1 0
0 1 0 1 0 1
1 0 0 0 α α
B0 1 0 0C BβC BβC
C B C B
B C
¼B CB C¼B C
@0 0 0 1A @0A @0A
0 0 1 0 0 0
   
1 α
¼  ¼ j0i ðαj0iþ βj1iÞ
0 β

0 1
1 0 0 0    
B0 1 0 0C 0 α
U XOR ðj1i ðαj0iþ βj1iÞÞ ¼ B
@0 0 0 1A
C 
1 β
0 0 1 0
0 1 0 1 0 1
1 0 0 0 0 0
B0 1 0 0C B0C B0C
¼B C B C B C
@0 0 0 1A  @αA ¼ @βA
0 0 1 0 β α
   
0 β
¼  ¼ j1i ðβj0iþ αj1iÞ
1 α

As can be verified from the results, if the first qubit is 0 the second qubit does not
change, but if the first qubit is 1 the second qubit exchanges its coefficients.
Constructing Quantum Circuits

We will now build a quantum circuit reflecting the architecture of the unitary
transformation of qubit exchange (EX). Three CN gates are needed, each of
which performs a quantum XOR. The corresponding circuit is illustrated in Fig. 5.5.
110 5 Introducing Quantum Computing

Fig. 5.5 Construction of an |x> |y>


EX by means of three CN
gates
|y> |x>

The operation of this circuit is as follows:


jx; y〉 !jx, x y〉 ! jðx yÞ x; x y〉 ¼jy, x y〉
! jy; y ðx yÞ〉 ¼jy, x〉

The steps to build the unitary 44 matrix that represents the exchange of two
qubits are as follows:
The first subcircuit performs the transformation
jx; yi ! jx; x yi

that corresponds to the quantum gate XOR whose unitary matrix is


0 1
1 0 0 0
B0 1 0 0C
m1 ¼ UXOR ¼ B@0 0 0 1A
C

0 0 1 0

The second subcircuit performs the transformation


jx; yi ! jy x; yi

Since the second qubit is now the control qubit, the transformation that yields the
subcircuit and associated unitary matrix is as follows:
j00〉 ! j00〉; j01〉 ! j11〉; j 10〉 ! j10 〉; j11〉 ! j01〉
0 1
1 0 0 0
B0 0 0 1C
m2 ¼ B
@0 0 1 0A
C

0 1 0 0

The third subcircuit is similar to the first subcircuit and matrix m3 is equal to
matrix m1. The matrix UEX corresponding to the exchange circuit for two qubits is
therefore
5.6 Constructing Algorithms with Qubits 111

UEX ¼ ðm1  m2 Þ  m3
20 1 0 13 0 1
1 0 0 0 1 0 0 0 1 0 0 0
6B 0 1 0 0 C B 0 0 0 1C 7 B 0C
6B
¼ 4@ C  B C7  B 0 1 0 C
0 0 0 1A @0 0 1 0 A5 @ 0 0 0 1A
0 0 1 0 0 1 0 0 0 0 1 0
0 1
1 0 0 0
B0 0 1 0C
¼B@0 1 0 0A
C

0 0 0 1

This result is exactly the same as that obtained analytically for the transforma-
tion UEX.
To conclude this section, we will analyze the quantum behavior of the reversible
CCN (Toffoli) gate, already referred to in the discussion on reversible computation.
Recall the universal nature of this gate. The {AND, NOT} set of logic gates and the
NAND gate are universal because they allow us to implement any function of the
type
f : f0; 1gn ! f0; 1gm

With reversible gates of one or two lines, it is not possible to obtain a set of
universal gates for reversible functions of the form
f : f0; 1gn ! f0; 1gn

However, we can do so using the CCN gate, which operates on three lines as
follows:
ANDðx; yÞ ! x ^ y ) Toffoliðx; y; zÞ ! ðx; y; z ðx ^ yÞÞ

The universal character of the CCN gate, whose truth table is shown in Table 5.5,
is demonstrated below. Remember that this gate can act like an AND or NOT or
XOR or I gate.
Clearly
z ðx ^ yÞ ¼ x ^ y ; if z¼0
¼x z ; if y¼1
¼ Øz ; if x¼y¼1
¼z ; if x ¼ 0, y ¼ 1
112 5 Introducing Quantum Computing

Table 5.5 Truth table for the L


X Y Z Z (X ^ Y )
CCN gate
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0

Fig. 5.6 Construction of a


CCN quantum gate using
different kinds of gates

Ry(π/4) Ry(π/4) Ry*(π/4) Ry*(π/4)

The CCN gate can be viewed as a quantum circuit with its corresponding unitary
matrix:
0 1
1 0 0 0 0 0 0 0
B0 1 0 0 0 0 0 0C
B C
B0 0 1 0 0 0 0 0C
B C
B0 0 0 1 0 0 0 0C
UToffoli ¼ B
B0 0 0 0 1 0 0 0C
C
B C
B0 0 0 0 0 1 0 0C
B C
@0 0 0 0 0 0 0 1A
0 0 0 0 0 0 1 0

Although the quantum CCN gate is a three-qubit gate, it can be implemented by


means of a quantum circuit that only uses one-qubit and two-qubit quantum gates.
Simplifying, it can be decomposed into a quantum circuit formed of six XOR gates
and eight one-qubit gates. Simplifying even further, if we can make a phase change,
the gate can be built as shown in Fig. 5.6.
The implementation of the CCN gate with one-qubit and two-qubit quantum
gates uses Ry(π/4) gates and their adjoints—whose unitary matrices were described
above—and XOR quantum gates. Below we analyze the behavior of this device in
three of the eight possible cases.

First Case: Input ¼ |0, 0, 0〉

Step 0: The initial values of the kets |x〉, |y〉, |z〉 are |0〉, |0〉, |0〉, respectively,
with which we configure the initial quantum state
5.6 Constructing Algorithms with Qubits 113

j0i j0i j0i ¼ j0; 0; 0i

Step 1: The first Ry gate acts on the ket |z〉 ¼ |0〉, as seen earlier:
0 π π 1 0 π 1
π cos sin   cos
B C 1 B C
Ry j0i ¼ @ 8π 8π A  ¼@ 8π A
4  sin cos 0  sin
8 8 8
π π
¼ cos j0i sin j 1i
8 8

The new quantum state is


        
θ θ θ θ
j0i j0i cos j0i sin j1i ¼ cos j0; 0; 0i sin j0; 0; 1i
8 8 8 8

Step 2: The first CN gate performs an XOR between the kets of the lines |y〉 ¼
|0〉, |z〉 ¼ cos (π/8) |0〉  sin (π/8) |1〉:
n π π o π π
jyi jzi ¼ j0i cos j0i sin j1i ¼ cos j0i sin j 1i
8 8 8 8

The new quantum state is


n π π o
j0i j0i j0i cos j0i sin j 1i
8 8
π π
¼ cos j0; 0; 0i sin j0; 0; 1i
8 8

Step 3: The second Ry gate acts on |z〉 ¼ cos(π/8)|0〉  sin(π/8)|1〉 as follows:


0 π π 1 0 π 1
π n π π o cos sin cos
B C B C
Ry cos j0i sin j 1i ¼ @ 8π 8π A  @ 8π A
4 8 8  sin cos  sin
0 π8 8π 1 0 8
π 1
cos 2
 sin 2
cos
B 8 8 C ¼ B C
¼@ π π A @ 4π A
2 sin cos  sin
π 8 π8 4
¼ cos j0i sin j1i
4 4

The new quantum state is


114 5 Introducing Quantum Computing

n π π o π π
j0i j0i cos j0i sin j1i ¼ cos j0; 0; 0i sin j0; 0; 1i
4 4 4 4

Step 4: The second CN gate performs an XOR between |x〉 and |z〉:
n π π o π π
jxi jzi ¼ j0i cos j0i sin j1i ¼ cos j0i sin j 1i
4 4 4 4

The new quantum state is


n π π o π π
j0i j0i cos j0i sin j1i ¼ cos j0; 0; 0i sin j0; 0; 1i
4 4 4 4

Step 5: The third Ry gate (the adjoint matrix Ry*) acts on |z〉 as follows:
0 π π 1 0 π 1
π n π π o cos sin cos
B C B C
R∗
y cos j0i sin j 1i ¼ @ π8 π8 A  @ 4π A
4 4 4 sin cos sin
0 8π π8 π π4 1
cos cos þ sin sin
B C
¼ @ π8 π4 π8 π4 A
sin cos  cos sin
8 4 8 4
0 π 1
cos π π
¼@ 8π A ¼ cos j0i sin j 1i
sin 8 8
8

The new quantum state is


n π π o π π
j0i j0i cos j0i sin j1i ¼ cos j0; 0; 0i sin j0; 0; 1i
8 8 8 8

Step 6: The third CN performs an XOR between |y〉 and |z〉 as follows:
n π π o π π
jyi jzi ¼ j0i cos j0i sin j1i ¼ cos j0i sin j 1i
8 8 8 8

The new quantum state is


n π π o π π
j0i j0i cos j0i sin j1i ¼ cos j0; 0; 0i sin j0; 0; 1i
8 8 8 8
5.6 Constructing Algorithms with Qubits 115

Step 7: Finally, the fourth Ry gate (also the adjoint matrix of Ry) acts on |z〉 as
follows:
0 π π 1 0 π 1
π n π π o cos  sin cos
B C B C
R∗
y cos j0i sin j 1i ¼ @ π8 π8 A  @ 8π A
4 8 8 sin cos  sin
0 8 π 8 π 81
cos 2
þ sin 2
B C
¼@ π π8 π8 π A
sin cos  cos sin
8 8 8 8
 
1
¼ ¼ j 0i
0

The new quantum state is


j0i j0i j0i ¼ j0; 0; 0i

We have therefore been able to verify that


U Toffoli j000〉 ! j000〉

Second Case: Input ¼ |1, 0, 0〉

We will write the structure of the gate as a sequence of unitary transformations,


in accordance with Fig. 5.6:
U Toffoli ¼ Ry ðθ=4Þjz〉  ðjy〉 jz〉Þ  Ry ðθ=4Þjz〉  ðjx〉 jz〉Þ
 Ry { ðθ=4Þjz〉  ðjy〉 jz〉Þ  Ry { ðθ=4Þjz〉

According to this structure, for input |1, 0, 0〉, the intermediate results are as
follows:
Step 0: |1, 0, 0〉
Step 1: cos (π/8) |1, 0, 0〉  sin (π/8) |1, 0, 1〉
Step 2: cos (π/8) |1, 0, 0〉  sin (π/8) |1, 0, 1〉
Step 3: cos (π/4) |1, 0, 0〉  sin (π/4) |1, 0, 1〉
Step 4: sin (π/4) |1, 0, 0〉 + cos (π/4) |1, 0, 1〉
Step 5: sin (3π/8) |1, 0, 0〉 + cos (3π/8) |1, 0, 1〉
Step 6: sin (3π/8) |1, 0, 0〉 + cos (3π/8) |1, 0, 1〉
Step 7: |1, 0, 0〉
We have therefore been able to verify that
U Toffoli j100〉 ! j100〉

involves a phase change.

Third Case: Input ¼ |1, 1, 1〉


116 5 Introducing Quantum Computing

This case illustrates how the Toffoli gate changes the state of the third qubit:
Step 0: |1, 1, 1〉
Step 1: sin (π/8) |1, 1, 0〉 + cos (π/8) |1, 1, 1〉
Step 2: cos (π/8) |1, 1, 0〉 + sin (π/8) |1, 1, 1〉
Step 3: |1, 1, 0〉
Step 4: |1, 1, 1〉
Step 5: sin (π/8) |1, 1, 0〉 + cos (π/8) |1, 1, 1〉
Step 6: cos (π/8) |1, 1, 0〉  sin (π/8) |1, 1, 1〉
Step 7: |1, 1, 0〉
We have therefore been able to verify that

U Toffoli j1, 1, 1〉 ! j1, 1, 0〉

5.7 Summary of the Chapter

Drawing on the formalism, concepts and techniques of quantum mechanics


discussed in Chap. 4, we introduce some of the most important ideas governing
quantum computing, starting with an historical overview of this new computational
paradigm. Concepts such as the simulation of the laws of physics, coherent super-
position, parallelism, entanglement, etc., are briefly described. The basic unit of
information in quantum computing, the qubit, is described, along with the restric-
tions that apply to the qubit and the concept of quantum algorithms. The definition of
the single qubit leads to the problem of systems with n qubits, for which we recall the
concepts of Hilbert spaces and the orthogonal basis, which enable such systems to be
appropriately represented. A central issue in quantum computing is then addressed,
namely the problematic measurement of states (directly related to Heisenberg’s
uncertainty principle), and we explore how Entanglement affects the measurement
of states. Finally, we explore the construction of quantum algorithms, which have to
take into account the no-cloning theorem, the reversibility of quantum gates that
allow operations with qubits, and the unitary property of quantum transformations.
The chapter concludes with the construction and analysis of two quantum circuits,
one simulating a quantum exchange by means of CN gates, and the other an
architecture that relies on several different gates to simulate a quantum CCN.

5.8 Glossary of Terms and Notation Used in This Chapter

Terms
• Bloch sphere: a geometrical representation of the pure state space of a two-level
quantum mechanical system.
5.8 Glossary of Terms and Notation Used in This Chapter 117

• Cryptography: the practice and study of techniques for secure communication in


the presence of third parties.
• Density matrix: a matrix that describes a quantum system in a mixed state as a
statistical ensemble of several quantum states.
• Maxwell’s demon: a thought experiment by the physicist James Clerk Maxwell
that suggested how the second law of thermodynamics could hypothetically be
violated.
• Orthonormal basis: for an inner product space V with finite dimension, a basis for
V whose vectors are orthonormal, that is, all are unit vectors that are orthogonal
to each other.
• Quantum circuit: a model for quantum computation whereby computation is
performed by a sequence of quantum gates that are reversible transformations of
a quantum mechanical analog of an n-bit register, referred to as an n-qubit
register.
• Quantum decoherence: the loss of coherence or ordering of the phase angles
between system components in quantum superposition.
• Quantum entanglement: a physical phenomenon that occurs when pairs or
groups of particles are generated or interact in such a way that the quantum
state of each particle cannot be described independently.
• Quantum parallelism: a method whereby a quantum computer is able to perform
computations simultaneously.
• Quantum superposition: a fundamental principle of quantum mechanics that
states that, much like waves in classical physics, any two (or more) quantum
states can be added together (superposed) and the result will be another valid
quantum state, and conversely, that every quantum state can be represented as a
sum of two or more other distinct states.
• Tensor product: the freest bilinear operation, applicable in different contexts to
vectors, matrices, tensors, vector spaces, algebras, topological vector spaces and
modules, among many other structures and objects.
• Tunnel effect: a quantum mechanical phenomenon whereby a particle penetrates
a barrier in a way impossible according to the classical laws of physics.
• Unitary matrix: in mathematics, a complex square matrix is unitary if its
conjugate transpose is also its inverse.
• Unitary transformation: a transformation that preserves the inner product (the
inner product of two vectors before transformation remains equal to their inner
product after transformation).

Notation

αi Amplitude
|α0|2 + |α1|2 ¼ 1 Normalization for a single qubit
Bn Computational basis
U Unitary transformation
〈--|--〉 Inner product of two vectors
118 5 Introducing Quantum Computing

 Tensor product
Exclusive-OR, EXOR, XOR
A* Complex conjugate of matrix A
AT Transpose of matrix A
A{ ¼ (AT)* Hermitian conjugate of matrix A
Chapter 6
Feynman’s Quantum Computer Machine

When it is working, you completely go into another place,


you’re tapping into things that are totally universal,
completely beyond your ego and your own self. That’s what
it’s all about.
Keith Haring

We are now ready to understand the design of quantum algorithms or, at least, to
analyze some of the more important quantum algorithms. But something is still
missing: we have a quantum computation model, but we do not have a computer
model on which to test our quantum algorithms. We will fill this gap by studying the
quantum computer model proposed by Feynman in the early 1980s.

6.1 Playing with Matrices

Consider an ideal quantum system, for example, built from atoms. Using the
property of spin, the system can be in either of two states:
Up ð"Þ : Spin ¼ þ1=2
Down ð#Þ : Spin ¼ 1=2

And the meaning is


Spin ð "Þ  Bit ð1Þ
Spin ð #Þ  Bit ð0Þ

We can build our computer from these atoms by connecting them in some
concrete form. Each set of atoms is in one of the two possible states, representing
a number that is the input to the quantum system. We now leave the system to
evolve during a certain period of time t. This evolution unfolds in accordance with
the laws of quantum mechanics. At a given moment we will have the set of atoms in
different states and representing the output of the system. With these ideas in mind,

© Springer International Publishing AG 2017 119


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_6
120 6 Feynman’s Quantum Computer Machine

Feynman proposed his quantum computer model, for which he used a special and
very simple kind of matrices.
Assume we have a line of computation A and a logic quantum gate that performs
a given unitary transformation, for example, identity or negation. We can thus
define the following matrices:
       
1 0 0 1 0 0 0 0
a1 ¼ , a2 ¼ , a3 ¼ , a4 ¼
0 0 0 0 0 1 1 0

We now multiply these matrices in all possible ways:


     
1 0 0 1 0 1
a1  a2 ¼  ¼ ¼ a2
0 0 0 0 0 0
     
0 1 1 0 0 0
a2  a1 ¼  ¼ ¼0
0 0 0 0 0 0
     
1 0 0 0 0 0
a1  a3 ¼  ¼ ¼0
0 0 0 1 0 0
     
0 0 1 0 0 0
a3  a1 ¼  ¼ ¼0
0 1 0 0 0 0
     
1 0 0 0 0 0
a1  a4 ¼  ¼ ¼0
0 0 1 0 0 0
     
0 0 1 0 0 0
a4  a1 ¼  ¼ ¼ a4
1 0 0 0 1 0
     
0 1 0 0 0 1
a2  a3 ¼  ¼ ¼ a2
0 0 0 1 0 0
     
0 0 0 1 0 0
a3  a2 ¼  ¼ ¼0
0 1 0 0 0 0
     
0 1 0 0 1 0
a2  a4 ¼  ¼ ¼ a1
0 0 1 0 0 0
     
0 0 0 1 0 0
a4  a2 ¼  ¼ ¼ a3
1 0 0 0 0 1
     
0 0 0 0 0 0
a3  a4 ¼  ¼ ¼ a4
0 1 1 0 1 0
     
0 0 0 0 0 0
a4  a3 ¼  ¼ ¼0
1 0 0 1 0 0

We use the above products to build, for example, the unitary matrices of identity
I and negation N:
6.1 Playing with Matrices 121

 
1 0
I¼ ¼ a1 þ a3 ¼ ða2 a4 þ a4 a2 Þ ¼ 1
0 1
 
0 1
N¼ ¼ a2 þ a4
1 0

We now calculate the corresponding conjugate-transpose matrices:


! ! ! !
1 0 1 0 0 1 0 0
a1 ¼ ! a∗ 1 ¼ ¼ a1 , a2 ¼ ! a∗2 ¼ ¼ a4
0 0 0 0 0 0 1 0
! ! ! !
0 0 0 0 0 0 0 1
a3 ¼ ! a∗ 3 ¼ ¼ a3 , a4 ¼ ! a∗4 ¼ ¼ a2
0 1 0 1 1 0 0 0

It is easy to verify that a1 and a3 do not change, whereas a2 and a4 are the
conjugate-transpose matrices of each other. As for what happens when we apply a2
and a4 to the states |0〉and |1〉 , the answer is
           
0 1 1 0 0 1 0 1
a 2 j 0i ¼  ¼ ¼ 0, a2 j1i ¼  ¼ ¼ j 0i
0 0 0 0 0 0 1 0
           
0 0 1 0 0 0 0 0
a 4 j 0i ¼  ¼ ¼ j1i, a4 j1i ¼  ¼ ¼0
1 0 0 1 1 0 1 0

When a2 operates on a ket 1, this becomes ket 0. Analogously, when a4 operates


on a ket 0, this becomes ket 1.
Of what use are these matrices a2 and a4? Before answering this question, we
should first simplify the notation somewhat. In the remainder of this chapter we will
represent a2 as a(a  a2) and a4 as a(a  a4). Accordingly,
aaj0i ¼ j0i
aaj1i ¼ j1i

Therefore, (aa) indicates that |A〉¼ |0〉and (aa) indicates that |A〉¼ |1〉
. We can
now use these criteria to represent the behavior of quantum gates—here the CN
gate—in terms of these matrices:
CN consists of two lines (A and B)
Line A is the control line (therefore |Ain〉¼ |Aout〉
)
If |A〉¼ |0〉then |Bout〉¼ |Bin〉
If |A〉¼ |1〉then |Bout〉¼ NOT |Bin〉
Then
UCN ¼ aa þ ðaaÞ  ðb þ bÞ ¼ 1  aa þ ðaaÞ  ðb þ bÞ
¼ 1 þ aa  ðb þ b  1Þ
122 6 Feynman’s Quantum Computer Machine

The above expression can be interpreted as follows: if line A is in state 0 (aa), the
system does not execute any control action on line B, whereas if line A is in state
1 (aa), then the system inverts the state of line B (b + b). If we now interpret the +
and  signs as somewhat equivalent to OR (disjunction) and AND (conjunction),
respectively, we can consider the above equation as follows:
• Line A is zero (aa)
• Or (+) line A is in state 1 (aa) and so () line B changes state (b + b)
We can now demonstrate the equivalence between the above expressions:
 
1 0
aa¼
0 0
 
0 0
aa¼
0 1
     
1 0 1 0 0 0
1aa¼  ¼ ¼ aa
0 1 0 0 0 1

The algebraic expression is therefore confirmed to be correct.


We now continue with an analysis of the CCN gate (Toffoli gate) gate in terms of
these matrices. Remember that the following restrictions apply:
   
Aoutput ¼ Ainput
   
Boutput ¼ Binput

If |A〉¼ |0〉and |B〉¼ |0〉then |Coutput〉¼ |Cinput〉


If |A〉¼ |0〉and |B〉¼ |1〉then |Coutput〉¼ |Cinput〉
If |A〉¼ |1〉and |B〉¼ |0〉then |Coutput〉¼ |Cinput〉
If |A〉¼ |1〉and |B〉¼ |1〉then |Coutput〉¼ NOT |Cinput〉

The representation in terms of the above mentioned matrices is as follows:


UCCN ¼ ða aÞ  ðb bÞ þ ða aÞ  ðb bÞ þ ða aÞ  ðb bÞþ
ða aÞ  ðb bÞ  ðc þ cÞ ¼ 1 þ ða aÞ  ðb bÞ  ðc þ c  1Þ

Continuing with practical examples, in order to find the matrix expression for the
FO operator, we need to represent this gate as a CN circuit with two lines: A, which
is the control line, and B, whose input is always 0. Thus
   
Ainput ¼ Aoutput
 
Binput ¼ j0i

If |A〉¼ |0〉then |Boutput〉¼ |Binput〉¼ |0〉


If |A〉¼ |1〉then |Boutput〉¼ NOT |Binput〉¼ |1〉

Remember that in line A


6.1 Playing with Matrices 123

aaj0i ¼ j0i; aaj1i ¼ j1i

and in line B
bbj0i ¼ j0i; bbj1i ¼ j1i

Therefore
UFO ¼ ðaaÞ  ðbbÞ þ ðaaÞ  ðbbÞ  ðb þ bÞ
¼ ð1  aaÞ  ðbbÞ þ ðaaÞ  ðbbÞ  ðb þ bÞ
¼ ðbbÞ  ðaaÞ  ðbbÞ þ ðaaÞ  ðbbÞ  ðb þ bÞ
¼ ðbbÞ þ ðaaÞ  ðbbÞ  ðb þ b  1Þ

As for the EX and Fredkin reversible gates, we will leave the development of
their matrix expressions to the reader, pointing the way by suggesting possible
combinations of other reversible gates that lead to the solution.
EX can be obtained from the architecture combining three CN gates, as depicted
in Fig. 6.1. The evolution of the values in each line is represented in Table 6.1.
The Fredkin gate executes a controlled EX on the input lines, as illustrated in
Table 6.2.
Similar operations can be implemented to construct more complicated devices.
In the case of the half adder in Fig. 6.2, we need to consider the step-by-step
evolution of the states in each line, as depicted in Table 6.3.
As for the full adder, the solution requires following the steps indicated in
Fig. 6.3 to obtain the final result reflected in Table 6.4. The logic structure is as
follows:

Fig. 6.1 EX architecture


A1 A2
based on three CN
A0 Af
reversible logic gates

B0 Bf
B1 B2

Table 6.1 Evolution of states for an EX architecture based on three CN reversible logic gates
|A0〉 |B0〉 |A1〉 |B1〉 |A2〉 |B2〉 |Af〉 |Bf〉
0 0 0 0 0 0 0 0
0 1 0 1 1 1 1 0
1 0 1 1 0 1 0 1
1 1 1 0 1 0 1 1
124 6 Feynman’s Quantum Computer Machine

Table 6.2 Evolution of states |A0〉 |B0〉 |C0〉 |Af〉 |Bf〉 |Cf〉
for a Fredkin gate
0 0 0 0 0 0
0 0 1 0 0 1
0 1 0 0 1 0
0 1 1 0 1 1
1 0 0 1 0 0
1 0 1 1 1 0
1 1 0 1 0 1
1 1 1 1 1 1

Fig. 6.2 Quantum A0 A1 A2 Af


representation of the half
adder

B0 B1 B2 Sf

C0 = 0 C1 C2 Kf

Table 6.3 Evolution of states for the Half Adder


|A0〉 |B0〉 |C0〉 |A1〉 |B1〉 |C1〉 |Af〉 |Sf〉 |Kf〉 (|A0〉+ |B0〉
) (|Sf〉+ |Kf〉
)
0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 1 0 0 1 0 0 1 1 0
1 0 0 1 0 0 1 1 0 1 0 1 0
1 1 0 1 1 1 1 0 1 1 1 0 1

Fig. 6.3 Full adder of


two-bit numbers A0 A1 A2 A3 A4 Af

B1 B2 B3 B4 Bf
B0

C1 C2 C3 C4 Sf
C0

D0=0 D1 D2 D3 D4 Kf
6.2 Quantum Computer Design 125

Table 6.4 Full adder of two-bit numbers


|A0〉 + |B0〉 ¼ |Sf〉 + |Kf〉 Comments
0 0 0 0 Without previous carry
0 0 1 0 With previous carry
0 1 1 0 Without previous carry
0 1 0 1 With previous carry
1 0 1 0 Without previous carry
1 0 0 1 With previous carry
1 1 0 1 Without previous carry
1 1 1 1 With previous carry

 
hΣC ½A0 ; B0 ; C0 ; D0 ¼ 0i ¼ Af ; Bf ; Sf ; K f

And the sequence of operations is as follows:


ΣC : fCCND0 ¼0, A0B0 g fCNB1 , A1 g fCCND2 , B2 C2 g fCNC3 , B3 g fCNB4 , A4 g

6.2 Quantum Computer Design

We will go now to the heart of the matter: the design of an operator capable of
implementing computation in genuine quantum style. Note that, up to now, we only
have employed four atoms—a, b, c and d—to represent most of the operations of
interest to us. Each of these atoms could be a |0〉or |1〉bit. Let us now consider our
quantum system built with these four atoms, assuming that this quantum system is
in the state |a, b, c, d〉. If we denote by M the matrix of the logic structure that
generates the transformation of the initial quantum state, then
Mja; b; c; d i ¼ ja0 ; b0 ; c0 ; d0 i
jΨin i ¼ ja; b; c; d i
jΨout i ¼ ja0 ; b0 ; c0 ; d0 i
jΨout i ¼ MjΨin i

To illustrate with an example, assume that we want to perform a sum for a


system whose initial state is
jΨin i ¼ j1; 0; 1; 0i

The operator M will obviously be ∑C, and (as can be verified from a truth table
for the full adder), the result will obviously be
jΨout i ¼ MjΨin i ¼ ΣC j1; 0; 1; 0〉 ¼j1; 0; 0; 1i

where (as already stated)


126 6 Feynman’s Quantum Computer Machine

ΣC : fCCND0 ¼0, A0 B0 g fCNB1 , A1 g fCCND2 , B2 C2 g fCNC3 , B3 g fCNB4 , A4 g

Here we have represented reversible operations according to the conventional


order of application of sequential primitive operations. If we use Feynman’s
notation, we can write ∑C as a matrix product, with the order of application going
from right to left:
ΣC ¼ Aa, b Ab, c Abc, d Aa, b Aab, d

The general formulation of the problem is the following. Consider the following
generic set of matrices:
fA1 ; A2 ; A3 . . . Ak g

With this set we establish the sequence of operations required for a (given)
complex logic unit which can operate on n lines. The 2n2n matrix Mn that we need
can be built as follows:
Mn  A k . . . A 3 A 2 A 1

In Mn each Ai of this product is a simple matrix that performs an elementary


operation. But the problem now is how to physically generate Mn now that we know
how to build the simplest elements. And here is the magic of Feynman. We have
n atoms in the register. We add a new set of k + 1 atoms that configure what we call
the position counter of the program.
We denote by ai the operator that resets position i (Pos(i) ¼ |0〉 ) and by ai the
operator that initiates position i (Pos(i) ¼ |1〉) in such a way that both ai and ai
operate from i ¼ 0 to i ¼ k. We now need an electron moving continuously from one
position to another. If a given position is empty at any moment, the state of this
position is |0〉
, and if a given position is occupied at any moment, the state of this
position is |1〉
. The following Hamiltonian operator can now be defined:
X
k1  X
k 
b ¼
H aiþ1 ai Aiþ1 þ ai1 ai A∗
i
i¼0 i¼1
  

b ¼ a a0 A1 þ a a1 A2 þ a a2 A3 þ . . .
H 1 2 3
  ∗  ∗
. . . þ a0 a1 A∗
1 þ a1 a2 A2 þ a2 a3 A3 þ . . .

In the above equation, AX performs a forward operation, and AX* performs a


backward operation.
If all the program positions are free—a situation we will denote by Pos()—then
all the program atoms are in the state |0〉 , and, consequently, there are no changes.
This means that the expression for Hamiltonian H only applies when one and only
one of the program positions is occupied:
6.2 Quantum Computer Design 127

H applies $ ∃i 8j 6¼ i ! PosðiÞ ¼ j1i and PosðjÞ ¼ j0i

Hence, the number of program positions in state |1〉is always the same. During
computation there can either be no occupied positions (when nothing happens), or
exactly one occupied position (when an elementary computation task is performed),
that is, it is not possible for two or more program positions to be occupied
simultaneously.
Let us try to understand what is happening with our quantum computer by
considering a quantum system in an initial state |Ψ0〉
:
1. When i ¼ 0 ! Pos ¼ 0 ! |Pos ¼ 0〉¼ |1〉 Pos(0)
2. We leave the system to evolve during an arbitrary time period
3. We observe that |Pos ¼ k〉¼ |1〉 Pos(k)
4. We observe that |Pos 6¼ k〉¼ |0〉
5. The register n is multiplied by the matrix

Mn ¼ A k . . . A 3 A 2 A 1

And the operation is completed.


This is not exactly trivial, so let us try again, this time considering an example:
Consider a register of three atoms: n ¼ 3
Consider four elementary operations: k ¼ 4
The number of program counter positions is k + 1 ¼ 5
Therefore

jPosi ¼ j1; 0; 0; 0; 0i : jΨ 0 i ! jΨ 1 i ¼ A1 jΨ 0 i : jPosi ¼ j0; 1; 0; 0; 0i


jPosi ¼ j0; 1; 0; 0; 0i : jΨ 1 i ! jΨ 2 i ¼ A2 jΨ 1 i : jPosi ¼ j0; 0; 1; 0; 0i
jPosi ¼ j0; 0; 1; 0; 0i : jΨ 2 i ! jΨ 3 i ¼ A3 jΨ 2 i : jPosi ¼ j0; 0; 0; 1; 0i
jPosi ¼ j0; 0; 0; 1; 0i : jΨ 3 i ! jΨ 4 i ¼ A4 jΨ 3 i : jPosi ¼ j0; 0; 0; 0; 1i

The example is explained as follows. Initially the system of three atoms is in the
state |Ψ0〉and counter position 0 is occupied. In these conditions, the term of H that
can operate is
a1 a0 A1

We now apply the matrix A1 to operate on the three atoms. Remember that a and
a move the position of the counter cursor.
The situation is
a0 : jPos ð0Þi ! j0i
a1 : jPos ð1Þi ! j1i
a1 a0 : Pos ð0Þ ! Pos ð1Þ
128 6 Feynman’s Quantum Computer Machine

According to what was stated above, a0 resets position 0 and a1 initiates position
1. Now it can be clearly seen that

i+1 ! |0〉
If ai+1 resets position i + 1, then |1〉 i+1
i ! |1〉
If ai initiates position i, then |0〉 i

We will now describe how the program operates in terms of cycles.

First cycle

• Register of program position counter

i ¼ 0 : jPosðiÞi ¼ j1i : jPosði þ 1 ! kÞi ¼ j0i

jPos0i ¼ j1; 0; 0 . . . 0i

• Register of n atoms in the initial state

jΨ 0 i ¼ jx1 ; x2 ; . . . xn i0 : xi ¼ 0, 1

• Operation of the first term of Η

a1 a0 A1

A1 operates on the register of n atoms

jΨ 1 i ¼ A1 jΨ 0 i
a1 a0 j1; 0; 0; . . . ; 0i ! j0; 1; 0; . . . ; 0i

If A1 wanted to undo and operate, it could not do so because

jPosð0Þi ¼ j0i

Second cycle

• Register of program position counter

i ¼ 1, jPos ðiÞi ¼ j1i, jPosð j ¼ 0 ! k; j 6¼ iÞi ¼ j0i

jPos1i ¼ j0; 1; 0 . . . 0i

• Register of n atoms in the new state

jΨ1 i ¼ jx1 ; x2 ; . . . xn i1 : xi ¼ 0, 1

• Term of Η that operates:


6.2 Quantum Computer Design 129

a2 a1 A2

A2 operates on the register of n atoms:

jΨ2 i ¼ A2 A1 jΨ0 i
a2 a1 j0; 1; 0; . . . ; 0i ! j0; 0; 1; . . . ; 0i

In this way the cursor continues to move and the primitive elementary operations
are applied in a suitable order so as to perform the complex operation M.
However, some restrictions have to be taken into account. For example, the
Hamiltonian H has to be Hermitian, so that the adjoint operations are present.
Furthermore, we can arrive at a position j from j  1 or from j + 1, but the result of
the computation has to be the same irrespective of the point of departure. Does
Feynman’s approach fulfil these restrictions?
Assume the computer is in |Pos (1)〉¼ |1〉and has already operated A2 A1|Register (n)〉 .
If the term that controls the process is a2 a1 , then the cursor moves to |Pos (2)〉¼ |1〉
and the evolution is |Ψ012〉¼ A3 A2 A1|Ψ0〉 . In contrast, if the term that controls the
process is a1 a2 , then the cursor moves to |Pos (0)〉¼ |1〉 , generating the new state
|Ψ010〉¼ A2* A2 A1|Ψ0〉 . But since we know that A2* A2 ¼ 1, then clearly
|Ψ010〉¼ A1|Ψ0〉 . The net result is that the state of the register n depends on the
position of the cursor.
More explicitly, we will assume a given number of atoms with information.
• Number of atoms: n ¼ 3
• Number of elementary operations: k ¼ 4
• Number of counter positions: k + 1 ¼ 5
• Possible states: Ψ0, Ψ1, Ψ2, Ψ3, Ψ4
• Matrices that perform operations: A1, A2, A3, A4
• Matrices that undo operations: A1*, A2*, A3*, A4*
• Position counter register:

Posð0Þ ¼ j10000i
Posð1Þ ¼ j01000i
Posð2Þ ¼ j00100i
Posð3Þ ¼ j00010i
Posð4Þ ¼ j00001i

• Forward movements of the cursor

a1 a0 : Pos ð0Þ ! Pos ð1Þ


a2 a1 : Pos ð1Þ ! Pos ð2Þ
a3 a2 : Pos ð2Þ ! Pos ð3Þ
a4 a3 : Pos ð3Þ ! Pos ð4Þ
130 6 Feynman’s Quantum Computer Machine

• Backward movements of the cursor

a0 a1 : Pos ð1Þ ! Pos ð0Þ


a1 a2 : Pos ð2Þ ! Pos ð1Þ
a2 a3 : Pos ð3Þ ! Pos ð2Þ
a3 a4 : Pos ð4Þ ! Pos ð3Þ

• Hamiltonian for this case


   
H ¼ a1 a0 A1 þ
 a2 a 1 A2 þ a3 a 2 A3 þ a4 a 3 A4
þ a0 a1 A∗ ∗ ∗
1 þ a1 a2 A2 þ a2 a3 A3 þ a3 a4 A4

6.3 The Quantum Computer at Work

Having our system in a given state Ψx then i ¼ x, and the state of the system can
evolve forwards ()) or backwards ((). We will use the following notation to
illustrate the process:
Ψx ! i ¼ x ! Ψx ) Ψxþ1 ðor Ψx ) Ψx1  Ψx1 ( Ψx Þ

In our example, the following cases appear:


1. Ψ0 ! i ¼ 0 ! Ψ0 ) Ψ1 ! One action forward possible
a. Ψ1 ¼ A1Ψ0
b. a1 a0 : Pos (0) ! Pos (1)
2. Ψ1 ! i ¼ 1 ! Ψ0 ( Ψ1 ) Ψ2 ! Two actions are possible
a. Forward action
i. Ψ1 ) Ψ2
ii. Ψ2 ¼ A2Ψ1 ¼ A2A1Ψ0
iii. a2 a1 : Pos (1) ! Pos (2)
b. Backward action
i. Ψ0 ( Ψ1
ii. Ψ0 ¼ A1*Ψ1 ¼ A1*A1Ψ0
iii. a0 a1 : Pos (1) ! Pos (0)
3. Ψ2 ! i ¼ 2 ! Ψ1 ( Ψ2 ) Ψ3 ! Two actions are possible
a. Forward action
i. Ψ2 ) Ψ3
6.4 Setting Up the Quantum Computer 131

ii. Ψ3 ¼ A3Ψ2 ¼ A3A2Ψ1 ¼ A3A2A1Ψ0


iii. a3 a2 : Pos (2) ! Pos (3)
b. Backward action
i. Ψ1 ( Ψ2
ii. Ψ1 ¼ A2*Ψ2 ¼ A2*A2Ψ1 ¼ A2*A2A1Ψ0
iii. a1 a2 : Pos (2) ! Pos (1)
4. Ψ3 ! i ¼ 3 ! Ψ2 ( Ψ3 ) Ψ4 ! Two actions are possible
a. Forward action
i. Ψ3 ) Ψ4
ii. Ψ4 ¼ A4Ψ3 ¼ A4A3Ψ2 ¼ A4A3A2Ψ1 ¼ A4A3A2A1Ψ0
iii. a4 a3 : Pos (3) ! Pos (4)
b. Backward action
i. Ψ2 ( Ψ3
ii. Ψ2 ¼ A3*Ψ3 ¼ A3*A3Ψ2 ¼ A3*A3A2Ψ1 ¼ A3*A3A2A1Ψ0
iii. a2 a3 : Pos (3) ! Pos (2)
5. Ψ4 ! i ¼ 4 ! Ψ3 ( Ψ4 ! One action backward possible
a. Ψ3 ¼ A4*Ψ4 ¼ A4*A4Ψ3 ¼ A4*A4A3Ψ2
¼ A4*A4A3A2Ψ1 ¼ A4*A4A3A2A1Ψ0
b. a3 a4 : Pos (4) ! Pos (3)

6.4 Setting Up the Quantum Computer

To set up our quantum computer we can apply the following protocol:


• Configure the input in the register of n atoms.
• Put the cursor in position 0: |Pos (0)〉¼ |1〉
• Leave the system to evolve.
• Continuously check the position of the cursor.
• When |Pos (Final)〉¼ |1〉do |Pos (Final)〉¼ |0〉
• Measure the register.
The main problem we have—still far from being resolved—refers to interaction
with the external world to configure inputs and read outputs. To facilitate our
quantum computer set-up and stop, suppose that, in addition to the internal posi-
tions used for computation, we create a new line of before (input) positions and
after (output) positions, as illustrated in Table 6.5.
We can thus configure the computation as follows:
132 6 Feynman’s Quantum Computer Machine

Table 6.5 A configuration for Feynman’s quantum computer


Input positions Processing positions Output positions
Cursor z y x t . . . 0 1 2 . . . k k+1 k + 2 k + 3 k + 4 . . .
<i>
Operation 1 1 1 1 1 A1 A2 A3 . . . Ak+1 1 1 1 1 1

ði < 0Þ or ði > kÞ ! A  ð1Þ

The operation of this monstrosity, with its much longer chain of spins, is as
follows:
• Before computing (i < 0), and the computer waits:

jΨi i ¼ jΨIn i 8i < 0

• After computing (i > k), and the computer waits:

jΨ i i ¼ jΨ Out i 8i > k

• The computations are performed with i 2 [0, k]


This strategy may allow us capture the cursor more easily.

6.5 Chapter Summary

In order to analyze Feynman’s universal quantum computer architecture, we start


by defining a special kind of matrix that can be used to represent elementary
operations such as identity and negation. We next use these matrices to find the
matrix representation of important logic gates such as CN and CCN. We also briefly
refer, from this new perspective, to other reversible logic gates, such as FO, EX and
the Fredkin gate. More complicated problems such as the Half Adder and the full
adder are revisited. This background provides the basis for tackling the design of a
quantum computer. Like Feynman, we define complex operations by means of the
product of elementary operations in their matrix representation. To represent the
entire process, we define the corresponding Hamiltonian, which, given quantum
mechanical restrictions, has to be Hermitian. To control the computation, we define
a position counter register for the program. Altogether, this yields a non-trivial
architecture. To explain how this machine works we use an example that is
discussed in depth from three different points of view. We conclude with some
thoughts on how to initialize the system and how to recognize when the computer
has completed computation.
6.6 Glossary of Terms and Notation Used in This Chapter 133

6.6 Glossary of Terms and Notation Used in This Chapter

Terms
• Position counter: indicates where a computer is in its program sequence.

Notation

I, 1 Identity matrix
N Negation matrix
M, Mn A complex quantum operation
Ai An elementary operation
Ai* Adjoint of Ai
b H
H, Hamilton operator or Hamiltonian
Chapter 7
Some Quantum Algorithms

We live in a culture that’s been hijacked by the management


consultant ethos. We want everything boiled down to a
PowerPoint slide. We want metrics and ‘show me the
numbers’. That runs counter to the immensely complex
nature of so many social, economic and political problems.
You cannot devise an algorithm to fix them.
Carl Honoré

A quantum algorithm is an algorithm that makes use of the principles of quantum


mechanics to perform certain computation tasks. The most important quantum
algorithms include the following:
• Deutsch’s algorithm
• The Deutsch-Jozsa algorithm
• The quantum Fourier transform
• Shor’s algorithm
• Simon’s algorithm
• Grover’s algorithm
• The quantum teleportation algorithm.
David Deutsch proposed the first quantum algorithm in 1985, based on the
principles of superposition and parallelism of qubits to perform quantum compu-
tations. The most important characteristic of this algorithm is that it served to
demonstrate that quantum computing could deal with real problems.
David Deutsch and Richard Jozsa subsequently generalized Deutsch’s algo-
rithm. The Deutsch-Jozsa approach showed how a given black-box problem
could be solved more efficiently and without error by a quantum computer com-
pared to a deterministic classical computer, which needs to make an exponential
number of queries to the black box.
Peter Shor developed the quantum version of the classical Fourier transform.
Probably one the most important quantum algorithms designed to date, it can also
be used as a quantum subroutine for other, more complex algorithms. Shor also
developed the quantum algorithm that bears his name. Of real practical value,
Shor’s algorithm decomposes an integer N into its prime factors. If Shor’s algorithm

© Springer International Publishing AG 2017 135


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_7
136 7 Some Quantum Algorithms

were to be implemented in a quantum computer, public-key cryptosystems such as


the Rivest-Shamir-Adleman (RSA) system would become obsolete. Like all quan-
tum computer algorithms, Shor’s algorithm is probabilistic: the probability of a
correct answer is high and the probability of failure can be reduced by repeating the
algorithm.
The most important characteristic of Simon’s algorithm is that it provides
exponential speed-up over any classical algorithm. It also works in conjunction
with classical computation algorithms to achieve the definitive solution to
problems.
Of special interest is Grover’s algorithm, initially designed to search an
unordered set of items to find the single element that satisfies some condition.
From a pedagogic point of view, Grover’s algorithm is useful for demonstrating
how quantum systems can improve on the lower runtime bounds of classical
algorithms. The speed-up in this case relies on the quantum superposition of states.
Finally, quantum teleportation illustrates the peculiar concept of entanglement.
Quantum teleportation is a process by which quantum information can be trans-
mitted from one location to another, using a classical communication system and
quantum entanglement between the sending and receiving locations.
Below we will analyze in depth the Deutsch, Deutsch-Jozsa, Simon and quantum
teleportation algorithms, leaving the reader to investigate the remaining algorithms
for him or herself.

7.1 Deutsch’s Algorithm

Deutsch’s algorithm goes as follows. Assume a black box with two inputs x and
y that take values in {0, 1}, and a function α of the type
α : f0; 1g ! f0; 1g

We will try to verify whether α is constant or balanced, taking into account that
α is constant if and only if α(x) ¼ α( y)
α is balanced if and only if α(x) 6¼ α( y)
From a classical point of view, four possible functions, as illustrated in Fig. 7.1,
satisfy the requirements of the problem:
α1: x ¼ 0, y ¼ 1 : α1 ðxÞ ¼ 0, α1 ðyÞ ¼ 0 ! α1 ðxÞ ¼ α1 ðyÞ ! α1 is constant
α2: x ¼ 0, y ¼ 1 : α2 ðxÞ ¼ 0, α2 ðyÞ ¼ 1 ! α2 ðxÞ 6¼ α2 ðyÞ ! α2 is balanced
α3: x ¼ 0, y ¼ 1 : α3 ðxÞ ¼ 1, α3 ðyÞ ¼ 0 ! α3 ðxÞ 6¼ α1 ðyÞ ! α3 is balanced
α4: x ¼ 0, y ¼ 1 : α4 ðxÞ ¼ 1, α4 ðyÞ ¼ 1 ! α4 ðxÞ ¼ α4 ðyÞ ! α4 is constant

According to the above, if the input is 0, we obtain the following results:


7.1 Deutsch’s Algorithm 137

Fig. 7.1 Four possible 0 0 0 0 0 0 0 0


functions that satisfy the
requirements of the problem
posed by Deutsch
1 1 1 1 1 1 1 1

α1 ð0Þ ¼ 0; α2 ð0Þ ¼ 0; α3 ð0Þ ¼ 1; α4 ð0Þ ¼ 1

And if the input is 1, we obtain the following results:


α1 ð1Þ ¼ 0; α2 ð1Þ ¼ 1; α3 ð1Þ ¼ 0; α4 ð1Þ ¼ 1

In accordance with established criteria for the classification of α, the functions α1


and α4 are constant (because α1 always returns 0 and α4 always returns
1, irrespective of the input values), whereas the functions α2 and α3 are balanced
(because the outputs of α2 and α3 depend on the input values).
From a classical perspective we can solve the problem by considering a Turing
machine M such that
M½αð0Þ; αð1Þ ¼ 1 $ αð0Þ ¼ αð1Þ

and
M½αð0Þ; αð1Þ ¼ 0 $ αð0Þ 6¼ αð1Þ

However, this Turing machine explicitly requires the function α to be evaluated


twice, so the question is whether we can solve the problem with a single evaluation
of α. For this to be possible we need a different Turing machine, M0 , such that
M0 ½αð0Þ ¼ 1 $ αð0Þ ¼ αð1Þ

and
M0 ½αð0Þ ¼ 0 $ αð0Þ 6¼ αð1Þ

However, this new Turing machine cannot be built following the classical
approach because α(1) is not an input of the system. So let us try to solve the
problem using the quantum computing paradigm.
According to the original Deutsch algorithm we assume that we have qubits |0i
and |1i to which we apply the Hadamard transform in order to superposition the
states
138 7 Some Quantum Algorithms

 
1 þ1 j0iþ j1i
H j0i ¼ pffiffiffi ¼ pffiffiffi
2 þ1 2

 
1 þ1 j0i j1i
H j1i ¼ pffiffiffi ¼ pffiffiffi
2 1 2

Now, given two arbitrary inputs |xi and |yi entering the quantum system by two
different lines, we define the unitary transformation of the Deutsch algorithm (UD)
as follows:
UD jx; yi ! jx; y  αðxÞi

But first let us analyze what happens to this unitary transformation with a
simplified version of the Deutsch algorithm. We will ignore the normalization
factors and will configure the input taking into account that there are two lines,
which means that we have to perform the tensor product of the input values.
Ignoring the normalization factors means that
jxi ¼j0iþ j1i; jyi ¼j0i j1i

Note that we are not working in the canonical basis [|0i, |1i], but on the basis
[|0i+ |1i, |0i |1i], so that we can avoid using Hadamard gates.
Applying all the above restrictions,
 

input ¼ jx; yi ¼ jxi  jyi ¼ ððj0i þ j1iÞ  ðj0i  j1iÞÞ

¼ ðj0; 0i  j0; 1i þ j1; 0i  j1; 1iÞ

This expression represents a quantum superposition state that allows a single


evaluation of the function α. Applying the proposed UD transformation to the input,
we obtain the output:
   
φ 
output ¼ U D φinput ¼

ðj0; 0  αð0Þi  j0; 1  αð0Þi þ j1; 0  αð1Þi  j1; 1  αð1ÞiÞ

We now analyze each of the terms of the state |φoutputi:


1. |0, 0  α(0)i
a. α(0) ¼ 0 ! |0, 0  α(0)i¼ |0, 0  0i¼ |0, 0i¼ |0, α(0)i
b. α(0) ¼ 1 ! |0, 0  α(0)i¼ |0, 0  1i¼ |0, 1i¼ |0, α(0)i
2. |0, 1  α(0)i
a. α(0) ¼ 0 ! |0, 1  α(0)i¼ |0, 1  0i¼ |0, 1i¼ |0, NOT α(0)i
b. α(0) ¼ 1 ! |0, 1  α(0)i¼ |0, 1  1i¼ |0, 0i¼ |0, NOT α(0)i
7.1 Deutsch’s Algorithm 139

3. |1, 0  α(1)i
a. α(1) ¼ 0 ! |1, 0  α(1)i¼ |1, 0  0i¼ |1, 0i¼ |1, α(1)i
b. α(1) ¼ 1 ! |1, 0  α(1)i¼ |1, 0  1i¼ |1, 1i¼ |1, α(1)i
4. |1, 1  α(1)i
a. α(1) ¼ 0 ! |1, 1  α(1)i¼ |1, 1  0i¼ |1, 1i¼ |1, NOT α(1)i
b. α(1) ¼ 1 ! |1, 1  α(1)i¼ |1, 1  1i¼ |1, 0i¼ |1, NOT α(1)i
In this way
   
φ 
output ¼ U φinput ¼ Uðj0; 0i  j0; 1i þ j1; 0i  j1; 1iÞ

¼ ðj0; 0  αð0Þi  j0; 1  αð0Þi þ j1; 0  αð1Þi  j1; 1  αð1ÞiÞ

¼ ðj0; αð0Þi  j0; NOTαð0Þi þ j1; αð1Þi  j1; NOTαð1ÞiÞ

¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞ þ j1i  ðjαð1Þi  jNOTαð1ÞiÞ

We apparently have not achieved much, as we still have to evaluate α(0) and
α(1). But recall that
• If α is constant ! α(0) ¼ α(1)
And
 

output ¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞ þ j1i  ðjαð1Þi  jNOTαð1ÞiÞ

¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞþ j1i  ð0jαð0Þi  jNOTαð0ÞiÞ

¼ ðj0i þ j1iÞ  ðjαð0Þi  jNOTαð0ÞiÞ

• If α is balanced ! α(0) ¼ NOT α(1)


And
 

output ¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞ þ j1i  ðjαð1Þi  jNOTαð1ÞiÞ

¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞ þ j1i  ðjNOTαð0Þi  jαð0ÞiÞ

¼ j0i  ðjαð0Þi  jNOTαð0ÞiÞ  j1i  ðjαð0Þi  jNOTαð0ÞiÞ

¼ ðj0i  j1iÞ  ðjαð0Þi  jNOTαð0ÞiÞ

We now only have to measure the first qubit to know whether α is constant or
balanced. In this simplified approach the corresponding measurement has to be
done in the non-canonical basis
fj0i þ j1i; j0i  j1ig

If we obtain (|0i + |1i) after measuring the first qubit, then α is constant, and
conversely, if we obtain (|0i |1i), then α is balanced.
140 7 Some Quantum Algorithms

Fig. 7.2 Quantum circuit for the Deutsch problem

The Original Deutsch Approach


To solve the problem using the original Deutsch approach we have to work on the
canonical basis
fj0i; j1ig

Deutsch designed the quantum circuit depicted in Fig. 7.2, where H represents
Hadamard gates, UD performs the unitary transformation of Deutsch, and the
speaker symbol indicates that the measurement is made on the corresponding line.
Hadamard gates are important for quantum algorithms in general, but especially
so for Deutsch’s algorithm, based as it is on the superposition of states. In order to
understand Deutsch’s algorithm, we need to remember that, as happens with
reversible gates in quantum circuits, sequentially applying Hadamard gates an
even number of times to a given initial state returns the initial state. This is because
H  H ¼ H2 ¼ I, where I is the identity matrix. Application of two Hadamard gates
in parallel, however, as in our case, gives the tensor product of two states in
superposition. For example,
   
ðH  H Þj1ij1i ¼ ðH j1iÞðH j1iÞ ¼ 1=√2 ðj0i  j1iÞ 1=√2 ðj0i  j1iÞ

¼ ð1=2Þðj00i  j01i  j10i þ j11iÞ

We will call the parallel application of n Hadamard gates on n-qubits the


Hadamard transformation, denoted Hn. H3|0i |0i |0i, for example, is interpreted
as follows:

H 3 ðj0ij0ij0iÞ

¼ ðH  H  H Þj000i ¼ ðH j0iÞðH j0iÞðH j0iÞ


     
¼ 1=√2 ðj0i þ j1iÞ 1=√2 ðj0i þ j1iÞ 1=√2 ðj0i þ j1iÞ
 3
¼ 1=√2 ðj000i þ j001i þ j010i þ j011i þ j100i þ j101i þ j110i þ j111iÞ
7.1 Deutsch’s Algorithm 141

We can now write the following general equation:

1 2X 1
n

H n j0in ¼ pffiffiffiffinffi jxi


2 x¼0

Returning to the original formulation of the problem by Deutsch, as mentioned,


the blocks labeled H in Fig. 7.2 are Hadamard gates, whose operation we know to
be as follows:
 
1 þ1 j0i þ j1i
H j0i ¼ pffiffiffi ¼ pffiffiffi
2 þ1 2

 
1 þ1 j0i  j1i
H j1i ¼ pffiffiffi ¼ pffiffiffi
2 1 2

The block labeled UD makes the transformation


U D jxi ; yi i ¼ jxi ; yi  αðxi Þi

In the algorithm to be described below, we force the inputs to block UD to be in a


state of quantum superposition, achieved by means of Hadamard gates. As can be
deduced from Fig. 7.2, the procedure is as follows:
 E  2 

output ¼ ðH  I ÞU D H j0ij1i

The algorithm as a whole involves the following steps:


1. Define an initial state |φinputi¼ |0i|1i and apply the Hadamard gates in parallel
in order to generate the tensor product of the state in quantum superposition.
2. Apply the UD transformation to this new state.
3. Apply a Hadamard gate to the first qubit (upper line), leaving the second qubit
(lower line) unchanged.
The process evolves as follows:
1. |φ0i¼ |0i |1i
2. |φ1i¼ H2|φ0i
  
j0i þ j1i j0i  j1i 1
¼ pffiffiffi pffiffiffi ¼ fj0ij0i  j0ij1i þ j1ij0i  j1ij1ig
2 2 2

• U D j0ij0i ¼ j0ij0  αð0Þi ¼j0ijαð0Þi

• U D j0ij1i ¼ j0ij1  αð0Þi ¼j0ijNOT αð0Þi


142 7 Some Quantum Algorithms

○ α(0) ¼ 0 ! NOT α(0) ¼ 1:1  α(0) ¼ 1 ¼ NOT α(0)


○ α(0) ¼ 1 ! NOT α(0) ¼ 0:1  α(0) ¼ 0 ¼ NOT α(0)
• U D j1ij0i ¼ j1ij0  αð1Þi ¼j1i jαð1Þi

• U D j1ij1i ¼ j1ij1  αð1Þi ¼j1i jNOT αð1Þi

○ α(1) ¼ 0 ! NOT α(1) ¼ 1:1  α(1) ¼ 1 ¼ NOT α(1)


○ α(1) ¼ 1 ! NOT α(1) ¼ 0:1  α(1) ¼ 0 ¼ NOT α(1)

Therefore
j φ2 i ¼ U D j φ1 i
1 
¼ j0ijαð0Þi  j0ijNOTα ð0Þi þ j1ijαð1Þi  j1ijNOT αð1Þi
2

Case 1: α(0) ¼ α(1)


1
jφ2 i ¼ ðj0ijαð0Þi  j0ijNOTαð0Þi þ j1ijαð0Þi  j1ijNOT αð0ÞiÞ
2
1     
¼ 0i þ j1i αð0Þi  0i þ j1i NOTαð0Þi
2
1   
¼ 0i þ j1i α ð0Þi  jNOTαð0Þi
2

Case 2: α(0) 6¼ α(1)


1
j φ2 i ¼ ðj0ijα ð0Þi  j0ijNOT αð0Þi þ j1ijNOTαð0Þi  j1ijαð0ÞiÞ
2
1     
¼ 0i  j1i αð0Þi  0i  j1i NOTα ð0Þi
2
1
¼ ððj0i  j1iÞðjαð0Þi  jNOTαð0ÞiÞÞ
2

3. |φ3i¼ (H  I) |φ2i

Case 1: α(0) ¼ α(1)


1   
j φ3 i ¼ ð H  I Þ 0i þ j1i αð0Þi  jNOTαð0Þi
2
!
1 2
¼ pffiffiffi ðjαð0Þi  jNOTαð0ÞiÞ
2 2 0

1
¼ pffiffiffi j0ifjαð0Þi  jNOTαð0Þig
2
7.1 Deutsch’s Algorithm 143

Case 2: α(0) 6¼ α(1)


1   
j φ3 i ¼ ð H  I Þ 0i  j1i αð0Þi  jNOTαð0Þi
2
!
1 0
¼ pffiffiffi ðjαð0Þi  jNOTαð0ÞiÞ
2 2 2

1
¼ pffiffiffi j1ifjα ð0Þi  jNOT α ð0Þig
2

We can now measure the first qubit (upper line), which will collapse to become a
conventional bit. If the result of the measurement is a bit 0, then α is constant, and
conversely, if the result of the measurement is a bit 1, then α is balanced.
Another Perspective on Deutsch’s Algorithm
There is yet another way to consider Deutsch’s algorithm, and interestingly, it
contains a term that helps explain the Deutsch-Jozsa algorithm. Given the ground-
work done above, we can progress rapidly from this point, but will explain the new
term in some detail.
We use the same quantum circuit analyzed above and the same first steps as
those previously described:
Input information: |φ0i¼ |0i |1i

j0iþj1i j0ij1i
Quantum superposition: jφ1 i ¼ H 2 j φ0 i ¼ pffiffi pffiffi
2 2

Assume that
   
j0iþ j1i j0i j1i
jxi ¼ pffiffiffi ; jyi ¼ pffiffiffi
2 2

If we do not make |xi explicit but do make |yi explicit, then the state |φ1i can be
written as follows:
 
j 0i  j 1i
jφ1 i ¼ jxi pffiffiffi
2

The next step is to obtain |φ2i from |φ1i and UD such that
 
j0i j1i
jφ2 i ¼ U D jxi pffiffiffi
2
 
jxi j0  αðxÞi  jxi j1  αðxÞi
¼ pffiffiffi
2
 
j0  αðxÞi j1  αðxÞi
¼ jxi p ffiffi

2
144 7 Some Quantum Algorithms

Now we will see what happens with


 
j0  αðxÞi j1  αðxÞi
pffiffiffi
2

depending on what values we have for α(x):


• If α(x) ¼ 0, then
     
j0  αðxÞi j1  αðxÞi j0i j1i αð0Þ j0i j1i
pffiffiffi ¼ pffiffiffi ¼ ð1Þ pffiffiffi
2 2 2

• If α(x) ¼ 1, then
     
j0  αðxÞi j1  αðxÞi j0i j1i j0i j1i
pffiffiffi ¼ pffiffiffi ¼ ð1Þαð1Þ pffiffiffi
2 2 2

The general expression can therefore be written as follows:


     
j0i j1i αðxÞ j0i j1i αðxÞ j0i j1i
U D jxi pffiffiffi ¼ jxið1Þ pffiffiffi ¼ ð1Þ jxi pffiffiffi
2 2 2

But |xi is in superposition:


 
j0iþ j1i
jxi ¼ pffiffiffi
2

Hence, the term (1)α(x) |xi should be written as

ð1Þαð0Þ j0i þ ð1Þαð1Þ j1i


pffiffiffi
2

Particular cases are as follows:


 
j0iþ j1i
αð0Þ ¼ 0 and αð1Þ ¼ 0 ! þ pffiffiffi
2

 
j0iþ j1i
αð0Þ ¼ 1 and αð1Þ ¼ 1 !  pffiffiffi
2

 
j0i j1i
αð0Þ ¼ 0 and αð1Þ ¼ 1 ! þ pffiffiffi
2
7.2 The Deutsch-Jozsa Algorithm 145

 
j0i j1i
αð0Þ ¼ 1 and αð1Þ ¼ 0 !  pffiffiffi
2

And we obtain the following results:


 2
 1=√2 ðj0i þ j1iÞðj0i  j1iÞ , αð0Þ ¼ αð1Þ

 2
 1=√2 ðj0i  j1iÞðj0i  j1iÞ , αð0Þ 6¼ αð1Þ

It is now time to go through the last Hadamard gate, which operates in the upper
line of the quantum circuit proposed by Deutsch. The results are as follows:
 
 1=√2 j0iðj0i  j1iÞ , αð0Þ ¼ αð1Þ

 
 1=√2 j1iðj0i  j1iÞ , αð0Þ 6¼ αð1Þ

The last step consists of measuring the first qubit in such a way that if the result
of the measurement is a bit 0, then α(x) is constant, and if the result of the
measurement is a bit 1, then α(x) is balanced.
The novelty of this way of looking at Deutsch’s algorithm lies in the term (1)α(x),
which plays an important role in the Deutsch-Jozsa algorithm.

7.2 The Deutsch-Jozsa Algorithm

The Deutsch-Jozsa algorithm, a generalization of Deutsch’s algorithm, was one


of the first algorithms designed to be executed on a quantum computer. Since
the Deutsch-Jozsa algorithm is based on the principles of intrinsic parallelism
and quantum superposition of states, it is more efficient than classical
algorithms.
In the Deutsch-Jozsa problem we have a function α that is a black box with
n input bits that generate a given output. We say that α is constant if the outputs are
either all 0 or all 1 and that α is balanced if the outputs are half and half 0 and 1. The
problem to be solved is to verify whether α is constant or balanced, which we do by
observing outputs after feeding the black box with inputs.
To generalize Deutsch’s algorithm, let us consider a function α implemented in a
quantum circuit and the operation of a unitary transformation UDJ, such that
U DJ jxi jyi !jxi jy  αðxÞi
146 7 Some Quantum Algorithms

In the above expression, |xi is a string with a number n of zeros and ones. For
example, if n ¼ 5, then |xicould be |1, 1, 0, 0, 1i¼ |11001i |25i. The following
configuration is useful for evaluating α(x):
U DJ jxi j0i !jxi j0  αðxÞi ¼jxi jαðxÞi

The most important part of the process is to correctly select the initial input to the
state of quantum superposition. An initial state of n qubits in quantum superposition
is represented by means of the equation
1
pffiffiffiffinffiðj01 ; . . . ; 0n1 ; 0n i þ j01 ; . . . ; 0n1 ; 1n i þ j01 ; . . . ; 1n1 ; 0n i þ
2
þj11 ; . . . ; 1n1 ; 1n i Þ

1 2X 1
n

¼ pffiffiffiffinffi jxi
2 x¼0

Consequently,
!
1 2X 1
1 2X 1
1 2X 1
n n n

U DJ pffiffiffiffinffi jxij0i ¼ pffiffiffiffinffi U DJ jxij0i ¼ pffiffiffiffinffi jxijαðxÞi


2 x¼0 2 x¼0 2 x¼0

This is quantum parallelism, by means of which the operator UDJ is applied


simultaneously to all vectors of the basis that define the corresponding state of
quantum superposition. Quantum parallelism thus enables exponential growth
within the computation space.
The Deutsch-Jozsa algorithm, as mentioned, is a generalization of the Deutsch
algorithm that determines whether a function of n qubits is constant or balanced.
Our purpose is to construct a bridge between the two approaches, and, to describe
the former, we need to bear in mind the UD transformation performed by the latter.
In the Deutsch problem, we considered that
   
j0i  j1i jxi j0  αðxÞi jxi j1  αðxÞi
U D jxi pffiffiffi ¼ pffiffiffi
2 2
 
j0  αðxÞi j1  αðxÞi
¼ jxi p ffiffi

2

Also, depending on the values of α(x), we obtained the following result:


• If α(x) ¼ 0, then
     
j0  αðxÞi j1  αðxÞi j0i j1i αð0Þ j0i j1i
pffiffiffi ¼ pffiffiffi ¼ ð1Þ pffiffiffi
2 2 2
7.2 The Deutsch-Jozsa Algorithm 147

• If α(x) ¼ 1, then
     
j0  αðxÞi j1  αðxÞi j0i j1i αð1Þ j0i j1i
pffiffiffi ¼ pffiffiffi ¼ ð1Þ pffiffiffi
2 2 2

The general expression could therefore be written as follows:


     
j0i  j1i j0i  j1i j 0i  j 1i
U D jxi pffiffiffi ¼ jxið1ÞαðxÞ pffiffiffi ¼ ð1ÞαðxÞ jxi pffiffiffi
2 2 2

Let us now establish the bridge between the two approaches.


The qubit |xi is in a state of superposition:
jxi ¼ α0 j0i þ α1 j1i

It is therefore clear that


   
j0i  j1i j0i j1i
U D jxi pffiffiffi ¼ U D ðα0 j0i þ α1 j1iÞ pffiffiffi

j0i  j1i
2 2

αð0Þ αð1Þ
¼ ð1Þ α0 j0i þ ð1Þ α1 j1i pffiffiffi
2
X  
1
j 0i  j 1i
¼ ð1ÞαðxÞ αx jxi pffiffiffi
x¼0 2

In the Deutsch-Jozsa approach, the superposition of states is given by the parallel


application of n Hadamard gates. Hence

1 2X 1
n

n n
H j 0i ¼ pffiffiffiffinffi jxi
2 x¼0

Then
   
1 2X 1
1 2X 1
n n
j0i  j1i αðxÞ j0i  j1i
p
U DJ nffiffiffiffi
ffi jxi p ffiffi
ffi ¼ p ffiffiffiffi
ffi ð1Þ jxi p ffiffi

2 x¼0 2 2n x¼0 2

To study the general Deutsch-Jozsa algorithm we will use the quantum circuit
depicted in Fig. 7.3.
The algorithm begins with a state of n + 1 qubits of the type

j0in j1i
148 7 Some Quantum Algorithms

n
|0〉 H⊗n H⊗n

UDJ

|1〉 H

|ϕ0〉 |ϕ1〉 |ϕ2〉 |ϕ3〉

Fig. 7.3 Quantum circuit for the Deutsch-Jozsa problem

To generate the input to the Deutsch-Jozsa unitary transformation, UDJ, we have


to perform the Hadamard transformation on all the qubits, bearing in mind that we
have two lines. This gives the following result:

1 2X 1
n

jφ1 i ¼ pffiffiffiffiffiffiffiffiffi jxiðj0i  j1iÞ


2nþ1 x¼0

We now apply the UDJ transformation to |φ1i and obtain

1 2X 1
n

jφ2 i ¼ U DJ jφ1 i ¼ pffiffiffiffiffiffiffiffiffi jxiðjαðxÞi  j1  αðxÞiÞ


2nþ1 x¼0
1 2X 1
n

¼ pffiffiffiffiffiffiffiffiffi ð1ÞαðxÞ jxiðj0i  j1iÞ


2nþ1 x¼0

What follows is not so obvious but is explained as follows. First, in accordance


with Fig. 7.3, we now have to work on the upper line and perform a new Hadamard
transformation on its n qubits. As can be seen in the previous equation,

  2X
n
1 X
φ2UpperLine ¼ p1ffiffiffiffiffi 1
ð1ÞαðxÞ jxi  pffiffiffiffinffi ð1ÞαðxÞ jxi
n
2 x¼0 2 x2f0;1gn

Therefore
   
φ3UpperLine ¼ H n φ2UpperLine

"n #
 1 2X 1 2X 1
1 2X 1 2X1
n n n
αðxÞ x z αðxÞ x z
jφ3UpperLine ¼ n ð1Þ ð1Þ jzi¼ n ð1Þ ð1Þ jzi
2 x¼0 z¼0
2 x¼0 z¼0
7.2 The Deutsch-Jozsa Algorithm 149

This can be written in more compact form as follows:


"n #
 1 2X 1 2X1
n
αðxÞþx z
jφ3UpperLine ¼ n ð1Þ j zi
2 x¼0 z¼0

The above equations are equivalent to those that follow:


 1 X X
jφ3UpperLine ¼ n ð1ÞαðxÞ ð1Þx z jzi
2 x2f0;1gn z2f0;1g n
2 3
1 X X
¼ n 4 ð1ÞαðxÞ ð1Þx z 5 jzi
2 x2f0;1gn z2f0;1gn

2 3
 1 X X
jφ3UpperLine ¼ n 4 ð1ÞαðxÞx z 5 jzi
2 x2f0;1g n
z2f0;1g n

In the last equation


x z ¼ x0 z0  x1 z1   xn1 zn1

Note that x z is either 0 or 1, and that α(x) is either 0 or 1.


Therefore the factor

ð1ÞαðxÞx z

is related to the sign of each individual term in the equation. We can now
perform a measurement on the upper line in order to evaluate the probability
P(|0in).
Obviously
• If P(|0in) ¼ 1, then α is constant
• If P(|0in) ¼ 0, then α is balanced
We can also observe |zi after performing the measurement.
Thus
• If z ¼ (0, 0, . . ., 0), then α is constant
• If z 6¼ (0, 0, . . ., 0), then α is balanced
This may seem excessively abstract, so let us illustrate the whole procedure with
an example. First, consider the quantum circuit defined for the Deutsch-Jozsa
algorithm (Fig. 7.3). For the sake of clarity, we will assume n ¼ 2. Thus
150 7 Some Quantum Algorithms

jφ0 i ¼ j0ij1i ¼ j00ij1i

In the above expression the first ket corresponds to the upper line, and the second
ket corresponds to the lower line. To put the upper line in a state of quantum
superposition we need two Hadamard gates:
 
0i ! H 2 0i ¼ Hj0iH j0i

2
¼ p1ffiffi f j00i þ j01i þ j10i þ j11ig
2

The previous expression is equivalent to

1 2X 1
n
1
pffiffiffiffiffi f j0i þ j1i þ j2i þ j3ig ¼ pffiffiffiffiffiffin jxi
22 2 x¼0

The next step is to build the input of the unitary transformation UDJ. Since the
second line is also in a state of quantum superposition, and since the two lines enter
in parallel into the transformation UDJ, we need to use the tensor product. First let us
recall the general approach:

1 2X 1
n

n j0i j1i
j φ1 i ¼ ð H  HÞjφ0 i ¼ pffiffiffiffinffi jxi pffiffiffi
2 x¼0 2

Taking into account that


   
j0i j1i jxij0i jxi j1i
U D ¼ jxi pffiffiffi ¼ UD pffiffiffi
2 2
 
1
¼ pffiffiffi fðjxij0  αðxÞiÞ  ðjxij1  αðxÞiÞg
2

• If αðxÞ ¼ 0 ! þ p1ffiffi fðjxij0iÞ  ðjxij1iÞg


2

• If αðxÞ ¼ 1 !  p1ffiffi2 fðjxij0iÞ  ðjxij1iÞg

And of course
 
j0i  j1i j0i  j1i
U D jxi pffiffiffi ¼ ð1ÞαðxÞ jxi pffiffiffi
2 2
7.2 The Deutsch-Jozsa Algorithm 151

Then

1 2X 1
n
j0i  j1i
jφ2 i ¼ U DJ jφ1 i ¼ pffiffiffiffinffi ð1ÞαðxÞ jxi pffiffiffi
2 x¼0 2

Returning to our example, in which n ¼ 2, we have


1 n o j0i  j1i
αð0Þ αð1Þ αð2Þ αð3Þ
jφ2 i ¼ pffiffiffiffiffi ð1Þ j0i þ ð1Þ j1i þ ð1Þ j2i þ ð1Þ j3i pffiffiffi
22 2

To simplify, we can say that


8 αð0Þ αð1Þ
9
1 < ð1Þ j0i þ ð1Þ j1i =
jAi ¼ pffiffiffiffiffi
22 : þð1Þαð2Þ j2i þ ð1Þαð3Þ j3i ;

For n ¼ 2 it holds that

0  ð00Þ; 1  ð01Þ; 2  ð10Þ; 3  ð11Þ

We consequently have

H 2 jAi8 9
>
> αð0Þ j0iþ j1i j0iþ j1i αð1Þ j0iþ j1i j0i j1i >>
>
> ð 1 Þ p ffiffi
ffi p ffiffi
ffi þ ð 1 Þ p ffiffi
ffi p ffiffi
ffi >
>
1 < 2 2 2 2 =
¼ pffiffiffiffiffi
22 >
>
> αð2Þ j0i j1i j0iþ j1i j0i j1i j0i j1i >
>
>
>
: þð1Þ pffiffiffi pffiffiffi þ ð1Þαð3Þ pffiffiffi pffiffiffi > ;
2 2 2 2

We can write the above equation more explicitly as follows:


( j00iþ j01iþ j10iþ j11i
2 1 ð1Þαð0Þ pffiffiffiffiffi
H jAi ¼ pffiffiffiffiffi 22
2
2

j00i j01iþ j10i j11i


þ ð1Þαð1Þ pffiffiffiffiffi
22
j00iþ j01i j10i j11i
þ ð1Þαð2Þ pffiffiffiffiffi
22
)
αð3Þ j00i j01i j10iþ j11i
þ ð1Þ pffiffiffiffiffi
22
152 7 Some Quantum Algorithms

We can now return to the original formulation:


(
1 j0iþ j1iþ j2iþ j3i
H jAi ¼ pffiffiffiffiffi ð1Þαð0Þ
2
pffiffiffiffiffi
2
2 22
j0i j1iþ j2i j3i
þð1Þαð1Þ pffiffiffiffiffi
22
j0iþ j1i j2i j3i
þð1Þαð2Þ pffiffiffiffiffi
22
)
αð3Þ j0i j1i j2iþ j3i
þð1Þ pffiffiffiffiffi
22

Performing some minor operations, we easily obtain


   nh i
1 1
2
H jAi ¼ pffiffiffiffiffi pffiffiffiffiffi ð1Þαð0Þ þ ð1Þαð1Þ þ ð1Þαð2Þ þ ð1Þαð3Þ j0i
22 22
h i
þ ð1Þαð0Þ  ð1Þαð1Þ þ ð1Þαð2Þ  ð1Þαð3Þ j1i
h i
þ ð1Þαð0Þ þ ð1Þαð1Þ  ð1Þαð2Þ  ð1Þαð3Þ j2i
h i o
þ ð1Þαð0Þ  ð1Þαð1Þ  ð1Þαð2Þ þ ð1Þαð3Þ j3i

Now to explain the change in signs. Following the previous equation, is easy to
see that, for n ¼ 2
fαð0Þ  αð00Þg; fαð1Þ  αð01Þg; fαð2Þ  αð10Þg; fαð3Þ  αð11Þg

The above terms can also be written as follows:


α ðxÞ ¼ α ðx1 ; x2 Þ=α, x1 , x2 2 f0; 1g

Now consider a given z with n ¼ 2. Analogously


z ¼ ðz1 ; z2 Þ=z1 , z2 2 f0; 1g

Now consider the inner product hx, zi ¼ x z, defined as follows:


hx; zi ¼ x z ¼ ðx1 ; x2 Þ ðz1 ; z2 Þ ¼ x1 z1  x2 z2

Table 7.1 shows the inner product results.


7.2 The Deutsch-Jozsa Algorithm 153

Table 7.1 Inner products for the vectors x and z


z#, x! (0,0) (0,1) (1,0) (1,1)
L L L L
(0,0) 00 00¼0 00 10¼0 10 00¼0 10 10¼0
L L L L
(0,1) 00 01¼0 00 11¼1 10 01¼0 10 11¼1
L L L L
(1,0) 01 00¼0 01 10¼0 11 00¼1 11 10¼1
L L L L
(1,1) 01 01¼0 01 11¼1 11 01¼1 11 11¼0

The change in signs is obtained through the inner product since

ð1Þ0 ¼ þ1; ð1Þ1 ¼ 1

Putting all the above together, each term is

ð1Þx:z ð1ÞαðxÞ jzi ¼ ð1Þx:zþαðxÞ jzi

The auxiliary expression is reconstructed as follows:

1 X3 X 3
1 X
3 X 3
H 2 jAi ¼ 2
ð1Þx:zþαðxÞ jzi ¼ 2 ð1Þx:zþαðxÞ jzi
2 x¼0 z¼0 2 z¼0 x¼0

The generalization to any n is as follows:

1 2X 1 2X 1
1 2X 1 2X 1
n n n n
x:zþαðxÞ
n
H jAi ¼ n ð1Þ j zi ¼ n ð1Þx:zþαðxÞ jzi
2 x¼0 z¼0 2 z¼0 x¼0

We can now build the output of the unitary transformation UDJ of the Deutsch-
Jozsa quantum circuit:

n 1 X2n 1 X2n 1 x:zþαðxÞ j0i  j1i
jφ3 i ¼ ðH  I Þjφ2 i ¼ n ð1Þ j zi pffiffiffi
2 z¼0 x¼0 2

Remember that the last step involves measurement of the first qubit:

1 2X 1 2X 1
n n

n ð1Þx:zþαðxÞ jzi
2 z¼0 x¼0

Thus, for n ¼ 2, if we make the part of the equation that represents the first qubit
explicit, then we have
154 7 Some Quantum Algorithms

Table 7.2 Results for the x z + α(0) x z + α(1) x z + α(2) x z + α(3) |zi
auxiliary ket A of the example
0 + α(0) 0 + α(1) 0 + α(2) 0 + α(3) |0i
0 + α(0) 1 + α(1) 0 + α(2) 1 + α(3) |1i
0 + α(0) 0 + α(1) 1 + α(2) 1 + α(3) |2i
0 + α(0) 1 + α(1) 1 + α(2) 0 + α(3) |3i

 nh i
1
jAi ¼ ð1Þ0þαð0Þ þ ð1Þ0þαð1Þ þ ð1Þ0þαð2Þ þ ð1Þ0þαð3Þ j0i
4
h i
þ ð1Þ0þαð0Þ þ ð1Þ1þαð1Þ þ ð1Þ0þαð2Þ þ ð1Þ1þαð3Þ j1i
h i
þ ð1Þ0þαð0Þ þ ð1Þ0þαð1Þ þ ð1Þ1þαð2Þ þ ð1Þ1þαð3Þ j2i
h i o
þ ð1Þ0þαð0Þ þ ð1Þ1þαð1Þ þ ð1Þ1þαð2Þ þ ð1Þ0þαð3Þ j3i

The results are more easily viewed as presented in Table 7.2.


Returning to our example in which n ¼ 2, let us analyze the results:
If α(0) ¼ α(1) ¼ α(2) ¼ α(3) ! the function is constant. In this case, the result
will always be zero after measuring the first qubit since the other terms are mutually
cancelled. Any other result means that the function is balanced. Therefore, for a
constant function it holds that:
• If α(x) ¼ 0 ! (1/4) {(1)0 + (1)0 + (1)0 + (1)0} |0i¼ +|0i
• If α(x) ¼ 1 ! (1/4) {(1)1 + (1)1 + (1)1 + (1)1} |0i¼ |0i
Obviously, if on measuring the outcome we obtain the value zero, with proba-
bility one this result confirms that the function α is constant.

7.3 Simon’s Algorithm

Daniel Simon proposed a very interesting problem and a very clever solution. The
problem was to find patterns in functions by means of a procedure that combines
quantum and classical methods.
Let α be a given function such that
α : f0; 1gn ! f0; 1gn

Assume that α can be evaluated, but is presented to us as a black box. We know


of the existence of a hidden binary chain,
c ¼ c0 c1 . . . cn1
7.3 Simon’s Algorithm 155

where c is the period of the function α.


c ¼ c0 c1 . . . cn1 ! 8x8y 2 f0; 1gn αðxÞ ¼ αðyÞ $ x ¼ y  c

The goal is to find said period. Note that if


• c ¼ 0n, then the function is 1-to-1
• c¼6 0n, then the function is 2-to-1
The following example shows how this works. Assume the standard values used
to explain this algorithm, namely, that n ¼ 3 and that c ¼ (101). The classical
solution involves the following steps:
1. Evaluate α several times
2. If α returns the same value for x1 and x2 then go to step 3
3. x1 ¼ x2  c ! x1  x2 ¼ x2  c  x2 ¼ c
Table 7.3 helps clarify what this means.
If we adopt a classical approach, the number of evaluations to be performed, in
the worst case scenario (why?) will be
2n
þ 1 ¼ 2n1 þ 1
2

In his quantum approach, Simon proposed the unitary transformation and algo-
rithm given below, along with the circuit depicted in Fig. 7.4. Note that the whole
process has to be repeated several times in order to take into account the probabi-
listic nature of the quantum approach.
• Unitary transformation: Us |xi|yi¼ |xi|y  α(x)i
• Algorithm: (Hn  I) Us (Hn  I) |0i|0i

First step:

jφ0 i ¼ j0ij0i

Second step:

Table 7.3 Example of L


y c x¼y c α( y) ¼ α(x)
Simon’s problem showing
000 101 101 α(000) ¼ α(101)
values for α
001 101 100 α(001) ¼ α(100)
010 101 111 α(010) ¼ α(111)
011 101 110 α(011) ¼ α(110)
100 101 001 α(100) ¼ α(001)
101 101 000 α(101) ¼ α(000)
110 101 011 α(110) ¼ α(011)
111 101 010 α(111) ¼ α(010)
156 7 Some Quantum Algorithms

H⊗n H⊗n
|0〉
Us

|0〉
|ϕ0〉 |ϕ1〉 |ϕ2〉 |ϕ3〉

Fig. 7.4 Quantum circuit for Simon’s algorithm

1 X 1 2X
n
1
jφ1 i ¼ pffiffiffiffinffi jxij0i ¼ pffiffiffiffinffi jxij0i
2 x2f0;1gn 2 x¼0

Third step:

1 X 1 2X
n
1
jφ2 i ¼ pffiffiffiffinffi jxijαðxÞi ¼ pffiffiffiffinffi jxijαðxÞi
2 x2f0;1gn 2 x¼0

Fourth step:

1 X X
j φ3 i ¼ ð1Þhz;xi jzijαðxÞi
2n x2f0;1gn z2f0;1gn

1 2X
12X
1
n n

¼ n ð1Þx:z jzijαðxÞi
2 x¼0 z¼0

In applying the algorithm, it can be seen that the operations with zeros and ones
could become a nightmare of confusion. We propose using decimal numbers to
avoid this problem. For example, for n ¼ 3, and following a similar approach to that
used earlier, we have
ð000Þ  0; ð001Þ  1; ð010Þ  2; ð011Þ  3

ð100Þ  4; ð101Þ  5; ð110Þ  6; ð111Þ  7

These numbers are presented in tabular form in Table 7.4. As with the Deutsch-
Jozsa algorithm, using such a table can help clarify the change in signs.
We now do the same with the values of α used in our example (Table 7.3).

α(0) ¼ 4 α(1) ¼ 1 α(2) ¼ 5 α(3) ¼ 7 α(4) ¼ 1 α(5) ¼ 4 α(6) ¼ 7 α(7) ¼ 5


7.3 Simon’s Algorithm 157

Table 7.4 Change of sign in 0 1 2 3 4 5 6 7


Simon’s algorithm
000 001 010 011 100 101 110 111
0 000 0 0 0 0 0 0 0 0
1 001 0 1 0 1 0 1 0 1
2 010 0 0 1 1 0 0 1 1
3 011 0 1 1 0 0 1 1 0
4 100 0 0 0 0 1 1 1 1
5 101 0 1 0 1 1 0 1 0
6 110 0 0 1 1 1 1 0 0
7 111 0 1 1 0 1 0 0 1

It is not so difficult to identify the period of the function α because this is an


academic example and so is very simple. Below we apply Simon’s procedure and
quantum circuit for n ¼ 3:
• First step:

jφ0 i ¼ j0ij0i

• Second step:

1 X 1 2X
n
1
jφ1 i ¼ pffiffiffiffinffi jxij0i ¼ pffiffiffiffinffi jxij0i
2 x2f0;1gn 2 x¼0

1
jφ1 i ¼ pffiffiffi fj0i þ j1i þ j2i þ j3i þ j4i þ j5i þ j6i þ j7igj0i
8

• Third step:

1 X 1 2X
n
1
jφ2 i ¼ pffiffiffiffinffi jxijαðxÞi ¼ pffiffiffiffinffi jxijαðxÞi
2 x2f0;1gn 2 x¼0

8 9
1 < j0i jαð0Þiþ j1i jαð1Þiþ j2i jαð2Þiþ j3i jαð3Þi =
jφ2 i ¼ pffiffiffi
8: þ j4i jαð4Þiþ j5i jαð5Þiþ j6i jαð6Þiþ j7i jαð7Þi ;

1
¼ pffiffiffifj0ij4i þ j1ij1i þ j2ij5i þ j3ij7i þ j4ij1i þ j5ij4i þ j6ij7i þ j7ij5ig
8
158 7 Some Quantum Algorithms

• Fourth step:

1 X X
j φ3 i ¼ ð1Þhz;xi jzijαðxÞi
2n x2f0;1gn z2f0;1gn

1 2X 12X
1
n n

¼ pffiffiffiffinffi ð1Þx:z jzijαðxÞi


2 x¼0 z¼0

1
jφ3 i ¼ fj0i þ j1i þ j2i þ j3i þ j4i þ j5i þ j6i þ j7ig j4i
8
1
þ fj0i  j1i þ j2i  j3i þ j4i  j5i þ j6i  j7ig j1i
8
1
þ fj0i þ j1i  j2i  j3i þ j4i þ j5i  j6i  j7ig j5i
8
1
þ fj0i þ j1i þ j2i þ j3i  j4i  j5i  j6i  j7ig j1i
8
1
þ fj0i þ j1i  j2i  j3i  j4i  j5i þ j6i þ j7ig j7i
8
1
þ fj0i  j1i  j2i þ j3i  j4i þ j5i þ j6i  j7ig j5i
8

Note how some elements disappear because of the change in sign. We can now
rewrite |φ3i as follows:
jφ3 i ¼

1 1
þ fj0i þ j2i þ j5i þ j7ig j4iþ fj0i þ j2i  j5i  j7ig j1i
8 8
1 1
þ fj0i þ j2i þ j5i þ j7ig j4iþ fj0i þ j2i  j5i  j7ig j1i
8 8
1 1
þ fj0i  j2i þ j5i  j7ig j5iþ fj0i  j2i  j5i þ j7ig j7i
8 8
1 1
þ fj0i  j2i þ j5i  j7ig j5iþ fj0i  j2i  j5i þ j7ig j7i
8 8
7.3 Simon’s Algorithm 159

The final result for |φ3i is as follows:


2 2
jφ3 i ¼ fj0i ½j4iþj1iþj5iþj7igþ fj2i ½j4iþj1ij5ij7ig
8 8
2 2
þ fj5i ½j4ij1iþj5ij7igþ fj7i ½j4ij1ij5ij7ig
8 8

We now perform several measurements that will yield different results. These
are the different possibilities:
• The measurement of the first qubit is 0  (000) ! h000, ci¼ 0
• The measurement of the first qubit is 2  (010) ! h010, ci¼ 0
• The measurement of the first qubit is 5  (101) ! h101, ci¼ 0
• The measurement of the first qubit is 7  (111) ! h111, ci¼ 0
We can now write c ¼ c1c2c3 and obtain a system of equations that can easily be
solved:
• If: h000, c1c2c3i¼ 0 ! (0  c1)  (0  c2)  (0  c3) ¼ 0 ! trivial solution
• If: h010, c1c2c3i¼ 0 ! (0  c1)  (1  c2)  (0  c3) ¼ 0 ! c2 ¼ 0
• If: h101, c1c2c3i¼ 0 ! (1  c1)  (0  c2)  (1  c3) ¼ 0 ! c1  c3 ¼ 0
In this case
c1 ¼ c3 ¼ 0 or c1 ¼ c3 ¼ 1

If: h111, c1c2c3i¼ 0 ! (1  c1)  (1  0)  (1  c3) ¼ 0


• (1  0)  (1  0)  (1  0) ¼ 0 ! trivial solution
• (1  1)  (1  0)  (1  1) ¼ 0 ! c1 ¼ c3 ¼ 1
Therefore, c ¼ 101 is the period of the function. To check our results, we will use
Table 7.3, from which we can easily verify that
αð0Þ ¼ αð000Þ  αð5Þ ¼ αð101Þ : c ¼ 101 : 000 ¼ 101  101

αð1Þ ¼ αð001Þ  αð4Þ ¼ αð100Þ : c ¼ 101 : 001 ¼ 100  101

αð2Þ ¼ αð010Þ  αð7Þ ¼ αð111Þ : c ¼ 101 : 010 ¼ 111  101

αð3Þ ¼ αð011Þ  αð6Þ ¼ αð110Þ : c ¼ 101 : 011 ¼ 110  101

To conclude, using the classical approach we need to perform

2n1 þ 1

evaluations of α, whereas using Simon’s quantum method we only need to


perform n evaluations of α.
160 7 Some Quantum Algorithms

7.4 Quantum Teleportation

There is nothing especially mysterious about quantum teleportation. However, it is


not about sending Mister Spock off on a quantum walk across the Universe, but
about teleporting information. A central concept is that quantum teleportation is a
direct consequence of entanglement between states, referred to briefly in Chap. 5.
Let us illustrate the problem with a pair of spies, Bad and Badder, whose boss
orders them to carry out a difficult mission: Bad must steal a message from an
embassy in one country and transmit it to an embassy in another country. The code
of the message is the following entangled state:
pffiffiffi

β ¼ 1= 2 ½j00i þ j11i

Once Bad has stolen the message he contacts Badder by phone in order to
transmit just two conventional bits: {00} or {01} or {10} or {11}. Badder then
has to decode the message following the protocol described below.
If Badder receives {00}, then the following decoding clue has to be used:
 
þ1 0
0 þ1

If Badder receives {01}, then the following decoding clue has to be used:
 
0 þ1
þ1 0

If Badder receives {10}, then the following decoding clue has to be used:
 
þ1 0
0 1

If Badder receives {11}, then the following decoding clue has to be used:
 
0 þ1
1 0

Note that some of these matrices are Pauli matrices, already used above.
To establish a secure communication system, Bad and Badder design the hybrid
quantum-conventional circuit depicted in Fig. 7.5. Bad can access the two first
lines, and Badder can access the third line. Remember that measurement results in
conventional bits.
Bad steals the message |φi¼ a|0i+ b|1i, encodes it in parallel and inputs it into
the circuit. This is what happens:
7.4 Quantum Teleportation 161

Fig. 7.5 The quantum- |ϕ〉 H


conventional teleportation
circuit

β ·
D |ϕ〉
·

Input ¼ jφi  β
pffiffiffi

¼ 1= 2 f½aj0i þ bj1i  ½j00i þ j11ig


pffiffiffi

¼ 1= 2 faj00ij0i þ aj01ij1i þ bj10ij0i þ bj11ij1ig

The system evolves and finds a CN gate for the two upper lines that produces the
following result:
pffiffiffi

jφ1 i ¼ 1= 2 faj00ij0i þ aj01ij1i þ bj11ij0i þ bj10ij1ig

The Hadamard operation in the first line performs the following transformation:
8 9
 2 < aðj0i þ j1iÞj0ij0i þ aðj0i þ j1iÞj1ij1i =
1
jφ2 i ¼ pffiffiffi
2 : þbðj0i  j1iÞj1ij0i þ bðj0i  j1iÞj0ij1i ;

8 9
 < aj00ij0i þ aj10ij0i þ aj01ij1i þ aj11ij1i =
1
¼
2 : ;
þbj01ij0i  bj11ij0i þ bj00ij1i  bj10ij1i

8 9
 < j00iðaj0i þ bj1iÞþ j01iðbj0i þ aj1iÞ =
1
¼
2 : ;
þ j10iðaj0i  bj1iÞþ j11iðbj0i þ aj1iÞ

Badder receives the third qubit of the complete message |φ2i through the
quantum channel. However, solving Bad’s task requires us to use the classical
part of the circuit. Badder receives a phone call from Bad.
If the message is {00}, then the term associated with |00i is
ðaj0i þ bj1iÞ

and the decoder is the identity matrix. In this case the stolen message would be
   
þ1 0 þa
 ¼ a j0i þ b j1i
0 þ1 þb
162 7 Some Quantum Algorithms

If the call is {01}, then the associated term is


ðbj0i þ aj1iÞ

and the decoder is the negation matrix. In this case the stolen message would be
   
0 þ1 þb
 ¼ a j0i þ b j1i
þ1 0 þa

If the call is {10}, then the associated term is


ðaj0i  bj1iÞ

and the decoder is the identity matrix with a phase change. In this case the stolen
message would be
   
þ1 0 þa
 ¼ a j0i þ b j1i
0 1 b

Finally, if the call is {11}, then the associated term is


ðbj0i þ aj1iÞ

and the decoder is the negation matrix with a phase change. In this case the
stolen message would be
   
0 þ1 b
 ¼ a j0i þ b j1i
1 0 þa

Badder always receives the same message. Note that any attempt to intercept the
quantum communication would lead—by the mere fact of measurement—to the
irreversible collapse of message transmission by Bad.

7.5 Chapter Summary

Several quantum algorithms are described, in particular, the Deutsch, Deutsch-


Jozsa, Simon and quantum teleportation algorithms, chosen because they do not
require any specialist mathematical background. Deutsch’s algorithm is presented
from different viewpoints with the goal of exploring the quantum computing
paradigm. The Deutsch-Jozsa algorithm is described using some of the material
developed in regard to the Deutsch algorithm. Both the Deutsch and Deutsch-Jozsa
algorithms are rather academic, but they are useful for illustrating thinking pro-
cesses in quantum computing. Simon’s algorithm, which focuses on finding the
period for a given function, is quite practical and relies on both quantum and
7.6 Glossary of Terms and Notation Used in This Chapter 163

conventional procedures. We conclude with a discussion and illustration of quan-


tum teleportation, emphasizing the fact that only information is teleported, not any
physical device or person. We also note that both quantum channels and conven-
tional channels are needed for teleportation, which explains why teleportation
cannot be faster than the speed of light in a vacuum.

7.6 Glossary of Terms and Notation Used in This Chapter

Terms
• Black box: in science, computing and engineering, a device, system or object
that can be viewed only in terms of its inputs and outputs (or transfer character-
istics), but not in terms of its internal workings.
• Canonical basis: for a Euclidean space, the set of unit vectors pointing in the
directions of the axes of a Cartesian coordinate system. The standard basis for
the Euclidean plane is formed by vectors. Canonical bases can be defined for
other vector spaces, such as polynomials and matrices. In both these cases, the
standard basis consists of elements of the vector space such that all the coeffi-
cients but one are 0 and the non-zero coefficient is 1. For polynomials, the
canonical basis consists of monomials and is commonly called the monomial
basis. For matrices, the canonical basis consists of mn matrices with exactly
one non-zero entry, which is 1.
• Parallelism: a type of computation in which many calculations are carried out
simultaneously.
• Teleportation: a process by which quantum information (for instance, the exact
state of an atom or photon) is transmitted (theoretically intact) from one location
to another, by means of a classical communication system and quantum Entan-
glement between the sending and receiving locations. Because it depends on
classical communication (which cannot take place faster than the speed of light),
teleportation cannot be used for faster-than-light transmissions or for conven-
tional bits. Neither can it be used to make copies of a system, as this violates the
no-cloning theorem.

Notation

α A given function
M, M0 Turing machines
UD Deutsch transformation
UDJ Deutsch-Jozsa transformation
US Simon transformation
β Bell state
Chapter 8
Concluding Remarks

Begin at the beginning, “the King said, very gravely,” and go


on till you come to the end: then stop.
Lewis Carroll

In this final chapter we discuss, from an academic point of view, the main charac-
teristics of several areas of computer science. We pay special attention to artificial
intelligence and quantum computing, in order to explore the possibility of mean-
ingful cooperation between them. In analyzing the basic principles that enable
researchers and engineers to make artificial intelligence and quantum computing
work together, we need to consider answers to several fundamental questions.
Below we briefly describe the behavior of the biological brain, focusing on the
singularities that enable it to perform so efficiently, especially energy consumption,
speed and parallelism. We illustrate the material presented here with examples and
conclude with a discussion regarding what we can expect from cooperation
between apparently unconnected fields of computer science.

8.1 What Are We Talking About?

In 2003 the Association for Computing Machinery (ACM) published an article


authored by Peter Shor entitled “Why haven’t more quantum algorithms been
found?” Shor pointed out that maybe one reason is that computer scientists often
do not understand the basic concepts of quantum mechanics. This last statement
also applies to artificial intelligence practitioners. Feynman referred to artificial
intelligence as the ‘field of advanced computing applications’.
However, by now it appears that computer scientists are making up lost ground,
as ongoing research into quantum computing, computer science and artificial
intelligence is starting to produce promising results that merit analysis. Even
more encouraging is the real and growing interest in this relatively new
multidisciplinary field.

© Springer International Publishing AG 2017 165


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1_8
166 8 Concluding Remarks

8.2 The Situation in 2014

In May 2013, Google, the National Aeronautics and Space Administration (NASA)
and the Universities Space Research Association (USRA) launched an initiative—
the Quantum Artificial Intelligence Lab (QAIL)—to investigate how technology
could drive artificial intelligence advances. The initiative is based on a synergy of
interests: Google believes that quantum computing could improve web search and
speech recognition technologies; university researchers aim to elaborate better and
more efficient computational models; and finally, NASA wants to model the
weather in space, simulate planetary atmospheres and analyze vast quantities
of data.
Until very recently, despite a sufficiently solid theoretical background, the
technology that would allow everything to be put together at the practical level
had not been developed. This situation was something similar to that of the
analytical engine defined by Charles Babbage and Ada Lovelace: the theory was
far in advance of the technology.
In 2011, as mentioned in Chap. 5, D-Wave Systems designed and implemented
what they claimed was the first system that applied quantum theory principles: the
128-qubit D-Wave One. In early 2013 this was updated to the 512-qubit D-Wave
Two. In January 2014, Google reported QAIL results comparing the performance of
D-Wave Two with classical computers; however, the results were ambiguous and
provoked heated discussion.
It is clear that not all the problems are of the same nature. On that basis, for
NASA, USRA and Google to achieve their goals, a very clear understanding is
necessary of the following:
Theoretical foundations
Advantages and disadvantages of the technology
Problems to be resolved
Limitations of both the theory and the technology.
We will illustrate our viewpoint with an example from biology. Our brains are
composed of highly interconnected neural systems. The neural systems need space
and the neurons in the system need energy. The human brain contains roughly
100 trillion nerve cells, 32 million kilometers of fibers (wires) and one million
trillion connections, occupies a volume of 1.5 l, weighs around 1.5 kg and consumes
around 10 W of energy. If we tried to build a similar artificial brain using silicon
chips, it would consume some 10 MW of energy and the heat it produced would
destroy it.
How is it possible for the biological brain to work so efficiently and economi-
cally? One of the aims of the artificial intelligence field is, obviously, to build
machines that are structurally and/or functionally similar to the brain, that is,
equally or more efficient. An analysis of how the brain works enables us to better
understand the potential of quantum computing in the artificial intelligence field.
8.3 Human Brains and Computers 167

8.3 Human Brains and Computers

Much of the efficiency of the biological brain is energy-related. In fact, the energy
cost of transmitting signals (that is, the communication capability between two
biological neurons) has probably been the most important single factor in the
biological evolution of the brain.
Approximately 50–80% of the total energy consumption of the brain is due to
conduction, that is, transmission of action potentials through fibers and communi-
cation between neurons in a process called synaptic transmission. Biological brains
are highly parallel networks and most neurons are connected directly to thousands
of other neurons. The fact that the brain is three-dimensional makes this possible.
In contrast, the two-dimensional nature of chips and circuits in silicon neurons
limits the establishment of connections, even among a small number of neurons,
which means that direct communication between silicon neurons is very restricted.
The high speeds allowed by conventional electronics are exploited in a different
way. The basic approach is to use processes that make it feasible for multiple
messages to be handled over the same wire. In this way computer engineers emulate
the connections of biological networks. There are, however, practically insur-
mountable energy implications. In fact, in their attempt to simulate the behavior
of biological systems, reducing energy consumption and increasing speed, some
computer engineers have adopted the strategy of using analog encoding rather than
digital encoding in classical bits (neuromorphic engineering); in other words,
information is encoded in the analog circuitry through continuously changing
voltage. This allows calculations to be done in fewer steps and also better exploits
the basic physics of silicon devices.
The human brain behaves as a massively parallel computing unit in which many
instructions are executed simultaneously. The basic underlying concept is that
complicated problems can be divided into simpler problems that are then solved
simultaneously (in parallel). The concept, which may seem trivial, certainly works
well in biological brains. The problem, however, is not so simple for our conven-
tional computers, for power consumption reasons. The power consumption of a
chip is given by the following equation:

P ¼ C  V2  F

where P is power, C is the capacitance change per cycle (proportional to the


number of transistors whose inputs change), V is voltage and F is the processor
frequency (cycles per second). Any increase in frequency increases the amount of
energy used in the processor. Such an increase in power consumption, in fact, led
Intel to cancel development of the Tejas and Jayhawk processors in May 2004. This
date, in fact, marked the end of the frequency scaling that had previously been the
dominant computer architecture paradigm.
168 8 Concluding Remarks

8.4 Artificial Intelligence, Parallelism and Energy


Efficiency

A number of the fundamental problems of artificial intelligence cannot be solved


with conventional computing techniques or with the hardware available today.
Artificial intelligence is a multidisciplinary field that draws on computer science,
logic and philosophy. The main goal of artificial intelligence is to design and create
systems capable of reasoning for themselves using the human intelligence para-
digm. Artificial intelligence can be envisaged from two different perspectives,
namely:
Conventional artificial intelligence
Computational intelligence
Conventional artificial intelligence, also known as deductive artificial intelli-
gence, is based on formal statistical analysis of human problem-resolving behavior.
Computational intelligence, also known as inductive artificial intelligence, is based
on development or interactive learning (for example, interactive parameter changes
in connectionist systems) using empirical data.
The main criticism of artificial intelligence programs is regarding their limited
ability to mimic human thinking. However, these criticisms ignore the fact that
even humans do not have the capacity to solve all kinds of problems. Authors such
as Howard Gardner have proposed that there are, in fact, multiple intelligences. The
efficiency of an artificial intelligence program is also conditioned by the lack of
massive computational capacity. Some examples:
• In rule-based expert systems, pattern matching of rules is computationally very
costly.
• In artificial neural systems, data mining and machine learning, the large amount
of data to be handled is a challenge to the efficiency of the program.
We are faced once again with the difficulty of transforming data into information
and information into knowledge. The reason we cannot draw on parallel computing
to solve these problems is related to energy considerations, but also to quantum
constraints. Gordon Moore predicted in 1965 that the number of transistors per
square inch of integrated circuits would double every 18 months and that this trend
would continue for at least two decades. This law, called Moore’s Law, still applies
today. The real problem will arise when new technologies enable chips of around
5 nm to be manufactured.
Modern microprocessors typically work on 64-bit architectures integrating more
than 700 million transistors and operating at frequencies above 3 GHz. The third-
generation Intel Core (2012) evolved from a width of 32–22 nm, while allowing the
number of transistors to be doubled. More transistors mean a greater capacity to do
more tasks simultaneously—but there is an upper limit beyond which capacity
cannot feasibly be increased.
8.5 Energy Restrictions on Information Processing 169

Likewise with chips; because smaller devices compute faster, increasingly small
microchips are being manufactured. However, their size cannot be infinitely
reduced. This is because nanometer-sized electrons escape from the channels
where they circulate in what is called the tunnel effect—a typically quantum
phenomenon. Electrons are quantum particles with wave-like behavior; hence,
there is a non-zero possibility that some such electrons will pass through the
walls behind which they are confined. Under such conditions, chips will not work
properly. By now, since we have already reached sizes of only a few tens of
nanometers, digital computing is clearly reaching its limits.
But where exactly is this limit? The answer may have much to do with the world
of the very small and it seems that we have no choice but to revert to certain
approaches and concepts of physics. Going back to basics, the first concept to
consider is the size of the atom. The size of current microprocessors is in the order
of nanometers. Various existing methods to estimate the size of the atomic radius
give values of between 0.5 and 5 Å, equivalent to 0.1 nm. Hence, we have only one
order of magnitude further to go before we have to design computers that take into
account the restrictions imposed by quantum mechanics!

8.5 Energy Restrictions on Information Processing

As mentioned in Chap. 4, Rolf Landauer addressed one of the problems of current


high-speed computers, i.e., the removal of the heat produced during operation,
asking whether this problem was inherent to the laws of physics or was due to the
lack of efficiency of the available technology.
The question, essentially, is whether there is any relationship between energy,
information and computing. The answer may seem trivial for those (all of us really)
who work with computers nowadays. Energy in the form of heat, noise etc., is
omnipresent when we use a computer. For a computer system to be operational the
flow of electrons through wires and devices is necessary, but this generates fric-
tional heat that has to be dissipated. To reduce this heat, we use a fan—which also
needs energy to function and which also generates noise (another form of energy).
The computer itself needs to be fed with external power.
But our concern here is to consider the energy issues of computing from the
point of view of the information we manipulate. Consider a system composed of
two tanks connected via a tube which can be opened or closed by means of a valve
and consider two different and easily distinguishable particles: particles (x) and
particles (o). Imagine the system in two different states. In state 1 the valve is
closed, all particles (o) are on the left, and all particles (x) are on the right. In state
2 the valve is open and the two types of particles (o) and (x) are evenly distributed in
both tanks. Let us now consider this system from a macroscopic perspective. If the
number of both particles is large, how can we evaluate the amount of energy in the
information in both states?
170 8 Concluding Remarks

We will answer this question using statistical mechanics, defining the concept of
entropy as follows: a measure of the disorder in a system, equal to the Boltzmann
constant multiplied by the natural logarithm of the number of microscopic states
corresponding to the thermodynamic state of the system. According to the above
definition:

S ¼ k ln ðN Þ

In this equation S is entropy, k is the Boltzmann constant and N is the number of


microscopic states corresponding to the thermodynamic state of the system. Now
consider Shannon’s formula for the amount of information:

Ψ ¼ k ln ðN Þ

Perhaps k and N are not the same thing in both expressions, but the equations are
identical, suggesting that there is some link between entropy and the amount of
information in a system. If entropy is a measure of the disorder in a system, it is
clear that state 2 in our tank example is much messier than state 1. In other words,
there are far more possible microscopic states in state 2 than in state 1. The entropy
of state 1 is therefore much smaller than the entropy of state 2. If N (1) is the number
of microstates of state 1, and N (2) is the number of microstates of state 2, then
Sð1Þ ¼ k ln ½N ð1Þ; Sð2Þ ¼ k ln ½N ð2Þ

In physics, however, the concept of absolute entropy does not exist. The physical
meaning relates to increments in entropy. Thus
ΔS ¼ Sð2Þ  Sð1Þ ¼ k ln ½N ð2Þ  k ln ½N ð1Þ ¼ k ln ½N ð2Þ=N ð1Þ

In this formulation the underlying assumption is that we start from state 1, we


open the valve and we let the system evolve. In this way the particles are disordered,
and the entropy of the system increases, so ΔS is positive.
But what happened to our information? When we have our system in state 1 we
have information: we know that all particles (o) are on the left and all particles
(x) are on the right. Then we open the valve and let the system evolve. But when the
system reaches equilibrium (which roughly speaking means that, macroscopically,
the system no longer evolves) we have lost all the information. Put another way, if
the system is in state 1 and we want to take out a particle (x), we can go directly to
the right tank and select any particle with the assurance that it is a particle (x). If the
system is in state 2, however, irrespective of which tank we choose, we will need to
verify that the particle is a particle (x) and, if not, return the particle to the system
and continue testing until finally we select a particle (x).
To say that chance guides our success in selecting a particle (x) when the system
in state 2 is the same as saying that our information is zero. Therefore, if Ψ(1) is the
information associated with state 1, and if Ψ(2) is the information associated with
state 2, then
8.5 Energy Restrictions on Information Processing 171

ΔΨ ¼ Ψð2Þ  Ψð1Þ ¼ Ψð1Þ

We have already said that we can assume that our information in state 2 is zero.
To recap, starting from state 1 and letting the system evolve spontaneously to reach
the equilibrium state 2, entropy increases, but information is lost. According to our
previous formulation, we could say that the loss of information from allowing the
system to spontaneously evolve is equivalent to an increase in entropy in the
system. However, we will be more cautious and simply state that

½ΔΨ ¼ Ψð1Þα ΔS

This expression is interpreted as follows: the loss of information that occurs


when we let the system evolve spontaneously is related to the increase in entropy of
the system. There are many examples of what we have described above in everyday
life. For instance, we can visualize what we have discussed by trying to answer the
same question in two different scenarios:
Question: Where can I find my blue socks?
Scenario 1: We are looking for them at mom’s.
Scenario 2: We are looking for them in our student apartment.
To this point we have been interested in the energy associated with computing—
but at best we have managed to establish a link between information and entropy in
a system. Linking energy and entropy, a thermodynamic function called free energy
(F) relates the internal energy of a system (U ) to its entropy (S). To illustrate how
this works we will analyze an interesting problem formulated by Feynman: how
much energy is needed to perform a basic computation?
Let us consider the structure of a typical message written on a continuously
moving belt that transports boxes with bits |0〉and |1〉 , according to the arbitrary
criterion that a bit |0〉is a particle on the right of the box, and a bit |1〉is a particle on
the left of the box. Let us now reboot the system by putting all the bits in the state |0〉 .

It is apparent that the amount of information in the message is proportional to the


free energy required to reset the entire belt to zero. The first thing to note is that
resetting to zero is equivalent to compressing each box to ensure that its constituent
particle is in position |0〉 , that is, to the right of the box. In this case, and assuming a
piston operating from left to right, when we travel just half way (and therefore have
reduced the volume of each box by half) we have all the bits on the right side. Thus,
if for each box the initial volume is V1 and the volume after reset is V2, it follows
that
V 2 ¼ ð1=2ÞV 1
172 8 Concluding Remarks

In thermodynamics, as mentioned above, state changes are studied in terms of


the two fundamental concepts of free energy F and entropy S. Given the restrictions
on our problem, the expression that relates the two magnitudes is as follows:

ΔF ¼ TΔS

where T is the temperature of the system, which is kept constant by a suitable


refrigeration system (recall that we only want to find out the energy cost of a basic
computation task). Now, if N is the number of bits in the entire message, kinetic
theory predicts that
ΔF ¼ W ¼ N k T ln ðV 1 =V 2 Þ

where k is the Boltzmann constant. Obviously ΔF is the energy that we use in


order to reset the message. Therefore, if we consider a single basic operation on a
single bit, it follows that
ΔF ¼ kT ln ð2Þ

Consequently
ΔS ¼ k ln ð2Þ

However, do not forget that we only expend free energy if we do not know where
the particle is, because this is the only circumstance in which the phase space is
divided in two. Likewise, if we know the position of the particle beforehand we do
not expend energy on resetting. The conclusion is obvious: the information in the
message is in the known bits, and the elementary energy of a basic computation task
is defined only in the case of unknown bits. This obviously does not mean that we
can perform computations without energy. However, it does help us understand the
importance of energy when dealing with quantum operators and the reversibility of
quantum logic gates.
Quantum computing, based on the use of qubits rather than bits, gives rise to new
logic gates that enable new algorithms. The same task in classical computing and in
quantum computing may have different levels of complexity, which, promisingly,
means that certain intractable problems become tractable.
As explained earlier, in classical digital computing, a bit can take only 0 or 1.
However, in quantum computing, due to the laws of quantum mechanics, the
qubit can be in coherent superposition and can be either 0, or 1, or 0 and 1 simul-
taneously, meaning that several operations can be performed in parallel. The
number of qubits indicates the number of bits that can be in superposition. With
conventional bits, if we have three bits we have eight possible values and a given
system can only take one of these eight possible values. However, with a vector of
three qubits, through quantum superposition the particle can take eight different
values simultaneously, meaning that a vector of three qubits allows eight parallel
operations. The number of operations, in other words, is exponential with respect to
8.6 Some Things to Ponder on 173

the number of qubits. To get an idea of the great progress that this represents, a
quantum computer working with only 30 qubits is equivalent to a conventional
processor of 10 teraflops (1013 floating-point operations per second). At present,
computers are currently working in the order of gigaflops (a thousand million
floating-point operations per second).
Returning to artificial intelligence, an article published by X.E. Ying in 2010 in
Artificial Intelligence discusses potential applications of quantum computing in
artificial intelligence, among them
Quantum algorithms for learning
Quantum algorithms for decision making
Quantum search
Quantum game theory
Semantic analysis
Natural language
Quantum Bayesian networks
Quantum neural networks
Quantum genetic algorithms.
The best applications of quantum computing in artificial intelligence will be
found in the field of machine learning. Machine learning could definitely benefit
from quantum computing, because machine learning involves the design of pro-
cesses by means of which computers adapt to the environment and thereby learn to
perform tasks. In some cases, the computer does all the learning itself, without
human supervision, but in other cases, the system is supervised by a human who
makes the necessary adjustments. Quantum principles enable a computer to simul-
taneously use all the data relevant to a problem.
Google’s particular interest in quantum computing is in performing high-level
scientific computations, especially in the area of machine learning. “Machine learn-
ing is about building better models of the world to make more accurate predictions,”
wrote Hartmut Neven, Google’s Director of Engineering, in his blog. He goes on to
say “If we want to cure diseases, we need better models about how these diseases
develop, if we want to create effective environmental policies, we need better models
of what happens with our climate, and if we want to build a more useful search, we
need to know what’s on the Web in order to get the best response.”
The potential of quantum computing in artificial intelligence is evident, but we
still do not know how to translate that potential into reality. Undoubtedly, time will
put things in their place.

8.6 Some Things to Ponder on

In recent years, conventional computers have experienced a great increase in


processing speeds. Moore’s Law has been consistently fulfilled to date, but now
encounters a limitation, given that when transistors achieve atomic dimensions the
174 8 Concluding Remarks

fundamental laws of physics change. Electrons experience quantum phenomena


and present wave-like behavior. This results in peculiar microscopic effects that
interfere with circuit operation. Classical computation would appear to be reaching
its limits; quantum principles would appear to represent the future of computation
and may well lead to a new computational revolution.
Outside its own field of application, quantum physics may appear to be an
abstract theory, mysterious and counterintuitive. Yet it has the potential to acquire
practical uses in the development of a future theory of information, as suggested by
Richard Feynman, Paul Benioff, David Deutsch and Charles H. Bennett who, in the
1970s and 1980s, proposed the application of quantum principles to computation
problems.
Computer problems are resolved by algorithms that need precise sets of instruc-
tions and their efficiency is evaluated in terms of the time taken to resolve problems
as the amount of input data increases. Quantum mechanics makes it possible to
define new algorithms that resolve problems at incredibly fast speeds, far, far
superior to those of even the most advanced computers of today.
The pioneering Deutsch-Jozsa algorithm was further improved in 1998 by
Richard Cleve, Arthur Ekert, Chiara Macchiavello and Michele Fly. The Shor
algorithm for rapidly factorizing very large numbers is the dream of any hacker
as it overcomes a major limitation of classical computation regarding security
applications. The algorithm developed by Grover to effectively search massive
databases also greatly reduces the execution time of a conventional computer.
Other genuinely efficient quantum algorithms need to be developed, however, to
overcome the problem that, although computers can run a multitude of simulta-
neous operations, the measurement obtains a single result. In other words, infor-
mation on other possibilities associated with the rest of states in superposition is
lost. A new quantum algorithm is needed that will produce, with a single measure-
ment, all the desired information as output.
In the quantum computation approach, the qubit, unlike the bit, may be found in
a simultaneous superposition of two quantum states, that is to say N qubits can
simultaneously overlap 2N states. This quantum superposition enables parallel
processing on a vast scale. In other words, the operational capacity of a quantum
computer increases exponentially with the number of qubits. The state of a qubit
can be viewed as a point on the surface of a sphere (called the Bloch sphere). In this
representation the poles of the sphere represent the classical bits 0 and 1 and all the
other points are the different possibilities that can be represented by a qubit.
Another key quantum computing concept is entanglement. Two entangled
quantum systems are so interconnected that, in spite of the distance between
them, they cannot be described separately. A key application of quantum entangle-
ment is the teleportation of information. A change in the quantum state of one
system is teleported instantly (within the limitations of the speed of light in a
vacuum) to a second system, no matter how distant the systems are from each
other. Note that only information, not matter, can be teleported. Thus, with quantum
computing we can transmit states of qubits without sending qubits.
8.6 Some Things to Ponder on 175

Some problems still need to be resolved. One such problem is the effect of
decoherence, which refers to information loss because of environmental interfer-
ence in the superposition of quantum states. Physical models therefore need to meet
certain requirements to be able to perform as authentic quantum computers. One of
these requirements is that the qubits have to be isolated to avoid decoherence.
Another is that systems have to permit controlled interaction with other qubits in
order to create states in quantum superposition and to be able to read results.
Although the errors caused by decoherence are a major problem for quantum
computation, scientists are developing quantum-based methods to correct these
errors. For instance, an article by Howard M. Wiseman published in Nature, titled
“Quantum physics: cruise control for a qubit,” describes an experimental imple-
mentation of a theoretical method for feedback control of quantum bits.
As for physical systems, several exist that theoretically fulfil the necessary
requirements to be quantum computers. However, they work with very few qubits
and we still cannot determine with any certainty which system might be the most
suitable. One problem of some prototypes is the lack of scalability to computers
with enough qubits to develop applications of practical interest, as these require
complex error detection methods.
In 1995, Juan Ignacio Cirac and Peter Zoller developed a basic schema for
quantum computers built using ions, thereby illustrating how what had previously
been a mere theoretical entelechy could be implemented. The quantum research
conducted by the joint recipients of the Nobel Prize in Physics 2012—Serge
Haroche and David Wineland—has direct implications for the future of quantum
computation and the physical implementation of qubits. As the Swedish Academy
noted, their innovative methods have laid the groundwork for the construction of a
new type of super-fast computer based on quantum physics. Both managed to
manipulate quantum systems formed by a single particle with no loss of quantum
properties, thereby achieving measurement: Wineland used photons to measure the
quantum state of atoms or ions in a trap, whereas Haroche—doing the opposite—
created a trap for photons and analyzed the quantum properties by means of atoms.
The novelty does not lie in the techniques to trap the individual quantum particles
but in the study and measurement of the quantum states of the trapped particles.
Recalling the paradox of Schr€odinger’s cat, this is rather similar to knowing
whether the cat is alive or dead without opening the box.
For the moment, however, current quantum computers continue to operate with a
very limited number of qubits and so are restricted in their capacity to resolve
problems of interest. However, there is no reason to think a priori that it will not be
possible to achieve these operations with many more qubits. Ongoing advances in
practical realizations of different theoretical models would suggest that the quan-
tum computer will be with us sooner than we may think, although, as yet, it is
difficult to say when. Juan Ignacio Cirac stated in a newspaper interview that we
may still have to wait several decades. However, in the words of Niels Bohr,
“Prediction is very difficult, especially if it’s about the future.”
176 8 Concluding Remarks

8.7 Chapter Summary

Some of the relevant characteristics of both artificial intelligence and quantum


computing are discussed in order to explore the possibility of a meaningful coop-
eration between these two computer science fields, although it is recognized that
many fundamental questions need to be answered before researchers and engineers
can combine artificial intelligence and quantum computing. We briefly describe the
behavior of the biological brain in terms of what makes it so efficient, mentioning
some well-established artificial intelligence approaches that mimic the biological
brain and paying particular attention to speed and energy consumption. We con-
tinue with a discussion about what can be expected from cooperation between the
apparently unconnected artificial intelligence and quantum computing fields.
Finally, we reflect on some issues raised in the book, leaving an open door for
further reflection on this new paradigm of computing.

8.8 Glossary of Terms and Notation Used in This Chapter

Terms
• Analytical engine: a mechanical general-purpose computer designed by English
mathematician and computer pioneer Charles Babbage in 1837 as the successor
to his difference engine (a design for a mechanical computer). The analytical
engine had an arithmetic logic unit, control flow in the form of conditional
branching and loops, and integrated memory. It was thus the first design for a
general-purpose computer that can be described in modern terms as Turing-
complete.
• Artificial intelligence: an academic field that studies how to create computers
and computer software capable of intelligent behavior.
• Bayesian network: a probabilistic graphical model (a type of statistical model)
that represents a set of random variables and their conditional dependencies via a
directed acyclic graph.
• Entropy: a measure of the number of specific ways in which a thermodynamic
system may be arranged, commonly understood as a measure of disorder.
According to the second law of thermodynamics the entropy of an isolated
system never decreases, as the system will spontaneously proceed towards
thermodynamic equilibrium as the configuration with maximum entropy. Sys-
tems that are not isolated may decrease in entropy, provided the entropy of their
environment increases by at least the same amount. Since entropy is a state
function, the change in the entropy of a system is the same for any process that
goes from a given initial state to a given final state, irrespective of whether the
process is reversible or irreversible. However, irreversible processes increase the
combined entropy of the system and its environment.
8.8 Glossary of Terms and Notation Used in This Chapter 177

• Genetic algorithm: a heuristic search that mimics the process of natural selec-
tion. This heuristic (also sometimes called a metaheuristic) is routinely used to
generate useful solutions to optimization and search problems. Genetic algo-
rithms belong to the larger class of evolutionary algorithms, which generate
solutions to optimization problems using techniques inspired by natural evolu-
tion, such as inheritance, mutation, selection and crossover.
• Machine learning: an artificial intelligence technique that explores the study and
construction of algorithms that can learn and make predictions from data. They
operate by building a model from example inputs in order to make data-driven
predictions or decisions, rather than by strictly following static program
instructions.
• Neural networks: a family of models inspired by biological neural networks (the
central nervous systems of animals, in particular the brain), which are used to
estimate or approximate functions that can depend on a large number of gener-
ally unknown inputs. Artificial neural networks are generally presented as
systems of interconnected neurons that exchange messages. The connections
have numerical weights that can be tuned based on experience, making neural
nets adaptive to inputs and capable of learning.
• Neuromorphic: a concept describing the use of very large-scale integration
systems containing electronic analog circuits that mimic neurobiological archi-
tectures present in the nervous system. In recent times the term has been used to
describe analog, digital and mixed-mode analog/digital systems that implement
models of neural systems (for perception, motor control or multisensory inte-
gration). The implementation of neuromorphic computing at the hardware level
can be realized by oxide-based memristors, threshold switches and transistors.
• Pattern matching: in computer science, pattern matching is the act of checking a
given sequence of tokens for the presence of the constituents of some pattern.
• Synergy: the creation of a whole that is greater than the simple sum of its parts.
• Transistor: a semiconductor device used to amplify or switch electronic signals
and electrical power. It is composed of semiconductor material with at least
three terminals for connection to an external circuit. A voltage or current applied
to one pair of the transistor’s terminals changes the current through another pair
of terminals. Because the controlled (output) power can be higher than the
controlling (input) power, a transistor can amplify a signal.

Notation
S Entropy
Ψ Information
α Proportional
F Free energy
W Energy in the form of work
Appendix A: Mathematical Background

In this appendix we are going to present some basic mathematical background that
has been used in the writing of this book. We are not going to work in any strictly
formal way as the idea is simply to provide a guide for quick consultation.

A.1. Complex Numbers

Consider the equation

x2 þ 1 ¼ 0

Obviously
pffiffiffiffiffiffiffi
x2 ¼ 1 ! x ¼  1
pffiffiffiffiffiffiffi
The number 1 is considered to be the imaginary unit, denoted by i. Therefore
pffiffiffiffiffiffiffi
i ¼ 1

Consider now the plane depicted in Fig. A.1 (called an Argand plane), in which
the x-axis represents real numbers and the y-axis represents imaginary numbers.
Let us call c the point (a, b) in Fig. A.1. This point c is called a complex number
because it has a real part and an imaginary part.
We can represent this complex number in several ways. For example,
c ¼ a þ bi ¼ ða; bÞ ¼ ðr; θÞ

where r is the length of the arrow in Fig. A.1 and θ is the angle between the arrow
and the x-axis.

© Springer International Publishing AG 2017 179


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1
180 Appendix A: Mathematical Background

Fig. A.1 Argand plane Im

r cos(θ)
z = x + iy
y

r
r sin(θ)

θ
Re
x

We will call the modulus of the complex number r and the argument of the
complex number θ. In this way
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
r ¼ j c j ¼ a2 þ b2

We can also see that


a ¼ r  cos θ

and

b ¼ r  sin θ

then
 
b
1
θ ¼ tan
a

We can do many things with complex numbers, for example, sum or multiply
them. Thus if c1 and c2 are complex numbers such that
c 1 ¼ ð a1 ; b1 Þ ¼ a1 þ b1 i ¼ ð r 1 ; θ 1 Þ

and
c 2 ¼ ð a2 ; b2 Þ ¼ a2 þ b2 i ¼ ð r 2 ; θ 2 Þ

then
c1 þ c2 ¼ ð a1 þ a2 ; b1 þ b2 Þ ¼ ða1 þ a2 Þ þ ðb1 þ b2 Þi

and
Appendix A: Mathematical Background 181

c 1  c 2 ¼ ð a1  a2  b1  b2 ; a1  b2 þ a2  b1 Þ
¼ ðr 1  r 2 ; θ 1 þ θ 2 Þ

To represent the above operations, we have used the most convenient and
clearest notation.
A very interesting property of complex numbers is conjugation, which consists
of maintaining the real part as it is and at the same time changing the sign of the
imaginary part. Thus, if we have the complex number

c ¼ a þ bi

the conjugate of c, denoted by c*, is

c∗ ¼ a  bi

Notice that conjugation of complex numbers is nothing more than a change of


angle. To verify this, assume we have the complex number c:
c ¼ a þ bi

Then

c∗ ¼ a  bi

For the number c we have


pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
rc ¼ a2 þ b2
 
1 b
θc ¼ tan
a

And for the number c* we have


qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
r c∗ ¼ a2 þ ðbÞ2 ¼ r
 
1 b
θ c∗ ¼ tan  ¼ θc
a

We can do many other things with complex numbers, but given the scope of this
Appendix, this is enough to understand the book.
182 Appendix A: Mathematical Background

A.2. Vectors

Let us now talk about vectors, which have an interesting analogy with complex
numbers. We will start with Fig. A.2, which is similar to Fig. A.1 except that it
depicts a vector in the plane.
We can denote by V the vector (arrow) in Fig. A.2 and can represent it as
follows:
 
V ¼ Vx ; Vy

where Vx and Vy are scalar numbers. We can also do many things with vectors. For
example, we can add two vectors. Assume
 
V ¼ Vx ; Vy

and
 
W ¼ Wx ; Wy

Then
     
V þ W ¼ Vx ; Vy þ Wx ; Wy ¼ Vx þ Wx ; Vy þ Wy

Vectors also have both modulus and argument:


qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
jVj ¼ Vx2 þ Vy2

and
 
1 Vy
θV ¼ tan
Vx

Fig. A.2 A vector in the y


plane XY

θ
x
Appendix A: Mathematical Background 183

It should be noted that when we multiply a vector by a scalar number the angle of
the vector does not change. Thus, if V is a vector and Z is a scalar number, then
 
Z  V ¼ Z Vx ; Z Vy

qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
 2
jZ  V j ¼ ðZ Vx Þ2 þ Z Vy

 
1 Vy
θZV ¼ tan
Vx

We can also represent a vector as a column matrix and perform the


corresponding matrix operations. For example,
   
Vx Wx
V¼ and W ¼
Vy Wy
 
Vx þ Wx
VþW¼
Vy þ Wy

Assume now that all the scalar numbers are complex scalar numbers. For
example,
 
α þ βi
c ¼ a þ bi and V ¼
γ þ δi

In this case
 
c ðα þ βiÞ
cV¼
c ðγ þ δiÞ

If two scalars multiply the same vector, it holds that


c1  ðc2  VÞ ¼ ðc1  c2 Þ  V

In this way, together with some other properties which will not be discussed here
for the sake of brevity, complex vector spaces are defined. An interesting question
regarding such complex vector spaces derives from the possibility of their matrix
representation. Briefly, we can define the following concepts.
Assume a vector V belonging to a complex vector space such that
V ¼ ½ða þ biÞ; ðc þ diÞ
184 Appendix A: Mathematical Background

It holds that
 
a þ bi
• Matrix V:
c þ di
 
a  bi
• Conjugate V ¼ V*:
c  di
• Transpose V ¼ VT: (a + bi c + di)
• Adjoint V ¼ (V*)T ¼ V{: ð a  bi c  di Þ
Now we can define the inner product as follows:
If we are working with real numbers in Rn, then, given two vectors V1 and V2,

hV1 ; V2 i ¼ V1T  V2 2 Rn

If we are working with complex numbers in Cn, then, given two vectors V1 and V2,

hV1 ; V2 i ¼ V{1  V2 2 Cn

We can now define the norm of a vector V as follows:


pffiffiffiffiffiffiffiffiffiffiffiffiffi
jVj ¼ hV; Vi

Note that the norm will always be a real number.

A.3. Hermitian and Unitary Matrices

On the subject of matrices, to conclude this Appendix, let us define two special
kinds of matrices: Hermitian and Unitary.
A given matrix M is Hermitian if the matrix is equal to its adjoint: M ¼ M{. For
example,
   
a b þ ci ∗ a b  ci
M¼ !M ¼
b  ci d b þ ci d
 
{ a b þ ci
!M ¼
b  ci d

A given matrix U is unitary if the product U  U{ is the identity matrix. For


example, consider the following Pauli matrix:
 
0 i
Sy ¼
i 0
Appendix A: Mathematical Background 185

It is easy to see that

Sy ¼ S{y

Then
     
0 i 0 i 1 0
Sy  S{y ¼  ¼
i 0 i 0 0 1

Bearing in mind the above mathematical concepts, we are ready to define the
Hilbert space.
A Hilbert space is a complex vector space with an inner product that is also
complete.
It is beyond the scope of this book to discuss the condition of completeness of
Hilbert spaces.
Appendix B: Glossary of Terms Used in the Book

• Absolute zero point: the point at which the fundamental particles of nature have
minimal vibrational motion, retaining only quantum mechanical, zero-point-
energy-induced particle motion.
• Alpha particle: positively charged particle consisting of two protons and two
neutrons, emitted in radioactive decay or nuclear fission. Also the nucleus of a
helium atom.
• Analytical engine: a mechanical general-purpose computer designed by English
mathematician and computer pioneer Charles Babbage in 1837 as the successor
to his difference engine (a design for a mechanical computer). The analytical
engine had an arithmetic logic unit, control flow in the form of conditional
branching and loops and integrated memory. It was thus the first design for a
general-purpose computer that could be described in modern terms as Turing-
complete.
• Artificial intelligence: an academic field that studies how to create computers
and computer software capable of intelligent behavior.
• Average value: a quantity intermediate to a set of quantities.
• Axiom: a proposition that is assumed without proof for the sake of studying its
consequences.
• Backward reasoning: proving a goal by recursively breaking it down into
sub-goals and trying to prove these until facts are derived. Facts are goals with
no sub-goals and are therefore always true.
• Bayesian network: a probabilistic graphical model (a type of statistical model)
that represents a set of random variables and their conditional dependencies via a
directed acyclic graph.
• Binary logic: classical propositional two-valued logic, often called Boolean
logic in engineering.
• Black body: a hypothetical body that absorbs but does not reflect electromag-
netic radiation incident on its surface.

© Springer International Publishing AG 2017 187


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1
188 Appendix B: Glossary of Terms Used in the Book

• Black box: in science, computing and engineering, a device, system or object


that can be viewed only in terms of its inputs and outputs (or transfer character-
istics), but not in terms of its internal workings.
• Bloch sphere: a geometrical representation of the pure state space of a two-level
quantum mechanical system.
• Canonical basis: for a Euclidean space, the set of unit vectors pointing in the
direction of the axes of a Cartesian coordinate system. The standard basis for the
Euclidean plane is formed by vectors. Canonical bases can be defined for other
vector spaces, such as polynomials and matrices. In both these cases, the
standard basis consists of elements of the vector space such that all the coeffi-
cients but one are 0 and the non-zero coefficient is 1. For polynomials, the
canonical basis consists of monomials and is commonly called the monomial
basis. For matrices, the canonical basis consists of mn matrices with exactly
one non-zero entry, which is 1.
• Complex number: a mathematical expression (a + bi) in which a and b are real
numbers and i2 ¼ 1.
• Cryptography: the practice and study of techniques for secure communication in
the presence of third parties.
• Data-driven reasoning: the construction of goals or the drawing of inferences
from a set of facts.
• Density matrix: a matrix that describes a quantum system in a mixed state as a
statistical ensemble of several quantum states.
• Differential equation: an equation involving differentials or derivatives.
• Diffraction: the spreading of waves around obstacles.
• Eigenfunction: any non-zero function f for a linear operator A defined in some
function space that returns from the operator exactly as is, except for a multi-
plicative scaling factor.
• Eigenstate: a quantum-mechanical state corresponding to an eigenvalue of a
wave equation.
• Eigenvalue: a special set of scalars associated with a linear system of equations
(that is, a matrix equation) that are sometimes also known as characteristic roots,
characteristic values, proper values or latent roots.
• Entropy: a measure of the number of specific ways in which a thermodynamic
system may be arranged, commonly understood as a measure of disorder.
According to the second law of thermodynamics the entropy of an isolated
system never decreases, as the system will spontaneously proceed towards
thermodynamic equilibrium as the configuration with maximum entropy. Sys-
tems that are not isolated may decrease in entropy, provided the entropy of their
environment increases by at least the same amount. Since entropy is a state
function, the change in the entropy of a system is the same for any process that
goes from a given initial state to a given final state, irrespective of whether the
process is reversible or irreversible. However, irreversible processes increase the
combined entropy of the system and its environment.
• Free energy: a thermodynamic property that expresses the capacity of a system
to perform work under certain conditions.
Appendix B: Glossary of Terms Used in the Book 189

• Full adder: an adder of binary numbers that accounts for values carried in as well
as out. A one-bit full adder adds three one-bit numbers, often written as A, B and
Cin; A and B are the operands, and Cin is a bit carried in from the previous less
significant stage. The full adder is usually a component in a cascade of adders
that sum binary numbers (8-, 16-, 32-bit etc.). The circuit produces a two-bit
output: output carry and sum.
• General relativity: a generalization of special relativity and Newton’s law of
universal gravitation that provides a unified description of gravity as a geometric
property of space and time (or space-time). The curvature of space-time is
directly related to the energy and momentum of the matter and radiation that
are present.
• Genetic algorithm: a heuristic search that mimics the process of natural selec-
tion. This heuristic (also sometimes called a metaheuristic) is routinely used to
generate useful solutions to optimization and search problems. Genetic algo-
rithms belong to the larger class of evolutionary algorithms, which generate
solutions to optimization problems using techniques inspired by natural evolu-
tion, such as inheritance, mutation, selection and crossover.
• Half adder: a combinational arithmetic circuit that adds two numbers, producing
a sum bit (S) and a carry bit (C) as output.
• Hamiltonian: the operator (in most cases) corresponding to the total energy of
the system.
• Heisenberg’s uncertainty principle: in quantum mechanics, any of a variety of
mathematical inequalities asserting a fundamental limit to the precision with
which certain pairs of physical properties of a particle (complementary vari-
ables), such as position x and momentum p, can be known simultaneously.
• Hermitian: in mathematics, a self-adjoint matrix or square matrix with complex
entries that is equal to its own conjugate transpose. Thus, the element in the i-th
row and j-th column is equal to the complex conjugate of the element in the j-th
row and i-th column, for all indices i and j. In mathematical analysis, a Hermitian
function is a complex function with the property that its complex conjugate is
equal to the original function with the variable changed in sign.
• Hilbert space: an abstract vector space possessing the structure of an inner
product that allows length and angle to be measured.
• Inner product space: in linear algebra, a vector space with an additional structure
called an inner product that associates each pair of vectors in the space with a
scalar quantity known as the inner product of the vectors. Inner products allow
the rigorous introduction of intuitive geometrical notions such as vector length
and the angle between two vectors and also provide the means of defining
orthogonality between vectors (zero inner product).
• Joint probability: given at least two random variables x, y, . . . defined in a
probability space, the joint probability distribution for x, y, . . . gives the prob-
ability that each of x, y, . . . falls within a particular range or discrete set of values
specified for that variable.
• Linear momentum: the product of the mass and velocity of an object.
190 Appendix B: Glossary of Terms Used in the Book

• Logarithm: the exponent of the power to which a base number must be raised to
equal a given number.
• Machine learning: an artificial intelligence technique that explores the study and
construction of algorithms that can learn and make predictions from data. They
operate by building a model from example inputs in order to make data-driven
predictions or decisions, rather than by strictly following static program
instructions.
• Matrix: in mathematics, a rectangular array of numbers, symbols or expressions,
arranged in rows and columns.
• Maxwell’s demon: a thought experiment by the physicist James Clerk Maxwell
that suggested how the second law of thermodynamics could hypothetically be
violated.
• Neural networks: a family of models inspired by biological neural networks (the
central nervous systems of animals, in particular the brain) that are used to
estimate or approximate functions that can depend on a large number of gener-
ally unknown inputs. Artificial neural networks are generally presented as
systems of interconnected neurons that exchange messages. The connections
have numerical weights that can be tuned based on experience, making neural
nets adaptive to inputs and capable of learning.
• Neuromorphic: a concept describing the use of very large-scale integration
systems containing electronic analog circuits that mimic neurobiological archi-
tectures present in the nervous system. In recent times the term has been used to
describe analog, digital and mixed-mode analog/digital systems that implement
models of neural systems (for perception, motor control or multisensory inte-
gration). The implementation of neuromorphic computing at the hardware level
can be realized by oxide-based memristors, threshold switches and transistors.
• Operator: a mapping from one vector space or module to another. Operators are
of critical importance in both linear algebra and functional analysis, and have
applications in many other pure and applied mathematics fields. For example, in
classical mechanics, the derivative is used ubiquitously, and in quantum
mechanics, observables are represented by Hermitian operators. Important prop-
erties of operators include linearity, continuity and boundedness.
• Orthonormal basis: for an inner product space V with finite dimension, a basis
for V whose vectors are orthonormal, that is, all are unit vectors that are
orthogonal to each other.
• Parallelism: a type of computation in which many calculations are carried out
simultaneously.
• Pattern matching: in computer science, pattern matching is the act of checking a
given sequence of tokens for the presence of the constituents of some pattern.
• Photoelectric effect: the observation that light shone on many metals produces
electrons called photoelectrons. The effect is commonly studied in electronic
physics and in chemistry disciplines such as quantum chemistry and
electrochemistry.
• Photon: a particle representing a quantum of light or other electromagnetic
radiation.
Appendix B: Glossary of Terms Used in the Book 191

• Planck’s constant: a physical constant that is the quantum of action and central to
quantum mechanics.
• Position counter: indicates where a computer is in its program sequence.
• Probability density: a function that describes the relative likelihood of a random
variable taking on a given value.
• Quantum circuit: a model for quantum computation whereby computation is a
sequence of quantum gates that are reversible transformations of a quantum
mechanical analog of an n-bit register, referred to as an n-qubit register.
• Quantum computation: a kind of computation that makes direct use of quantum
mechanical phenomena, such as superposition and entanglement, to perform
operations on data. Quantum computers are different from our digital electronic
computers based on transistors. Whereas digital computers require data to be
encoded in binary digits (always in one of two states, 0 or 1), quantum compu-
tation uses quantum bits, which can be in a superposition of states.
• Quantum decoherence: the loss of coherence or ordering of the phase angles
between system components in quantum superposition.
• Quantum entanglement: a physical phenomenon that occurs when pairs or
groups of particles are generated or interact in such a way that the quantum
state of each particle cannot be described independently.
• Quantum parallelism: a method whereby a quantum computer is able to perform
computations simultaneously.
• Quantum superposition: a fundamental principle of quantum mechanics that
states that, much like waves in classical physics, any two (or more) quantum
states can be added together (superposed) and the result will be another valid
quantum state, and conversely, that every quantum state can be represented as a
sum of two or more other distinct states.
• Remainder: the portion of the dividend that is not evenly divisible by the divisor.
• Reversible computing: a model of computing where the computational process
is to some extent reversible (in time). In a computational model that uses
transitions from one state of the abstract machine to another, a necessary
condition for reversibility is one-to-one mapping from states to their successors.
• Rule base: a set of rules that apply to a given inferential process. Each rule has an
IF-part (the condition), a THEN-part (the conclusion) and, optionally, an ELSE-
part.
• Spin: in quantum mechanics and particle physics, an intrinsic form of angular
momentum carried by elementary particles, composite particles (hadrons) and
atomic nuclei.
• Symbol: a letter, figure, or other character or mark or combination thereof used
to designate something.
• Synergy: the creation of a whole that is greater than the simple sum of its parts.
• Teleportation: a process by which quantum information (for instance, the exact
state of an atom or photon) is transmitted (theoretically intact) from one location
to another, by means of a classical communication system and quantum entan-
glement between the sending and receiving locations. Because it depends on
classical communication (which cannot take place faster than the speed of light),
192 Appendix B: Glossary of Terms Used in the Book

teleportation cannot be used for faster-than-light transmissions or for conven-


tional bits. Neither can it be used to make copies of a system, as this violates the
no-cloning theorem.
• Tensor product: the freest bilinear operation, applicable in different contexts to
vectors, matrices, tensors, vector spaces, algebras, topological vector spaces and
modules, among many other structures or objects.
• Transistor: a semiconductor device used to amplify or switch electronic signals
and electrical power. It is composed of semiconductor material with at least
three terminals for connection to an external circuit. A voltage or current applied
to one pair of the transistor’s terminals changes the current through another pair
of terminals. Because the controlled (output) power can be higher than the
controlling (input) power, a transistor can amplify a signal.
• Trigonometric (circular) function: in mathematics, any function of an angle that
relates the angles of a triangle to the lengths of its sides. Trigonometric functions
are important in the study of triangles and in the modeling of periodic
phenomena.
• Tunnel effect: a quantum mechanical phenomenon whereby a particle penetrates
a barrier in a way impossible according to the classical laws of physics.
• Turing machine: a hypothetical device with a set of logical rules of computation,
used in mathematical studies of the computability of numbers and in mathemat-
ical theories of automata and computers.
• Unitary matrix: in mathematics, a complex square matrix is unitary if its
conjugate transpose is also its inverse.
• Unitary transformation: a transformation that preserves the inner product (the
inner product of two vectors before transformation remains equal to their inner
product after transformation).
• Universal gate: AND, NOT and OR are basic gates which we can combine to
create any logic gate or any Boolean expression. NOR and NAND gates have the
particular property that either of them can create any logical Boolean expression
if arranged properly. We examine the operation of each gate separately as
universal gates.
• Wave function: in quantum mechanics, a quantum state of an isolated system of
one or more particles, whereby one wave function contains all information on
the entire system (not separate wave functions for each particle in the system).
Its interpretation is that of a probability amplitude and it can be used to derive
quantities associated with measurements, such as the average momentum of a
particle.
Suggested Reading

Barenco, A., Bennett, C.H., Cleve, R., DiVincenzo, D.P., Margolus, N., Shor, P., Sleator, T.,
Smolin, J., Weinfurter, H.: Elementary gates for quantum computation. Phys. Rev. A. 52(5),
3457–3467 (1995)
Benioff, P.: Quantum mechanical Hamiltonian models of Turing machines. J. Stat. Phys. 29,
515–546 (1982)
Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17, 525–532 (1973)
Bennett, C.H.: The thermodynamics of computation: a review. Int. J. Theoret. Phys. 21(12),
905–940 (1982)
Bennett, C.H., DiVincenzo, D.P.: Quantum information and computation. Nature. 404, 247–255
(2000)
Bennett, C.H., Landauer, R.: The fundamental physical limits of computation. Sci. Am. 253,
48–56 (1985)
Bennett, C.H., Shor, P.W.: Quantum information theory. IEEE Trans. Inf. Theory. 44(6),
2724–2742 (1998)
Brain Basics: Know your brain. Http://www.ninds.nih.gov/disorders/brain_basics/know_your_
brain.htm. Accessed Mar 2014
Brandom, R.: A first look inside Google’s futuristic quantum lab. http://www.theverge.com/2013/
10/10/4824026/a-first-look-inside-googles-secretive-quantum-lab. Accessed Mar 2014
Cirac, J.I., Zoller, P.: A scalable quantum computer with ions in an array of microtraps. Nature.
404, 579–581 (2000)
Cirac, J.I., Zoller, P.: Quantum teleportation between light and matter. Nature. 443, 557–560
(2006)
Desurvire, E.: Classical and Quantum Information Theory. Cambridge University Press, Cam-
bridge (2009)
Deutsch, D.: Quantum theory, the Church-Turing principle and the universal quantum computer.
Proc. R. Soc. A400, 97–117 (1985)
Deutsch, D., Jozsa, R.: Rapid solution of problems by quantum computation. Proc. R. Soc. A439,
553–558 (1992)
Diccionario de Computación: McGraw-Hill/Interamericana. ISBN: 970-10-0018-8 (1991)
Dieks, D.: Communication by EPR devices. Phys. Lett. A. 92(6), 271–272 (1982)
D-Wave, disentangled: Google explains the present and future of Quantum Computing. Http://
www.extremetech.com/extreme/177316-d-wave-disentangled-google-explains-the-present-
and-future-of-quantum-computing. Accessed Mar 2014
Feynman, R.P.: Simulating physics with computers. Int. J. Theor. Phys. 21, 467–488 (1982)
Feynman, R.P.: Lectures on Computation, Critical Eds (2003)

© Springer International Publishing AG 2017 193


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1
194 Suggested Reading

Feynman, R.P., Pines, D., Hey, A., Hey, J.G., Tollen, W.: Feynman Lectures on Computation.
Westview Press, Boulder (1996)
Fredkin, E., Toffoli, T.: Conservative logic. Int. J. Theor. Phys. 21, 219–253 (1982)
Gardner, H.: Multiple Intelligences: The Theory in Practice. Basic Books, New York (1993)
Gisin, N.: Nonlocality criteria for quantum teleportation. Phys. Rev. Lett. A. 210(3), 157–159
(1996)
Group of Quantum Computation: Department of Applied Mathematics and Computing,
Universidad Politécnica de Madrid, Introduction to the Quantum Model of Computation,
Technical Report Number 19, 2003
Grover, L.K.: A fast quantum mechanical algorithm for database search. The Alamos Physics
Preprint File. http://xxx.lanl.gov/abs/quant-ph/9605043 (1996)
Landauer, R.: Irreversibility and heat generation in the computing process. IBM J. Res. Dev. 5(3),
183–191 (1961)
Levine, I.N.: Quantum Chemistry. AC Eds. (1977)
Levine, I.N.: Quantum Chemistry, 7th edn. Pearson Education, London (2013)
Meglicki, Z.: Quantum Computing Without Magic: Devices. The MIT Press, Cambridge (2008)
Moret-Bonillo, V.: Can artificial intelligence benefit from quantum computing? Prog. Artif. Intell.
3(2), 89–105 (2015)
Neven, H.: Launching the Quantum Artificial Intelligence Lab. http://research.googleblog.com/
2013/05/launching-quantum-artificial.html. Accessed Mar 2014
Nielsen, M.A., Chuang, I.L.: Quantum Computation and Quantum Information. Cambridge
University Press, Cambridge (2000)
Poon, C.-S., Zhou, K.: Neuromorphic silicon neurons and large-scale neural networks: challenges
and opportunities. Front. Neurosci. (2011). doi:10.3389/Fnins.2011.00108
Quantum Artificial Intelligence Lab: http://en.wikipedia.org/wiki/Quantum_Artificial_Intelli
gence_Lab. Accessed Mar 2014
Shor, P.W.: Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a
Quantum Computer, The Alamos Physics Preprint File. http://xxx.lanl.gov/abs/quantph/
9508027 (1994)
Shor, P.W.: Why haven’t more quantum algorithms been found? J. ACM. 50(1), 87–90 (2003)
Sicart, T., Elkin, M.: Some Introductory Elements About the Quantum Computation. Department
of Basic Sciences. University EAFIT. Medellı́n, Colombia, June 1999
The Babbage Engine. http://www.computerhistory.org/babbage/. Accessed Mar 2014
Toffoli, T.: Reversible computing. MIT Technical Report MIT/LCS/TM-151 (1980)
Toffoli, T., Margolus, N.: Cellular Automata Machines: A New Environment for Modeling. The
MIT Press, Cambridge (1987)
Vance, A.: Intel says Adios to Knit and Jayhawk chips. Http://www.theregister.co.uk/2004/05/07/
intel_kills_tejas/ (From Inter- net March 2014)
Wichert, A.: Principles of Quantum Artificial Intelligence. World Scientific, New York (2013)
Wootters, W.K., Zurek, W.H.: A single quantum cannot be cloned. Nature. 299, 802–803 (1982)
Yanofsky, N.S., Mannucci, M.A.: Quantum Computing for Computer Scientists. Cambridge
University Press, Cambridge (2008)
Ying, M.: Quantum computation, quantum theory and AI. Artif. Intell. 174(2), 162–176 (2010)
Index

A Bra-ket notation, 12
Absolute zero point, 72 Bra notation, 70
Adjoint, 98
Algebra, 68, 73
Alpha particle, 72 C
Analytical engine, 176 Canonical basis, 93, 138, 163
AND operator, 16 Cartesian coordinates, 67
Angular momentum, 74 Cartesian product, 81
Artificial intelligence, 3, 165, 168, 176 CCN gate, 112, 122
Average value, 69, 72 Church-Turing principle, 76
Axiom, 25 Cirac, J.I., 175
Circuit, 11, 153
Cleve, R., 174
B Commutator, 68
Babbage, C., 166, 176 Complex number, 72
Backward reasoning, 3, 25 Compton scattering, 22, 66
Bayesian network, 176 Compton, A., 22
Bell state, 88 Controlled-controlled-NOT (CCN), 29
Benioff, P., 75, 174 Control register, 48
Bennett, C.H., 28, 50, 174 Corpuscular character of light, 54
Billiard balls, 35 Cryptography, 117
Binary decision, 2
Binary disjunction, 14, 15
Binary equality, 14 D
Binary logic, 1, 13–19, 25 Data-driven, 177
Binary negation, 14 Data-driven reasoning, 3, 25
Binary representation, 89 de Broglie, L., 54, 61, 66
Black body, 66, 72 de Broglie’s equation, 61
Black box, 163 Decoherence, 78, 175
Bloch sphere, 84, 116, 174 Density matrix, 117
Bohr, N., 58, 66, 175 Deutsch, D., 76, 135, 174
Boltzmann constant, 170 Deutsch-Jozsa algorithm, 145–154
Boole, G., 13 Deutsch’s algorithm, 136–143
Born, M., 63, 66 Differential equation, 72

© Springer International Publishing AG 2017 195


V. Moret-Bonillo, Adventures in Computer Science,
DOI 10.1007/978-3-319-64807-1
196 Index

Diffraction, 59, 72 I
Dirac, P., 12, 66, 70 Implication, 17
Information, 2, 6, 12, 27, 47, 49, 53, 79, 81, 85,
168–174
E Inner product space, 70, 73, 152
Eigenfunctions, 67, 72, 84
Eigenstates, 67, 72
Eigenvalue, 73 J
Einstein, A., 54, 66 Joint probability, 25
Ekert, A., 174 Jordan, P., 66
Electron, 12, 54, 56, 82 Jozsa, R., 135
Energy, 28, 39, 49, 53, 54, 56, 72, 166, 171
Entanglement, 50, 80, 174
Entropy, 171, 176 K
Euclidean space, 163 Ket notation, 12, 70
Exchange (EX), 27, 105 Knowledge, 168

F L
Fanout (FO), 27 Landauer, R., 53, 169
Feynman, R., 75, 81, 174 Learning, 22, 168, 177
Fly, M., 174 Lecerf, Y., 50
Fredkin, E., 22, 28 Levine, I., 64
Fredkin gate, 31–33, 124 Linear momentum, 73
Free energy, 37 Linear operator, 98
Full adder, 21, 37, 46, 47 Logarithm, 25
Logic gates, 19, 77, 81, 172
Logic operator, 28
G Lovelace, A., 166
General relativity, 73
Genetic algorithms, 173, 177
Gigaflops, 78, 173 M
Grover, L., 76 Macchiavello, C., 174
Grover’s algorithm, 76 Machine learning, 168, 177
Matrix, 73
Maxwell, J.C., 54, 117
H Maxwell’s demon, 80, 117
Hadamard gates, 101, 141, 150 Measurement, 56, 66, 82, 90, 92, 162, 175, 176
Hadamard operation, 161 Momentum, 55, 58
Hadamard transformation, 140
Half adder, 20–22, 37
Hamiltonian operator, 66, 73, 126 N
Haroche, S., 175 NAND gate, 32
Heisenberg, W., 56, 66 NAND operator, 17
Heisenberg’s uncertainty principle, 56–60, 72, Neural networks, 177
73, 79, 82 Neuromorphic, 177
Hermitian, 73 Neurons, 20, 166, 177
conjugate, 103, 118 Newton’s second law of motion, 60
operator, 67 No-cloning theorem, 80, 98
Hilbert space, 72, 73, 81 NOR operator, 16
Index 197

Normalized, 84, 93 Reversible architectures, 39–44, 46–51


Normalized state function, 67 Reversible computing, 37, 39, 47
NOT operator, 14 Reversible inverse implication, 41, 42
Number bases, 10 Reversible NOR, 42, 43
Reversible OR, 43, 44
Reversible simple implication, 40
O Reversible Turing machine, 50
Operator, 73 Reversible XNOR, 41, 42
OR operator, 14 Reversible XOR, 44, 45
Orthogonal states, 77, 93 Rule base, 25
Orthonormal basis, 85, 117 Rutherford, E., 53

P S
Parallelism, 78, 80, 89, 163, 165 Scalability, 79
Pattern matching, 177 Schoelkopf, R., 77
Pauli matrices, 83, 160 Schr€odinger, E., 60, 66
Pauli, W., 66 Schr€odinger’s equation, 60–63
Photoelectric effect, 54, 66, 73 Schumacher, B., 79
Photon, 73 Schumacher compression, 79
Planck, M., 54 Self-adjoint, 73
Planck’s constant, 54, 73 Shannon, C., 5
Position, 56 Shannon’s formula, 170
Position counter, 133 Shor’s algorithm, 76
Postulates, 72 Simon, D., 76, 154
Postulates of quantum mechanics, 66, 67 Simon’s algorithm, 154–159
Probability, 2, 6, 83, 87, 91, 149 Simon’s problem, 155
Probability density, 63, 74 Sinusoidal solution, 62
Spin, 12, 74, 82
Spin pin, 53
Q Stern, O., 56
Quantum algorithms, 76, 80, 135–152, Stickers, 10–12
154–163 Superposition, 50, 77, 79, 83, 101, 141
Quantum circuit, 80, 117 Symbol, 25
Quantum computing, 50, 65, 71, 75–118, Synergy, 177
165, 174
Quantum cryptography, 76, 79
Quantum decoherence, 117 T
Quantum entanglement, 117 Teleportation, 163, 174
Quantum information, 78 Tensor product, 86, 95, 117, 141, 150
Quantum mechanical, 71 Thermodynamics, 176
Quantum mechanical postulates, 91 Toffoli gate, 29–31, 116, 122
Quantum mechanics, 53, 54, 56–74, 79, 81, 86 Toffoli, T., 22
Quantum parallelism, 117 Transistor, 177
Quantum superposition, 117 Transpose, 118
Quantum teleportation, 76, 89, 160–162 Trigonometric (circular) function, 61, 74
Quantum Turing machine, 81 Trigonometric relations, 103
Qubit, 76, 82, 93 Tunnel effect, 75, 117, 169
Turing machines, 51, 75, 77, 137

R
Registers, 90, 98 U
Remainder, 25 Unit of measure, 2
Reversibility, 27, 29, 39, 49, 99, 172 Unit vectors, 163
Reversible AND, 44, 45 Unitary matrix, 80, 99, 112, 117
198 Index

Unitary operators, 98 Wavelength, 54, 61


Unitary properties, 78 Wineland, D., 175
Unitary transformation, 98, 105, 107–109, Wiseman, H.M., 175
117, 150
Unitary vectors, 85, 88
Universal gate, 38 X
XNOR operator, 18
XOR operator, 15
V
Vectors, 66, 72, 82
Velocity, 54, 56 Y
Ying, X.E., 173

W
Wave, 54, 58, 75 Z
Wave function, 74 Zoller, P., 175

Vous aimerez peut-être aussi