0% found this document useful (0 votes)
12 views

Introduction To Quantum Algorithms Johannes A Buchmann pdf download

The document is an introduction to quantum algorithms by Johannes A. Buchmann, outlining the principles of quantum computing and its potential to outperform classical systems. It covers foundational topics such as classical computation, quantum mechanics, and various quantum algorithms, including Shor's and Grover's algorithms. The book aims to be accessible to readers with diverse backgrounds in mathematics, physics, and computer science, providing a comprehensive understanding of quantum algorithms and their applications.

Uploaded by

quipsamrad60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Introduction To Quantum Algorithms Johannes A Buchmann pdf download

The document is an introduction to quantum algorithms by Johannes A. Buchmann, outlining the principles of quantum computing and its potential to outperform classical systems. It covers foundational topics such as classical computation, quantum mechanics, and various quantum algorithms, including Shor's and Grover's algorithms. The book aims to be accessible to readers with diverse backgrounds in mathematics, physics, and computer science, providing a comprehensive understanding of quantum algorithms and their applications.

Uploaded by

quipsamrad60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

Introduction To Quantum Algorithms Johannes A

Buchmann download

https://ebookbell.com/product/introduction-to-quantum-algorithms-
johannes-a-buchmann-56632724

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Introduction To Quantum Algorithms Via Linear Algebra Second Edition


Richard J Lipton Kenneth W Regan

https://ebookbell.com/product/introduction-to-quantum-algorithms-via-
linear-algebra-second-edition-richard-j-lipton-kenneth-w-
regan-56402476

An Introduction To Quantum Computing Algorithms Progress In Computer


Science And Applied Logic 19 Softcover Reprint Of The Original 1st Ed
2000 Pittenger

https://ebookbell.com/product/an-introduction-to-quantum-computing-
algorithms-progress-in-computer-science-and-applied-
logic-19-softcover-reprint-of-the-original-1st-
ed-2000-pittenger-55202036

Introduction To Quantum Field Theory Classical Mechanics To Gauge


Field Theoriessolutions Manual For Teachers Ethan N Carragher

https://ebookbell.com/product/introduction-to-quantum-field-theory-
classical-mechanics-to-gauge-field-theoriessolutions-manual-for-
teachers-ethan-n-carragher-46591366

Introduction To Quantum Technologies Alto Osada Rekishu Yamazaki

https://ebookbell.com/product/introduction-to-quantum-technologies-
alto-osada-rekishu-yamazaki-47283296
Introduction To Quantum Groups 1st Edition Teo Banica

https://ebookbell.com/product/introduction-to-quantum-groups-1st-
edition-teo-banica-48812246

Introduction To Quantum Groups Teo Banica

https://ebookbell.com/product/introduction-to-quantum-groups-teo-
banica-49169390

Introduction To Quantum Mechanics 2nd Edition S M Blinder

https://ebookbell.com/product/introduction-to-quantum-mechanics-2nd-
edition-s-m-blinder-50483800

Introduction To Quantum Fields On A Lattice Jan Smit

https://ebookbell.com/product/introduction-to-quantum-fields-on-a-
lattice-jan-smit-50904810

Introduction To Quantum Computing River Publishers Series In Rapids In


Computing And Information Science And Technology 1st Edition Ahmed
Banafa

https://ebookbell.com/product/introduction-to-quantum-computing-river-
publishers-series-in-rapids-in-computing-and-information-science-and-
technology-1st-edition-ahmed-banafa-51343730
4
64

Introduction
to Quantum
Algorithms

Johannes A. Buchmann
Introduction
to Quantum
Algorithms
Pure and Applied
Sally
The UNDERGRADUATE TEXTS • 64
SERIES

Introduction
to Quantum
Algorithms

Johannes A. Buchmann
EDITORIAL COMMITTEE
Daniel P. Groves John M. Lee
Tara S. Holm Maria Cristina Pereyra
Giuliana Davidoff (Chair)

2020 Mathematics Subject Classification. Primary 11-xx, 68-xx, 81-xx, 94-xx.

For additional information and updates on this book, visit


www.ams.org/bookpages/amstext-64

Library of Congress Cataloging-in-Publication Data


Cataloging-in-Publication Data has been applied for by the AMS.
See http://www.loc.gov/publish/cip/.
DOI: https://doi.org/10.1090/amstext/64

Copying and reprinting. Individual readers of this publication, and nonprofit libraries acting
for them, are permitted to make fair use of the material, such as to copy select pages for use
in teaching or research. Permission is granted to quote brief passages from this publication in
reviews, provided the customary acknowledgment of the source is given.
Republication, systematic copying, or multiple reproduction of any material in this publication
is permitted only under license from the American Mathematical Society. Requests for permission
to reuse portions of AMS publication content are handled by the Copyright Clearance Center. For
more information, please visit www.ams.org/publications/pubpermissions.
Send requests for translation rights and licensed reprints to [email protected].

c 2024 by the American Mathematical Society. All rights reserved.
The American Mathematical Society retains all rights
except those granted to the United States Government.
Printed in the United States of America.

∞ The paper used in this book is acid-free and falls within the guidelines
established to ensure permanence and durability.
Visit the AMS home page at https://www.ams.org/
10 9 8 7 6 5 4 3 2 1 29 28 27 26 25 24
Contents

Preface ix
The advent of quantum computing ix
The goal of the book x
The structure of the book xi
What is not covered xiv
For instructors xiv
Acknowledgements xv

Chapter 1. Classical Computation 1


1.1. Deterministic algorithms 1
1.2. Probabilistic algorithms 16
1.3. Analysis of probabilistic algorithms 21
1.4. Complexity theory 29
1.5. The circuit model 35
1.6. Circuit families and circuit complexity 40
1.7. Reversible circuits 43

Chapter 2. Hilbert Spaces 53


2.1. Kets and state spaces 54
2.2. Inner products 56
2.3. Linear maps 67
2.4. Endomorphisms 72
2.5. Tensor products 93

v
vi Contents

Chapter 3. Quantum Mechanics 103


3.1. State spaces 104
3.2. State spaces of composite systems 112
3.3. Time evolution 113
3.4. Measurements 118
3.5. Density operators 123
3.6. The quantum postulates for mixed states 131
3.7. Partial trace and reduced density operators 134

Chapter 4. The Theory of Quantum Algorithms 141


4.1. Simple single-qubit operators 142
3
4.2. More geometry in ℝ 144
4.3. Rotation operators 158
4.4. Controlled operators 167
4.5. Swap and permutation operators 174
4.6. Ancillary and erasure gates 175
4.7. Quantum circuits revisited 176
4.8. Universal sets of quantum gates 179
4.9. Implementation of controlled operators 181
4.10. Perfectly universal sets of quantum gates 187
4.11. A universal set of quantum gates 192
4.12. Quantum algorithms and quantum complexity 199

Chapter 5. The Algorithms of Deutsch and Simon 205


5.1. The Deutsch algorithm 206
5.2. Oracle complexity 209
5.3. The Deutsch-Jozsa algorithm 209
5.4. Simon’s algorithm 213
5.5. Generalization of Simon’s algorithm 218

Chapter 6. The Algorithms of Shor 221


6.1. Idea of Shor’s factoring algorithm 222
6.2. The Quantum Fourier Transform 222
6.3. Quantum phase estimation 228
6.4. Order finding 233
6.5. Integer factorization 244
6.6. Discrete logarithms 248
6.7. Relevance for cryptography 251
6.8. The hidden subgroup problem 252
Contents vii

Chapter 7. Quantum Search and Quantum Counting 255


7.1. Quantum search 256
7.2. Quantum counting 268

Chapter 8. The HHL Algorithm 277


8.1. The problem 277
8.2. Overview 279
8.3. Analysis and applications 282

Appendix A. Foundations 283


A.1. Basics 283
A.2. The asymptotic notation 288
A.3. Number theory 289
A.4. Algebra 298
A.5. Trigonometric identities and inequalities 304

Appendix B. Linear Algebra 307


B.1. Vectors 308
B.2. Modules and vector spaces 308
B.3. Linear maps between modules 311
B.4. Matrices 313
B.5. Square matrices 315
B.6. Free modules of finite dimension 322
B.7. Finite-dimensional vector spaces 324
B.8. Tensor products 330
B.9. Tensor products of finite-dimensional vector spaces 337

Appendix C. Probability Theory 345


C.1. Basics 345
C.2. Bernoulli experiments 348

Appendix D. Solutions of Selected Exercises 351

Bibliography 363

Index 365
Preface

The advent of quantum computing


Computing has become indispensable in all areas of society, economy, science, and
engineering. As the scope and complexity of problems we aim to solve with comput-
ers expand, the demand for computing power continues to skyrocket. For decades,
Moore’s law has driven the exponential growth of computing resources, enabling faster
and more capable machines. However, physical limitations loom on the horizon, chal-
lenging the continuation of this trend. Addressing the impending limitations of classi-
cal computing requires innovative solutions. New computing architectures and algo-
rithms that can significantly outperform classical systems would be a game changer,
promising the ability to tackle problems that are currently beyond reach.
Such an innovative concept is that of a quantum computer. It harnesses the prin-
ciples of quantum mechanics. While in classical computing, bits can represent ei-
ther a “0” or a “1”, quantum bits or qubits can exist in superpositions of these values.
This property allows quantum registers with several qubits to store and process expo-
nentially more information than classical registers with an equivalent number of bits.
However, as this book will demonstrate, harnessing this property of quantum comput-
ers presents significant challenges.
The concept of quantum computing began to take shape in the early 1980s, thanks
to the visionary work of several researchers. The mathematician and physicist Yuri
Manin [Man80], [Man99] pondered whether computers based on the principles of
quantum mechanics could challenge the Church-Turing thesis and go beyond the ca-
pabilities of Turing machines. Physicist Paul Benioff [Ben80] proposed the model of a
quantum Turing machine, laying the theoretical foundation for quantum computation.
Physics Nobel laureate Richard Feynman [Fey82] recognized the potential of quantum
computers to simulate physics experiments involving quantum effects. Quantum algo-
rithms became known to virtually everyone in the world through the groundbreaking

ix
x Preface

work of Peter Shor [Sho94] on quantum polynomial time factoring and discrete log-
arithm algorithms. Shor’s work alarmed the world as it revealed the vulnerability of
all known public-key cryptography, one of the fundamental pillars of cybersecurity, to
quantum computer attacks.
Another early advancement in quantum computing that garnered significant at-
tention was Lov Grover’s algorithm [Gro96], offering a quadratic speedup for unstruc-
tured search problems. This breakthrough further fueled the growing interest in quan-
tum computing. Grover’s algorithm captured widespread interest because of its ability
to solve a very generic problem, making it useful across a wide range of applications.
In the decades following these early developments, many more quantum algo-
rithms have been discovered. An example is the HHL algorithm [HHL08], which can
be used to find properties of solutions of large sparse linear systems with certain prop-
erties, providing an exponential speedup over classical solvers like Gauss elimination.
Since linear algebra is one of the most important tools in all areas of science and engi-
neering, the HHL algorithm has wide applications, including machine learning, which
is one of the most significant techniques in computer science today.
This progress should not deceive us, as the development of quantum algorithms
remains a significant challenge. Sometimes, there is the impression that quantum com-
puting allows all computations to be parallelized and significantly accelerated. How-
ever, that is not the case. In reality, each new quantum algorithm requires a unique
idea. Consequently, such algorithms can currently only accelerate a few computa-
tion problems. Moreover, only very few of these improvements come with exponential
speedups.
All the algorithms mentioned in this book are designed for universal, gate-based
quantum computers, which are the most widely recognized and extensively researched
type of quantum computers. In addition to universal quantum computers, there are
more specialized types of quantum computers, such as quantum annealers and quan-
tum simulators. Quantum annealers utilize annealing techniques to solve optimiza-
tion problems by finding the lowest-energy state of a physical system. On the other
hand, quantum simulators are specifically designed to simulate quantum systems and
study quantum phenomena. However, this book focuses on universal quantum com-
puters due to their versatility and because they are the most interesting from a com-
puter science perspective.

The goal of the book


The book is well suited for readers with a basic understanding of calculus, linear alge-
bra, algebra, and probability theory, as well as algorithms and complexity as taught in
basic university courses on these subjects. However, recognizing that the readers may
have diverse backgrounds in computer science, mathematics, physics, and engineer-
ing, my goal is to make the book self-contained and rigorous from the perspectives of all
these subjects. Thus, even readers with little knowledge of algorithms and complexity
can acquire this by studying Chapter 1. Similarly, for those lacking knowledge of cer-
tain topics in linear algebra, algebra, or probability theory, the appendix and Chapter 2
can compensate. Furthermore, the physics introduced in Chapter 3 is sufficient for the
The structure of the book xi

subsequent chapters. I also adopted this approach in writing the book due to my own
experience. Despite having degrees in mathematics and physics and being a computer
science professor for over 30 years, I found myself needing to refresh my memory on
several required concepts and to learn new material. Therefore, my objective is to make
the presentation understandable with a minimum of prerequisites, ensuring clarity for
both myself and the readers.
My approach of covering all the details will lead to the situation that some readers
may already possess knowledge covered in the introductory chapters. However, even
they are likely to encounter new and vital information in these chapters, essential for
understanding quantum algorithms. For example, Chapter 1 gives an introduction to
the theory of reversible computation, which is not typically part of the standard com-
puter science education. Chapter 2 introduces mathematicians to the Dirac notation,
commonly used by physicists. Chapter 3 further expands the understanding of physi-
cists by applying the quantum mechanics postulates to quantum gates and circuits.
Therefore, I encourage those with prior knowledge to read these sections, taking note
of the notation used in the book and of unfamiliar results. This is vital for grasping the
intricacies of my explanation of quantum algorithms.

The structure of the book


As described, the initial three chapters lay the groundwork required to dive into quan-
tum computing.
Chapter 1 presents the theoretical aspects of classical computation relevant to un-
derstanding quantum computing. It begins with classical algorithms, particularly fo-
cusing on probabilistic algorithms and their complexity analysis. This is pivotal be-
cause quantum algorithms, such as Shor’s algorithm, can be seen as probabilistic algo-
rithms with quantum circuits as subroutines. Therefore, the analysis of probabilistic al-
gorithms effortlessly extends to the analysis of quantum algorithms. Furthermore, the
classical complexity classes elucidated in this chapter serve as a blueprint for defining
quantum complexity classes. The second part of this chapter is dedicated to the com-
putational model of classical Boolean circuits, specifically examining the theory of re-
versible circuits, which bears a direct connection to their quantum counterparts. This
serves as a foundation for designing basic quantum algorithms using quantum circuits.
The chapter establishes that every Boolean function can be computed by a Boolean cir-
cuit and covers universal sets of classical gates, uniform families of circuits, and their
correlation with classical algorithms and their complexity. Moreover, it demonstrates
that every Boolean circuit can be transformed into a reversible circuit — an essential
result later applied to show that every Boolean function can be computed by a quantum
circuit.
Chapter 2 explores the theory of finite-dimensional Hilbert spaces, which forms
the mathematical framework for modeling the physics of quantum computing. We
note, however, that finite-dimensional Hilbert spaces may fall short of modeling gen-
eral quantum mechanics. The chapter begins by establishing the necessary founda-
tions, including essential concepts like inner products, orthogonality, linear maps, and
their adjoints. It also introduces the Schur decomposition theorem, which provides
xii Preface

valuable tools for subsequent discussions. Moving forward, the chapter familiarizes the
reader with significant operators in quantum mechanics, such as Hermitian, unitary,
and normal operators. Of particular significance is the spectral theorem, a fundamen-
tal result that offers profound insights into these operators and their characteristics.
The consequences of the spectral theorem are also explored to enrich the reader’s un-
derstanding. Furthermore, the chapter delves into the concept of tensor products of
finite-dimensional Hilbert spaces, a crucial notion in quantum computing. The dis-
cussion culminates with an elucidation of the Schmidt decomposition theorem, which
plays a pivotal role in characterizing the entanglement of quantum systems.
Chapter 3 constitutes the third foundational pillar of quantum computing required
in this book, encompassing the essential background of quantum mechanics. This
chapter introduces the relevant quantum mechanics postulates. To illustrate their rele-
vance, the chapter applies these postulates to introduce fundamental concepts of quan-
tum computing, including quantum bits, registers, gates, and circuits. Simple exam-
ples of quantum computation are provided to enhance the reader’s understanding of
the connection between the postulates and quantum algorithms. In addition, the chap-
ter provides the foundation for the geometric interpretation of quantum computation.
It achieves this by establishing the correspondence between states of individual quan-
tum bits and points on the Bloch sphere, a pivotal concept in quantum computing vi-
sualization. Moreover, the chapter presents an alternative description of the relevant
quantum mechanics using density operators. This approach enables the modeling of
the behavior of components within composed quantum systems.
The foundational groundwork laid out in the initial three chapters, including the
domains of computer science, mathematics, and physics, sets the stage for a compre-
hensive exploration of quantum algorithms in Chapter 4. This chapter embarks on
this transformative journey by shedding light on pivotal quantum gates, which serve
as the fundamental constituents of quantum circuits. We start by introducing single-
qubit gates, demonstrating that their operations can be perceived as rotations within
three-dimensional real space. Subsequently, we delve into the realm of multiple-qubit
operators, with a particular focus on controlled operators. In addition, this chapter
familiarizes readers with the significance of ancillary and erasure gates, which play
a vital role in the augmentation and removal of quantum bits. Leveraging analogous
outcomes from classical reversible circuits, the chapter shows that every Boolean func-
tion can be realized through a quantum circuit. In contrast to the classical scenario, the
quantum case does not adhere to the notion that a finite set of quantum gates suffices to
implement any quantum operator. Instead, finite sets of quantum gates are presented,
enabling the approximation of all quantum circuits. Lastly, the chapter ushers in the
concept of quantum complexity theory, using the analogy between classical probabilis-
tic algorithms and quantum algorithms. It introduces the complexity class BQP, which
stands for bounded-error quantum polynomial time.
The following four chapters focus on specific quantum algorithms.
Chapter 5 introduces early algorithms designed to illustrate the quantum comput-
ing advantage. We begin with the Deutsch algorithm, as presented in David Deutsch’s
seminal paper from 1985 [Deu85], and its generalization by David Deutsch and Richard
The structure of the book xiii

Jozsa in 1992 [DJ92]. Subsequently, we explore Daniel R. Simon’s algorithm, pro-


posed in 1994 [Sim94], which demonstrated a quadratic speedup compared to the best-
known classical algorithm for its specific problem. Through the explanations of these
algorithms, two key principles emerge, elucidating why quantum computing can sur-
pass classical computing. The first principle is quantum parallelism, which capitalizes
on the ability of quantum registers to exist in superpositions of states, allowing for si-
multaneous computation of multiple possibilities. The second principle is quantum
interference, empowering quantum algorithms to concentrate probability amplitudes
on correct answers while suppressing incorrect ones. This phenomenon increases the
likelihood of obtaining the desired solution to a computational problem. Also, the im-
portant phase-kickback method is explained.
Chapter 6 introduces the most famous quantum algorithms, namely Peter Shor’s
algorithms for factoring integers and computing discrete logarithms [Sho94]. The
chapter commences by presenting an overview of Shor’s integer factorization algo-
rithm, serving as a road map for the subsequent concepts introduced and their utiliza-
tion within this algorithm. Next, the key ingredient of Shor’s algorithms is presented:
the Quantum Fourier Transform. A detailed explanation illustrates how this opera-
tor and its inverse can be efficiently implemented using simple quantum gates. The
Quantum Fourier Transform is then employed to solve the problem of quantum phase
estimation. By utilizing quantum phase estimation, a polynomial time quantum algo-
rithm for computing the order of an integer modulo another positive integer is devel-
oped, leading to a polynomial time quantum algorithm for integer factorization. More-
over, the chapter reveals how quantum phase estimation enables the computation of
discrete logarithms modulo positive integers in polynomial time.
Chapter 7 explores another significant quantum algorithm with numerous appli-
cations: the Grover search algorithm from 1996. This algorithm offers a quadratic ad-
vantage when searching for a specific target item in an unstructured set. The chapter
delves into the concept of amplitude amplification, a powerful technique that plays
a pivotal role in Grover’s algorithm. Moreover, the chapter introduces the quantum
counting algorithm, a notable contribution by Gilles Brassard, Peter Høyer, and Alain
Tapp in 1998 [BHT98]. This algorithm utilizes Grover’s algorithm in combination with
quantum phase estimation to count the number of solutions for a given search prob-
lem.
Chapter 8 provides an overview of the HHL algorithm, which focuses on comput-
ing properties of solutions for large sparse linear systems over the complex numbers.
The primary purpose of this chapter is to demonstrate how the ideas of previously in-
troduced algorithms in this book enable the design of such an advanced algorithm.
The book also features an extensive appendix that serves as a valuable resource
for readers. It introduces the mathematical notation used throughout the book and
covers essential concepts, including results that might not commonly be part of stan-
dard mathematical university education. Appendix A begins by exploring fundamen-
tal mathematical concepts, including groups, rings, and fields. It then delves into the
necessary topics in number theory, such as the greatest common divisor and its com-
putation, prime factor decomposition, and continued fractions. In addition, this part
xiv Preface

of the appendix lists essential trigonometric identities and inequalities that play a cru-
cial role in the main part of the book. Appendix B focuses on linear algebra. Its first
part briefly reviews important concepts and results. The second part covers the con-
cept of tensor products, which is of significant importance in quantum computing and
is typically not included in introductory courses in linear algebra. Lastly, Appendix C
contains the required notions and results from probability theory. This knowledge is
essential for the analysis of probabilistic and quantum algorithms.

What is not covered


The main focus of this book is on the theory of quantum algorithms, rather than the
practical aspects of their implementation. However, it is essential to acknowledge two
significant aspects related to realizing practical quantum computers, which our pre-
sentation does not cover.
One such aspect is quantum error correction, which plays a crucial role in quan-
tum computing. Quantum systems are highly sensitive to their environment, leading
to decoherence, which can introduce errors in quantum computations. Quantum error
correction techniques are designed to protect quantum computing from the harmful
effects of decoherence and errors, making quantum algorithms more reliable and ro-
bust.
Another critical aspect is the physical implementation of quantum computers.
Various approaches are being explored to build qubits and quantum gates for prac-
tical quantum computers. These approaches include using superconducting circuits,
trapped ions, photonic qubits, topological qubits, and quantum dots, among others.
Each of these approaches has its advantages and challenges, and researchers are ac-
tively working to develop scalable and efficient quantum computing technologies.
An overview of the main results of quantum computing, including quantum error
correction and quantum computer architectures, can be found in the Wikipedia article
“Timeline of quantum computing” [Aut23].

For instructors
This book is suitable for self-study. It is also intended and has been used for teaching
introductory courses on quantum algorithms. My recommendation to instructors for
such a course is as follows: If most of the participants are already familiar with the
required basics of algorithms and complexity, linear algebra, algebra, and probability
theory, the course should cover Chapters 3, 4, 5, 6, 7, and 8 in this order, exploring dif-
ferent aspects of quantum algorithms. Individual students lacking some basic knowl-
edge can familiarize themselves with those topics using the detailed explanations in
the respective parts of the book. If the majority of the participants in the course is un-
familiar with certain basic topics, the instructor may want to briefly cover them either
in a preliminary lecture or when they are used during the course.
Depending on the instructor’s intentions and the available time, the course may
focus more on theoretical explanations and proofs or on the practical aspects of how
quantum algorithms work. In both situations, students who desire more background
Acknowledgements xv

than is covered in the course can supplement their knowledge through self-study of
the corresponding book parts.

Acknowledgements
I express my sincere gratitude to the following individuals who have been instrumental
in supporting me throughout the process of writing this book. Their invaluable advice,
discussions, and comments have played a pivotal role in shaping the content and qual-
ity of this work: Gernot Alber, Gerhard Birkl, Jintai Ding, Samed Düzlü, Fritz Eisen-
brand, Marc Fischlin, Mika Göös, Iryna Gurevich, Matthieu Nicolas Haeberle, Taketo
Imaizumi, Michael Jacobson, Nigam Jigyasa, Norbert Lutkenhaus, Alastair Kay, Ju-
liane Krämer, Gen Kimura, Michele Mosca, Jigyasa Nigam, Rom Pinchasi, Ahamad-
Reza Sadeghi, Masahide Sasaki, Alexander Sauer, Florian Schwarz, Tsuyoshi Takagi,
Shusaku Uemura, Thomas Walther, Yuntao Wang, and Ho Yun. Their dedication to
sharing their expertise and knowledge has been truly invaluable, and I am deeply grate-
ful for their willingness to engage in insightful discussions and provide constructive
feedback throughout this journey.
I also extend my heartfelt gratitude to Ina Mette, the responsible person at AMS.
Her belief in the potential of this book and her continuous encouragement to pursue
this project have been instrumental in its realization. I am deeply grateful for her un-
wavering support and guidance throughout the writing process. I am also grateful to
Arlene O’Sean and her team at AMS for their great job in carefully proofreading the
book and making its appearance so nice.
I learned a lot from the books on quantum computing by Michael A. Nielsen and
Isaac L. Chuang [NC16] and by Phillip Kaye, Raymond Laflamme, and Michele Mosca
[KLM06].
The writing of this book would not have been possible without the invaluable con-
tributions of several open-source LaTeX packages, which greatly facilitated the presen-
tation of complex concepts. I extend my gratitude to the creators and maintainers of
these packages:
• The powerful TikZ library1 and its extension circuitikz2 were instrumental in
visualizing circuits and diagrams throughout the book.
• I used the open source TikZ code for illustrating the right-hand rule,3
• For the clear representation of quantum circuits, I relied on quantikz.4
• To illustrate quantum states on Bloch spheres, I used the blochsphere package.5
• The packages algorithm and algorithmpseudocode6 were indispensable in pre-
senting algorithms in a structured and easily understandable format.
• For handling the Dirac notation with ease, I benefited from the physics package.7
1
https://tikz.net/
2
https://ctan.org/pkg/circuitikz
3
https://tikz.net/righthand_rule/
4
https://ctan.org/pkg/quantikz
5
https://ctan.org/pkg/blochsphere
6
https://www.overleaf.com/learn/latex/Algorithms
7
https://www.ctan.org/pkg/physics
xvi Preface

I am sincerely grateful to the open-source community for making these and many more
tools available, enhancing the quality of this work and simplifying its creation.
Finally, I would like to acknowledge the support provided by ChatGPT8 in improv-
ing many formulations of my presentation. As I am not a native speaker of the English
language, this assistance was of great help.

8
https://chat.openai.com/
Chapter 1

Classical Computation

Quantum algorithms outperform the best-known classical algorithms in numerous


computational tasks. To establish and demonstrate these advancements, we rely on
essential mathematical frameworks. These frameworks aid our understanding of clas-
sical and quantum computation, enable us to address questions about problem solubil-
ity on both classical and quantum computers, and assess the computational efficiency
of these algorithms.
This chapter presents models fundamental to classical computation, providing the
basis for the corresponding models in quantum computation. We begin by explain-
ing a model for classical deterministic and probabilistic algorithms. It forms the basis
for reviewing key concepts and results in classical complexity theory. The part on the
analysis of probabilistic algorithms is particularly important, as it plays a crucial role in
later chapters where we discuss quantum algorithms which are probabilistic in nature.
The methods used for analyzing probabilistic algorithms, including success probability
amplification, will be directly applicable to the analysis of quantum algorithms.
Moving on from the algorithmic model, we introduce the classical circuit model
of computation, with a particular emphasis on reversible circuits. These reversible cir-
cuits can be readily transformed into quantum circuits, providing the essential insight
that quantum computing is Turing complete.

1.1. Deterministic algorithms


In the realm of computer algorithms, there exist various formal models. The most
famous is the model of Turing machines. It was invented in 1936 by the mathematician
Alan Turing. The Turing machine model has mathematical rigor. But its connection
with algorithms implemented using real-world programming languages is difficult to
understand and describe. Hence, we will introduce a model of computation that strikes
a balance between a formal description and a representation resembling real-world
computing. A very good and comprehensive presentation of computer algorithms that

1
2 1. Classical Computation

uses similar modeling is the book by Thomas H. Cormen, Charles E. Leiserson, Ronald
L. Rivest, and Clifford Stein [CLRS22].

1.1.1. Basics. To explain our model, we introduce some basic concepts and re-
sults. We begin by defining alphabets.
Definition 1.1.1. An alphabet is a finite nonempty set.
Example 1.1.2. The simplest alphabet is the unary alphabet {I}, which contains only
the symbol I. The most commonly used alphabet in computer science is the binary
alphabet {0, 1}, where each element is referred to as a bit. Other commonly used al-
phabets in computer science include the set {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} of decimal digits,
the set {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 𝐴, 𝐵, 𝐶, 𝐷, 𝐸, 𝐹} of hexadecimal digits, and the Latin al-
phabet ℛ = {a, . . . , z, A, . . . , Z, ␣} that includes lowercase and uppercase Latin letters,
as well as the space symbol ␣.

Next, we introduce words over alphabets.


Definition 1.1.3. Let Σ be an alphabet.
(1) By Σ∗ we denote the set of all finite sequences over Σ including the empty se-
quence which is denoted by ( ).
(2) The elements of Σ∗ are called words or strings over Σ.
(3) If 𝑤 is a word over Σ, then its elements are called the characters of 𝑤 and |𝑤|
denotes the length of 𝑤.
(4) The set of words over Σ of length 𝑛 ∈ ℕ0 is denoted by 𝑆 𝑛 .
(5) If 𝑛 ∈ ℕ0 and 𝑠 ⃗ ∈ Σ𝑛 , then we write 𝑠 ⃗ = 𝑠0 𝑠1 ⋯ 𝑠𝑛−1 , 𝑠 ⃗ = “𝑠0 ⋯ 𝑠𝑘−1 ”,
𝑠 ⃗ = (𝑠0 𝑠1 ⋯ 𝑠𝑛−1 ), or 𝑠 ⃗ = (𝑠0 , 𝑠1 , . . . , 𝑠𝑛−1 ). We also use other numberings of the
characters. For example, we may start the numbering with 1.
Example 1.1.4. The sequence III is a word over the alphabet {I}. The sequence (0, 1, 0)
is a word over the alphabets of bits, decimal digits, and hexadecimal digits. The se-
quence (0, 1, 2) is a word over the alphabets of decimal digits and hexadecimal digits.
The sequence (0, 1, 𝐴) is a word over the alphabet of hexadecimal digits. All these
words have length 3. Finally “another␣failure” is a word over the alphabet of Roman
letters.

Next, we define encodings.


Definition 1.1.5. An encoding of a set 𝑆 with respect to an alphabet Σ is an injective
map 𝑒 ∶ 𝑆 → Σ∗ .
Example 1.1.6. A simple encoding of the set ℕ0 of nonnegative integers is
(1.1.1) 𝑒 ∶ ℕ0 → {I}∗ , 𝑎 ↦ I𝑎 = I⏟
⋯I .
𝑎 times
𝑎
For 𝑎 ∈ ℕ0 we call 𝑒(𝑎) = I the unary representation of 𝑎. Its length is 𝑎.

As an important way of encoding nonnegative integers, we introduce their binary


representation.
1.1. Deterministic algorithms 3

Proposition 1.1.7. Let 𝑎 ∈ ℕ. Then there is a uniquely determined sequence 𝑏 ⃗ =


(𝑏0 , . . . , 𝑏𝑛−1 ) ∈ {0, 1}∗ with 𝑏0 = 1 such that
𝑛−1
(1.1.2) 𝑎 = ∑ 𝑏𝑖 2𝑛−𝑖−1 .
𝑖=0

The length of this sequence is 𝑛 = ⌊log2 𝑎⌋ + 1.


Exercise 1.1.8. Prove Proposition 1.1.7.
Definition 1.1.9. Let 𝑎 ∈ ℕ.
(1) The sequence 𝑏 ⃗ from Proposition 1.1.7 is called the binary expansion or binary
representation of 𝑎.
(2) The positive integer 𝑛 = ⌊log2 𝑎⌋ + 1 is called the binary length or bit length of 𝑎.
It is denoted by bitLength(𝑎).
(3) The binary expansion or binary representation of 0 is defined to be (0). The binary
length or bit length of 0 is set to 1.
Example 1.1.10. The binary expansion of 7 is 111 since 7 = 22 + 21 + 20 . The binary
length of 7 is 3.
Exercise 1.1.11. Determine the binary expansion and the binary length of 251.

As we have seen, every finite sequence of bits that starts with the bit ‘1’ is assigned
to a uniquely determined positive integer as its binary expansion. Now, we also assign
uniquely determined nonnegative integers to all sequences in {0, 1}∗ including those
that start with the bit 0 using the following definition.

Definition 1.1.12. For all 𝑛 ∈ ℕ and 𝑏 ⃗ = (𝑏0 , . . . , 𝑏𝑛−1 ) ∈ {0, 1}∗ we set
𝑛−1
(1.1.3) stringToInt(𝑏)⃗ = ∑ 𝑏𝑖 2𝑛−𝑖−1
𝑖=0

and call this value the integer represented by 𝑏.⃗

Note that nonnegative integers are represented by infinitely many strings in {0, 1}∗ .
Specifically, they are represented by all strings that result from prepending a string
consisting only of zeros to their binary expansions. Also, the number 0 is represented
by all finite sequences of the bit “0”.
Exercise 1.1.13. Use Proposition 1.1.7 to show that the map (1.1.3) is a bijection.

1.1.2. Data types. Algorithms perform operations on objects of specific data


types, such as bits or integers. In this context, a data type refers to a nonempty set,
and the individual elements within this set are called data type objects.
In the presented model, the elementary data types consist of the following sets:
• the set {0, 1} of bits,
• the set ℤ of integers,
• the set ℛ of lowercase and uppercase Latin letters, including the space symbol ␣.
4 1. Classical Computation

Table 1.1.1. Elementary data types and their sizes.

Data type Element Size


{0, 1} 𝑏 size(𝑏) = O(1)
ℛ 𝑥 size(𝑥) = O(1)
ℤ 𝑎 size(𝑎) = O(bitLength(|𝑎|))

Another common data type is that of a floating point number, which represents an
approximation to a real number. However, analyzing algorithms that use this data
type is more complex, as it requires considering error propagation. For our purposes,
we do not need to take this data type into account.
Objects of these elementary data types are represented and stored using bits. The
encoding of these objects can be defined in a straightforward manner for both bits and
Roman characters. Integers are encoded using the binary expansion of their absolute
value along with the indication of their sign. The size of these encodings refers to the
number of bits used. For a data type object 𝑎, the size of its encoding is denoted by
size 𝑎. It may vary depending on the specific computing platform, programming lan-
guage, or other relevant factors. However, detailed discussions regarding these specific
implementations are beyond the scope of this book, and we present only a summary of
the different sizes of the elementary data types in Table 1.1.1.
In our model, advanced data types include vectors and matrices over some data
type, which are described in Sections B.1 and B.4. For example, (1, 2, 3) is an integer
0 1
vector. Similarly, ( ) is a bit matrix. Vectors and matrices are also encoded by bits,
1 0
using the encoding method of their data type. The encodings of vectors and matrices
possess the following properties. For any 𝑘 ∈ ℕ, the size of the encoding of a vector
𝑠 ⃗ = (𝑠0 , . . . , 𝑠𝑘−1 ) over some data type satisfies
𝑘−1
(1.1.4) size(𝑠)⃗ = O ( ∑ size 𝑠𝑖 ) .
𝑖=0

Similarly, for any 𝑘, 𝑙 ∈ ℕ, the size of the encoding of a matrix 𝑀 = (𝑚𝑖,𝑗 )𝑖∈ℤ𝑘 ,𝑗∈ℤ𝑙 over
some data type satisfies

(1.1.5) size(𝑀) = O ( ∑ size 𝑚𝑖,𝑗 ) .


𝑖∈ℤ𝑘 ,𝑗∈ℤ𝑙

Here we have used ℤ𝑘 = {0, . . . , 𝑘 − 1}.

1.1.3. Variables. A variable is a symbol that serves as a reference to a memory


unit with the capability of storing an element of a specific data type. Once defined,
the data type of a variable remains fixed. The value of a variable corresponds to the
content stored in its associated memory cell. Thus, the size of a variable is determined
by the size of its value. This concept is illustrated in Figure 1.1.1, where the variable 𝑎
represents a memory cell containing the integer 19, while the variable 𝑏 represents a
memory cell containing the word “bit”. Therefore, the value of 𝑎 is 19, and the value of
𝑏 is “bit”.
1.1. Deterministic algorithms 5

𝑎 𝑏

19 “bit”

Figure 1.1.1. The variables 𝑎 and 𝑏 represent memory cells that contain 19 and “bit”, respectively.

In most programming languages, variables must be explicitly declared before they


can be used. This declaration serves three essential purposes: first, it specifies the
data type of the variable; second, it reserves the necessary memory space to store the
variable’s value; and third, it assigns a name to the variable for easy reference within
the code. However, to streamline the presentation of algorithms and to keep the focus
on the core logic, we omit explicit variable declarations and assume that the data type
and name of the variables are apparent from the context in which they are used.

1.1.4. Instructions. Instructions serve as fundamental building blocks of algo-


rithms and play a central role in defining their functionality. In this section, we will
introduce the instructions, also known as statements, that algorithms in our model can
execute, and we will provide upper bounds on their running times and memory size
requirements. We will use the terms “instructions” and “statements” interchangeably
to refer to these essential algorithmic components.
Unless otherwise specified, we measure the running times in bit operations. By bit
operations, we refer to all operations that a computer can perform on a single or two
bits. For example, a collection of bit operations commonly available on most computers
is shown in Table 1.1.3. The concept is that all operations are executed using these bit
operations, and the number of such bit operations is counted. This concept is justified
by the fact that, as we will see in Section 1.5.3, all operations can be implemented using
the operators 𝖭𝖮𝖳, 𝖠𝖭𝖣, and 𝖮𝖱. Analogously, we measure the space requirement by
counting the number of memory units used during the computation.
The basic instruction is the assign instruction:

(1.1.6) 𝑎 ← 𝑏.

It sets the value of a variable 𝑎 of a certain data type to an element 𝑏 of this data type
or to the value of a variable 𝑏 of the same data type as 𝑎. The running time and space
requirement for this operation is O(size 𝑏).
Algorithms may also assign the result of an operation to a variable. An example of
such an instruction is

(1.1.7) 𝑎 ← 𝑏 + 3.

The right-hand side of this assignment is the arithmetic expression 𝑏 + 3. When such
an instruction is executed, the arithmetic expression is evaluated first. In the example,
6 1. Classical Computation

Table 1.1.2. Permitted operations on integers, their running times, and space require-
ments for operands of size O(𝑛).

Operation Operands Result Time Space


absolute value 𝑎∈ℤ |𝑎| O(𝑛) O(𝑛)
add 𝑎, 𝑏 ∈ ℤ 𝑎+𝑏 O(𝑛) O(𝑛)
subtract 𝑎, 𝑏 ∈ ℤ 𝑎−𝑏 O(𝑛) O(𝑛)
multiply 𝑎, 𝑏 ∈ ℤ 𝑎∗𝑏 O(𝑛2 ) O(𝑛)
divide 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 ⌊𝑎/𝑏⌋ O(𝑛2 ) O(𝑛)
remainder 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 𝑎 mod 𝑏 O(𝑛2 ) O(𝑛)
equal 𝑎, 𝑏 ∈ ℤ 𝑎=𝑏 O(𝑛) O(𝑛)
less than 𝑎, 𝑏 ∈ ℤ 𝑎<𝑏 O(𝑛) O(𝑛)
less than or equal to 𝑎, 𝑏 ∈ ℤ 𝑎≤𝑏 O(𝑛) O(𝑛)
square root 𝑎∈ℤ ⌊√𝑎⌋ O(𝑛2 ) O(𝑛)
floor 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 ⌊𝑎/𝑏⌋ O(𝑛2 ) O(𝑛)
ceiling 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 ⌈𝑎/𝑏⌉ O(𝑛2 ) O(𝑛)
next integer 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 ⌊𝑎/𝑏⌉ O(𝑛2 ) O(𝑛)
bit length 𝑎 ∈ ℕ0 bitLength(𝑎) O(size 𝑎) O(size 𝑎)
string to int 𝑠 ⃗ ∈ {0, 1}∗ stringToInt(𝑠)⃗ O(size 𝑠)⃗ O(size 𝑠)⃗

it depends on the value of the variable 𝑏. Then the result is assigned to 𝑎. It is permit-
ted that the variable on the left side also appears on the right side. For instance, the
instruction
(1.1.8) 𝑐←𝑐+1
increments a counter 𝑐 by 1.
Next, we present the operations that may be used in expressions on the right side
of an assign instruction. The permitted operations on integers are listed in Table 1.1.2,
including their time and space requirements. The results of the operations absolute
value, floor, ceiling, next integer, add, subtract, multiply, divide, and remainder are
integers. The results of the comparisons are the bits 0 or 1 where 1 stands for “true”
and 0 stands for “false”. For a description and analysis of these algorithms see [AHU74]
and [Knu82].
In most programming languages, only integers with limited bit lengths are avail-
able, such as 64-bit integers. When there is a need to work with integers of arbitrary
length, specialized algorithms are required to handle operations on such numbers. To
simplify our descriptions, we assume that operations on integers of arbitrary length are
available as basic operations. These operations can be realized using the running time
and memory space as listed in Table 1.1.2 but there exist much more efficient algo-
rithms for integer multiplication and division with remainder. For instance, a highly
efficient integer multiplication algorithm developed by David Harvey and Joris van
der Hoeven [HvdH21] has running time O(𝑛 log 𝑛) for 𝑛-bit operands. Additionally,
it is known that for any integer multiplication algorithm with a running time of 𝑀(𝑛),
there exist division with remainder and square root algorithms with a running time of
O(𝑀(𝑛)) (see [AHU74, Theorem 8.5]). However, in practice, these faster algorithms
1.1. Deterministic algorithms 7

Table 1.1.3. Permitted logic operations.

Name Logic operator


𝖠𝖭𝖣 ∧
𝖮𝖱 ∨
𝖭𝖮𝖳 ¬
𝖭𝖠𝖭𝖣 ↑
𝖭𝖮𝖱 ↓
𝖷𝖮𝖱 ⊕

Table 1.1.4. Functions implemented by the permitted logic operations.

𝑎 𝑏 𝑎∧𝑏 𝑎∨𝑏 ¬𝑎 𝑎↑𝑏 𝑎↓𝑏 𝑎⊕𝑏


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

are only advantageous for handling very large numbers. For more typical integer sizes,
classical algorithms may still be more efficient in terms of practical performance.
On the bits 0 and 1 our algorithms can perform the logic operations that are listed
in Table 1.1.3. They implement the functions shown in Table 1.1.4. All permitted logic
operations run in time O(1) and require space O(1).

Exercise 1.1.14. Show that ⊕ is addition in ℤ2 and ∧ is multiplication in ℤ2 .

Algorithms may also use the branch statements for, while, repeat, and if. They
initiate the execution of a sequence of instructions if some branch condition is satis-
fied. In the analysis of algorithms, we will assume that the time and space required to
execute an algorithm part that uses a branch instruction is the time and space required
to evaluate the branch condition and the corresponding sequence of instructions, pos-
sibly several times. Branch instructions together with the corresponding instruction
sequence are referred to as loops.
We now provide more detailed explanations of the branch instructions using the
examples shown in Figures 1.1.2 and 1.1.3 utilizing pseudocode that is further de-
scribed in Section 1.1.5.
A for statement appears at the beginning of an instruction sequence and is ended
by an end for statement. This instruction sequence is executed for all values of a spec-
ified variable, as indicated in the for statement. In the for loop in Figure 1.1.2, the
variable is 𝑖, and the instruction 𝑝 ← 2𝑝 is executed for all 𝑖 from 𝑖 = 1 to 𝑖 = 𝑒. After
𝑖 iterations of this instruction, the value of 𝑝 is 2𝑖 . So after completion of the for loop,
the value of 𝑝 is 2𝑒 .
Also, while statements appear at the beginning of an instruction sequence after
which there is an end while statement. The instruction sequence is executed as long
as the condition in the while statement is true. For instance, the while loop in Figure
8 1. Classical Computation

𝑝←1 𝑖←1 𝑖←0


for 𝑖 = 1 to 𝑒 do 𝑝←1 𝑝←1
𝑝 ← 2𝑝 while 𝑖 ≤ 𝑒 do repeat
end for 𝑝 ← 2𝑝 𝑝 ← 2𝑝
𝑖 ←𝑖+1 𝑖 ←𝑖+1
end while until 𝑖 = 𝑒

Figure 1.1.2. for, while, and repeat loops that compute 2𝑒 .

1.1.2 also computes 2𝑒 . For this, the counting variable 𝑖 is initialized to 1 and the vari-
able 𝑝 is initially set to 1. Before each round of the while loop, the logic expression 𝑖 ≤ 𝑒
is evaluated. If it is true, then the instruction sequence in the while loop is executed.
In the example, 𝑝 is set to 2𝑝 and the counting variable 𝑖 is increased by 1. After the
𝑘th iteration of the while loop, the value of 𝑝 is 2𝑘 and the counting variable is 𝑖 = 𝑘.
Hence, after the 𝑒th iteration of the while loop we have 𝑝 = 2𝑒 and 𝑖 = 𝑒 + 1. So the
while condition is violated and the computation continues with the first instruction
following the while loop.
Next, repeat statements are also followed by an instruction sequence that is ended
by an until statement that contains a condition. If this condition is satisfied, the com-
putation continues with the first instruction after the until statement. Otherwise, the
instruction sequence is executed again. In the example in Figure 1.1.2, the instruction
𝑝 ← 2𝑝 is executed until the counting variable 𝑖 is equal to 𝑒. Note that the instruction
sequence is executed at least once. Therefore, this repeat loop cannot compute 20 .
Exercise 1.1.15. Find for, while, and repeat loops that compute the integer repre-
sented by a bit sequence 𝑠0 𝑠1 ⋯ 𝑠𝑛−1 ∈ {0, 1}𝑛 where 𝑛 ∈ ℕ.

Now we explain if statements. The three different ways to use if are shown in
Figure 1.1.3. Such a statement is followed by a sequence of instructions that is ended
by an end if statement. The instruction sequence may be interrupted by an else state-
ment or by one or more else if statements. The code segment on the left side of Figure
1.1.3 checks whether 𝑎 < 0 is true, in which case the instruction 𝑎 ← −𝑎 is executed.
Otherwise, the computation continues with the instruction following the end if state-
ment. This code segment computes the absolute value of 𝑎 because 𝑎 is set to −𝑎 if 𝑎 is
negative and otherwise remains unchanged. The code segment in the middle of Figure
1.1.3 checks whether 𝑎 is divisible by 11. If so, the variable 𝑠 is set to 1 and otherwise
to 0. Finally, the code segment on the right side of Figure 1.1.3 first checks if 𝑎 > 0 in
which case the variable 𝑠 is set to 1. Next, if 𝑎 = 0, 𝑠 is set to 0. Finally, 𝑠 is set to −1 if
𝑎 < 0. The result is the sign 𝑠 of 𝑎.
A computation terminates when the return instruction is used. This instruction
makes the result available for further use and takes the form
(1.1.9) return(𝑎)
where 𝑎 is an element or variable of some data type or a sequence of such objects. The
time and space requirement for this operation is O(𝑆), where 𝑆 represents the sum of
the sizes of the objects in the return statement.
1.1. Deterministic algorithms 9

if 𝑎 < 0 then if 𝑎 mod 11 = 0 if 𝑎 > 0 then


𝑎 ← −𝑎 then 𝑠←1
end if 𝑠←1 else if 𝑎 = 0
else then
𝑠←0 𝑠←0
end if else if 𝑎 < 0
then
𝑠 ← −1
end if

Figure 1.1.3. if statements.

Algorithms can also return the result of expressions. For instance, a return in-
struction may be of the form

(1.1.10) return(2 ∗ 𝑎 + 𝑏).

In this case, the expression is evaluated first, and then the result is returned. The time
and space requirements of this instruction are O(𝑡) and O(𝑠), respectively, where 𝑡 and
𝑠 denote the time and space required to evaluate the corresponding expression.
Finally, a call to a subroutine is also considered a valid instruction in our model.
It takes the form

(1.1.11) 𝑎 ← 𝐴(𝑏)

where 𝐴 represents an algorithm, as elaborated in the subsequent section. For example,


such an instruction may be expressed as

(1.1.12) 𝑏 ← 𝗉𝗈𝗐𝖾𝗋(𝑎, 𝑒).

Here, the call 𝗉𝗈𝗐𝖾𝗋(𝑎, 𝑒) invokes the subroutine, returning the result of 𝑎𝑒 , where 𝑎
and 𝑒 are both nonnegative integers.
The time and space requirements associated with a subroutine call are O(𝑡) and
O(𝑠), respectively, where 𝑡 and 𝑠 represent the time and space required by the subrou-
tine to execute. Section 1.4 provides an explanation of how these requirements are
determined.

1.1.5. Definition of deterministic algorithms. In this section, we explain the


concept of a deterministic algorithm and illustrate how such an algorithm can be pre-
sented using pseudocode. Pseudocode serves as a high-level depiction of an algorithm’s
logic and sequence of steps, with the aim of ensuring ease of comprehension for human
readers. To simplify the discussion, we will just talk about an “algorithm” instead of a
“deterministic algorithm”. In contrast, in the next section, we introduce probabilistic
algorithms.
As mentioned earlier, our model of computation is a compromise between a for-
mal description and a representation that resembles real algorithms written in some
programming language. Therefore, in this section, we do not use formal definitions.
10 1. Classical Computation

But in the next sections, we formally define the properties of algorithms. These defini-
tions can be made precise if a formal model of computation is used, such as the Turing
machine model.
We illustrate our algorithm model using the Euclidean algorithm. The correspond-
ing pseudocode is shown in Algorithm 1.1.16.

Algorithm 1.1.16. Euclidean algorithm


Input: 𝑎, 𝑏 ∈ ℤ
Output: gcd(𝑎, 𝑏)
1: gcd(𝑎, 𝑏)
2: 𝑎 ← |𝑎|
3: 𝑏 ← |𝑏|
4: while 𝑏 ≠ 0 do
5: 𝑟 ← 𝑎 mod 𝑏
6: 𝑎←𝑏
7: 𝑏←𝑟
8: end while
9: return 𝑎
10: end

An algorithm 𝐴 has the following components:


(1) An Input statement. It specifies a finite number of input variables, their data
types, and the permitted values of these variables. The set of all permitted input
value tuples is referred to as Input(𝐴).
(2) An Output statement. For every 𝑎 ∈ Input(𝐴) it specifies properties that may
depend on 𝑎 and makes a return value a correct output. The set of all correct
outputs for input 𝑎 is denoted by Output(𝐴, 𝑎).
(3) An algorithm name followed by the sequence of input variables which is used
when 𝐴 is called by other algorithms as a subroutine.
(4) A finite sequence of instructions that ends with end.
For example, in the Euclidean algorithm, the Input statement specifies that there
are two integer input variables 𝑎 and 𝑏 which may take any integer value. According
to the Output statement, the algorithm returns gcd(𝑎, 𝑏). The name of the algorithm
and the sequence of input variables can be seen in line 1 of the pseudocode: gcd(𝑎, 𝑏).
It is followed by 8 instructions. The last line of the pseudocode is end.
Let 𝐴 be an algorithm that has 𝑘 input variables 𝑣 0 , . . . , 𝑣 𝑘−1 of data types 𝐷0 , . . . ,
𝐷𝑘−1 , respectively. Then the set Input(𝐴) of all allowed input values of 𝐴 satisfies
Input(𝐴) ⊂ 𝐷0 × ⋯ × 𝐷𝑘−1 . For the Euclidean algorithm, we have 𝑘 = 2, 𝐷0 = 𝐷1 = ℤ,
and Input(𝐴) = ℤ × ℤ. Running 𝐴 with input 𝑎 = (𝑎0 , . . . , 𝑎𝑘−1 ) ∈ Input(𝐴) means
the following. 𝐴 assigns 𝑎𝑖 to the input variable 𝑣 𝑖 for all 𝑖 ∈ ℤ𝑘 . Then it executes its
sequence of instructions. This process is called the run of 𝐴 with input 𝑎. We list a few
requirements that every deterministic algorithm must satisfy.
1.1. Deterministic algorithms 11

(1) Each run of the algorithm with a permitted input carries out a return instruction.
This means that the algorithm terminates on any input 𝑎 ∈ Input(𝐴).
(2) When the algorithm performs a return instruction, the return value is correct;
i.e., it has the property specified in the Output statement.
(3) Executing the return instruction is the only way the algorithm can terminate.
This means that after executing a statement that is not a return instruction there
is always a next instruction that the algorithm carries out.

Example 1.1.17. We describe the run of the Euclidean algorithm with input (𝑎, 𝑏) =
(100, 35). The instructions in lines 2 and 3 replace 𝑎 and 𝑏 by their absolute values. For
the chosen input, they have no effect. Since 𝑏 = 35, the while condition is satisfied.
Hence, the Euclidean algorithm executes 𝑟 ← 100 mod 35 = 30, 𝑎 ← 𝑏 = 35, and
𝑏 ← 𝑟 = 30. After this, the while condition is still satisfied since 𝑏 = 30. So the
Euclidean algorithm executes 𝑟 ← 35 mod 30 = 5, 𝑎 ← 𝑏 = 30, and 𝑏 ← 𝑟 = 5. Also,
after this iteration of the while loop, the while condition is still satisfied since 𝑏 = 5.
The Euclidean algorithm executes 𝑟 ← 30 mod 5 = 0, 𝑎 ← 𝑏 = 5, and 𝑏 ← 𝑟 = 0. Now,
the while condition is violated. So the while loop is no longer executed. Instead, the
return instruction following end while is carried out. This means that the algorithm
returns 5 which is gcd(100, 35).

We model the run of an algorithm 𝐴 on an input 𝑎 ∈ Input(𝐴) as a sequence of


states. A state describes the situation of the algorithm immediately before the exe-
cution of an instruction. It includes the contents of the memory cells corresponding
to the variables in the algorithm and the instruction to be executed next. For example,
consider the run of the Euclidean algorithm with input (100, 35). Tables 1.1.5 and 1.1.6
show the first and final states of this run.
If the instruction in a state is not the return statement, then the algorithm per-
forms this instruction. This may change the value of the variables. Then the algorithm
enters the next state since in our model termination is only possible when the return
instruction is carried out. This next state is uniquely determined by the previous state.
So, the input 𝑎 ∈ Input(𝐴) uniquely determines the execution of the algorithm and
its return value, which is referred to by 𝐴(𝑎). This explains the name “deterministic

Table 1.1.5. Beginning of the run of the Euclidean algorithm with input (100, 35).

State# Memory contents Next instruction


𝑎 𝑏 𝑟
1 100 35 𝑎 ← |𝑎|
2 100 35 𝑏 ← |𝑏|
3 100 35 while 𝑏 ≠ 0 do
4 100 35 𝑟 ← 𝑎 mod 𝑏
5 100 35 30 𝑎←𝑏
6 35 35 30 𝑏←𝑟
7 35 30 30 end while
8 35 30 30 while 𝑏 ≠ 0 do
12 1. Classical Computation

Table 1.1.6. End of the run of the Euclidean algorithm with input (100, 35).

State# Memory contents Next instruction


𝑎 𝑏 𝑟
1 30 5 5 while 𝑏 ≠ 0 do
2 30 5 5 𝑟 ← 𝑎 mod 𝑏
3 30 5 0 𝑎←𝑏
4 5 5 0 𝑏←𝑟
5 5 0 0 end while
6 5 0 0 while 𝑏 ≠ 0 do
7 5 0 0 return 𝑎

algorithm”. For instance, consider State 3 in Table 1.1.5. The value of 𝑏 is 35. So the
while condition is satisfied. The execution of the while instruction does not change
the values of 𝑎, 𝑏, or 𝑟 and causes the next instruction to be 𝑟 ← 𝑎 mod 𝑏. So State 4 is
uniquely determined by State 3.
Since we require deterministic algorithms to always terminate, the same state can-
not occur repeatedly in an algorithm run. Otherwise, the algorithm would enter an
infinite loop. In other words, the states in algorithm runs are pairwise different.
It is important to prove the correctness of an algorithm. This means that on input of
any 𝑎 ∈ Input(𝐴) the algorithm terminates and its output has the specified properties.
In Example 1.1.18, we present the correctness proof of the Euclidean algorithm.
Example 1.1.18. We prove the correctness of the Euclidean algorithm. First, note that
after 𝑏 is replaced by its absolute value, the sequence of values of 𝑏 is strictly decreasing
since starting from the second 𝑏, any such value is the remainder of a division by the
previous value of 𝑏. So at some point, we must have 𝑏 = 0 which means that the
algorithm terminates. Next, as Exercise 1.1.19 shows, the value of gcd(𝑎, 𝑏) in line 4
is always the same. But when the algorithm terminates, we have 𝑏 = 0 and therefore
gcd(𝑎, 𝑏) = gcd(𝑎, 0) = 𝑎. The fact that gcd(𝑎, 𝑏) does not change is called an algorithm
invariant. Such invariants are frequently used in correctness proofs of algorithms.
Exercise 1.1.19. Show that in line 4 of the Euclidean algorithm, the value of gcd(𝑎, 𝑏)
is always the same.

As a further example, we present a deterministic factoring algorithm. Recall that


a composite integer is an integer 𝑎 that can be written as 𝑎 = 𝑏𝑐 where 𝑏, 𝑐 are integers
and 𝑏 is a proper divisor of 𝑎; i.e., 𝑎 mod 𝑏 = 0 and 0 < |𝑏| < |𝑎|. The goal of a factoring
algorithm is to find a proper divisor of a given integer 𝑎 if 𝑎 is composite. Algorithm
1.1.21 is such an algorithm. It is based on the fact that any composite integer 𝑎 has a
proper divisor 𝑏 with 1 < 𝑏 ≤ √|𝑎|. This is proved in Exercise 1.1.20. The input of the
algorithm is an integer 𝑎 > 1. It enumerates all integers 𝑏 with 1 < 𝑏 ≤ √𝑎 and checks
whether 𝑏 is a divisor of 𝑎. If no divisor is found, then 𝑎 is proved to be a prime number
in which case the algorithm returns 0.
Exercise 1.1.20. Show that every composite integer 𝑎 has a proper divisor 𝑏 such that
1 < 𝑏 ≤ √|𝑎|.
1.1. Deterministic algorithms 13

Algorithm 1.1.21. A deterministic factoring algorithm


Input: 𝑎 ∈ ℤ>1
Output: A proper divisor 𝑏 of 𝑎 if 𝑎 is composite, or 0 if 𝑎 is a prime number
1: 𝖽𝖾𝗍𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
2: for all 𝑏 = 2, . . . , ⌊√𝑎⌋ do
3: if 𝑎 mod 𝑏 = 0 then
4: return 𝑏
5: end if
6: end for
7: return 0
8: end

Exercise 1.1.22. Let 𝑎 = 35. Determine the first three and the last three states of the
run of Algorithm 1.1.21.

1.1.6. Decision algorithms. In classical complexity theory, decision algorithms


play an important role. Such an algorithm decides whether a string 𝑠 ∈ {0, 1}∗ belongs
to a subset 𝐿 of {0, 1} which is called a language. The input of a decision algorithm is a
string 𝑠 ⃗ in {0, 1}∗ . The output is 0 or 1, where 1 means that the input 𝑠 ⃗ belongs to 𝐿 and
0 means that 𝑠 ⃗ belongs to the complement of 𝐿 in {0, 1}∗ . We also say that the algorithm
decides the language 𝐿.
Example 1.1.23. Algorithm 1.1.24 decides the language 𝐿 that consists of all strings in
𝑠 ⃗ ∈ {0, 1}∗ representing composite integers. It works like Algorithm 1.1.21 except that
the output corresponding to a composite number is 1 and the output is 0 if the input
string 𝑠 ⃗ is (), represents 0, 1, or a prime number.

There is a close connection between decision and more general algorithms. For ex-
ample, as shown in Example 1.4.21, an algorithm that decides whether an integer has
a proper divisor below a given bound can be transformed into an integer factoring al-
gorithm with almost the same efficiency. This can be generalized to many algorithmic
problems.

Algorithm 1.1.24. Compositeness decision algorithm


Input: 𝑠 ⃗ ∈ {0, 1}∗
Output: 1 if stringToInt(𝑠)⃗ is composite and 0 otherwise
1: 𝖽𝖾𝖼𝗂𝖽𝖾𝖢𝗈𝗆𝗉(𝑠)⃗
2: 𝑎 ← stringToInt(𝑠)⃗
3: for all 𝑏 = 2, . . . , ⌊√𝑎⌋ do
4: if 𝑎 mod 𝑏 = 0 then
5: return 1
6: end if
7: end for
8: return 0
9: end
14 1. Classical Computation

1.1.7. Time and space complexity. Let 𝐴 be an algorithm. Its efficiency de-
pends on the time complexity and the memory requirements of 𝐴 which we discuss in
this section.
Definition 1.1.25. (1) The running time or time complexity of 𝐴 for a particular in-
put 𝑎 ∈ Input(𝐴) is the sum of the time required for reading the input 𝑎 which
is O(size(𝑎)) and the running times of the instructions executed during the algo-
rithm run with input 𝑎.
(2) The worst-case running time or worst-case time complexity of 𝐴 is the function
(1.1.13) wTime𝐴 ∶ ℕ → ℝ≥0
that sends a positive integer 𝑛 which is the size of an input of 𝐴 to the maximum
running time of 𝐴 over all inputs of size 𝑛. If 𝑛 is not the size of an input of 𝑎, then
we set wTime𝐴 (𝑛) = 0.

Next, we define the space complexity of 𝐴.


Definition 1.1.26. (1) The space complexity of 𝐴 for a particular input 𝑎 is the total
amount of memory space that is used in the algorithm run with input 𝑎.
(2) The worst-case space complexity of 𝐴 is the function
(1.1.14) wSpace𝐴 ∶ ℕ → ℝ≥0
that sends a positive integer 𝑛 which is the size of an input of 𝐴 to the maximum
space complexity of 𝐴 over all inputs of size 𝑛. If 𝑛 is not the size of an input of 𝑎,
then we set wSpace𝐴 (𝑛) = 0.

Using the Definitions 1.1.25 and 1.1.26, we define the asymptotic time and space
complexity of deterministic algorithms.
Definition 1.1.27. Let 𝑓 ∶ ℕ → ℝ>0 be a function. We say that 𝐴 has asymptotic worst-
case running time or space complexity O(𝑓) if wTime𝐴 = O(𝑓) or wSpace𝐴 = O(𝑓),
respectively. The words “asymptotic” and “worst-case” may also be omitted.

It is common to use special names for certain time and space complexities. Several
of these names are listed in Table 1.1.7.

Table 1.1.7. Asymptotic time and space complexity names.

Name Time or space complexity


constant O(1)
logarithmic O(log 𝑛)
linear O(𝑛)
quasilinear O(𝑛(log 𝑛)𝑐 ) for some 𝑐 ∈ ℕ
quadratic O(𝑛2 )
cubic O(𝑛3 )
polynomial O(𝑛𝑐 ) for some 𝑐 ∈ ℕ
𝜀
subexponential O(2𝑛 ) for all 𝜀 ∈ ℝ>0
𝑐
exponential O(2𝑛 ) for some 𝑐 ∈ ℕ
1.1. Deterministic algorithms 15

Exercise 1.1.28. Show that quasilinear complexity can also be written as 𝑛1+o(1) , poly-
nomial complexity as 𝑛O(1) or 2O(log 𝑛) , subexponential complexity as 2o(𝑛) , and expo-
O(1)
nential complexity as 2𝑛 .

Example 1.1.29. We analyze the time and space complexity of the Euclidean Algo-
rithm 1.1.16. Let 𝑎, 𝑏 ∈ ℤ be the input of the algorithm, and let 𝑛 be the maximum
of size(𝑎) and size(𝑏). The time to read the input 𝑎, 𝑏 is O(𝑛). After the operations in
lines 2 and 3 we have 𝑎, 𝑏 ≥ 0. The time and space complexity of these instructions
is O(𝑛). If 𝑏 = 0, then the while loop is not executed and 𝑎 is returned, which takes
time O(𝑛). If 𝑏 ≠ 0 and 𝑎 ≤ 𝑏, then after the first iteration of the while loop, we have
𝑏 < 𝑎. It follows from Exercise 1.1.30 that the total number of executions of the while
loop is O(𝑛). Also, by this exercise, the size of the operands used in the executions of
the while loop is O(𝑛). So, the running time of each iteration is O(𝑛2 ) and the space
requirement is O(𝑛). This shows that the worst-case running time of the Euclidean
algorithm is O(𝑛3 ) and the worst-case space complexity is O(𝑛). Thus, the Euclidean
algorithm has cubic running time. Using more complicated arguments, it can even be
shown that this algorithm has quadratic running time (see Theorem 1.10.5 in [Buc04]).

What is the practical relevance of worst-case running times when comparing algo-
rithms? Let us take two algorithms, 𝐴 and 𝐴′ , both designed to solve the same problem,
such as computing the greatest common divisors. It is essential to note that if algorithm
𝐴 has a smaller asymptotic running time than algorithm 𝐴′ , it does not automatically
make 𝐴 superior to 𝐴′ in practice. This comparison only indicates that 𝐴 is faster than
𝐴′ for inputs greater than a certain length. However, this input length can be so large
that it becomes irrelevant for most real-world use cases.
For example, in [AHU74] it is shown that for any integer multiplication algorithm
with a worst-case time complexity of 𝑀(𝑛), there exists a gcd algorithm with a worst-
case time complexity of O(𝑀(𝑛) log(𝑛)). Additionally, [HvdH21] presents an integer
multiplication algorithm with a worst-case running time of O(𝑛 log 𝑛). As a result,
2
there is a corresponding gcd algorithm with a worst-case running time of O(𝑛 log 𝑛).
However, this improved complexity only outperforms the O(𝑛2 ) algorithm for very
large integers, which may not occur in most common input sizes.

Exercise 1.1.30. Let 𝑎, 𝑏 ∈ ℕ, 𝑎 > 𝑏, be the input of the Euclidean algorithm. Let
𝑟0 = 𝑎 and 𝑟1 = 𝑏. Denote by 𝑘 the number of iterations of the while loop executed
in the algorithm and denote by 𝑟2 , 𝑟3 , . . . , 𝑟 𝑘+1 the sequence of remainders 𝑟 which are
computed in line 5 of the Euclidean algorithm. Prove that the sequence (𝑟 𝑖 )0≤𝑖≤𝑘+1 is
strictly decreasing and that 𝑟 𝑖+2 < 𝑟 𝑖 /2 for all 𝑖 ∈ ℤ𝑘 . Conclude that 𝑘 = O(size 𝑎).

Example 1.1.31. We determine the worst-case time and space complexity of the De-
terministic Factoring Algorithm 1.1.21. Let 𝑛 = bitLength 𝑎. The number of iterations
of the for loop in this algorithm is O(2𝑛/2 ). Each iteration of the for loop requires time
O(𝑛2 ) and space O(𝑛). Hence, the worst-case time complexity of Algorithm 1.1.21 is
O(𝑛2 2𝑛/2 ) = 2O(𝑛) and the worst-case space complexity is O(𝑛). So, the algorithm has
exponential running time and linear space complexity.
16 1. Classical Computation

1.2. Probabilistic algorithms


Quantum algorithms are inherently probabilistic; i.e., the output for a given input is
not uniquely determined but follows a probability distribution on the possible outputs.
This section discusses classical probabilistic algorithms. In many cases, they are much
more efficient than their deterministic counterparts. An example is the probabilistic
solution of the Deutsch-Jozsa problem in Section 5.3.1.

1.2.1. Definition of probabilistic algorithms. A probabilistic algorithm has


the same four components as a deterministic algorithm: the Input and Output state-
ment, the algorithm name followed by the sequence of input variables, and a sequence
of instructions that is ended by end. In addition, states, runs, and complexities of
probabilistic algorithms are defined analogously to their deterministic counterparts.
The differences between the two types of algorithms are now listed. For this, let 𝐴 be
a probabilistic algorithm.

(1) The probabilistic algorithm 𝐴 may call the subroutine coinToss. It returns 0 or 1,
1
both with probability 2 .
(2) The probabilistic algorithm 𝐴 may call other probabilistic algorithms subroutines
if they satisfy the following condition. Given a permitted input, they terminate
and return one of finitely many possible outputs according to a probability distri-
bution.
(3) The run of 𝐴 on input of some 𝑎 ∈ Input(𝐴) may depend on 𝑎 and the return
values of the probabilistic subroutines called during the run of the algorithm.
Therefore, in contrast to deterministic algorithms, this run may not be uniquely
determined by 𝑎.
(4) 𝐴 may not terminate, since termination may depend on certain return values of
some probabilistic subroutine that may never occur.
(5) Let 𝑎 ∈ Input(𝐴) and suppose that 𝐴 terminates on input of 𝑎 with output 𝑜.
Then 𝑜 may not be uniquely determined by 𝑎, but it may also depend on the return
values of the probabilistic subroutine calls during the run of 𝐴. Also, we may have
𝑜 ∈ Output(𝐴, 𝑎), 𝑜 = “Failure”, which indicates that the algorithm did not find
a correct output or 𝑜 has neither of these properties.
(6) Due to the special meaning of the return value “Failure”, it must never be a correct
output.

So an important difference between deterministic and probabilistic algorithms is


that the latter are not required to always return correct outputs. As we shall see, correct
outputs occur with a certain success probability. We will show in Proposition 1.3.5 that
the second condition in (2) follows from the property that the probabilistic subroutine
always terminates.
We present two examples of probabilistic algorithms that may be used as subrou-
tines in probabilistic algorithms.
1.2. Probabilistic algorithms 17

Example 1.2.1. On input of 𝑘 ∈ ℕ, Algorithm 1.2.2 returns a random bit string of


length 𝑘 with a uniform distribution. Also, on the same input, Algorithm 1.2.3 returns
a random integer 𝑎 with bit length at most 𝑘 with the uniform distribution.

Algorithm 1.2.2. Selecting a uniformly distributed random bit string of fixed length
Input: 𝑘 ∈ ℕ
Output: 𝑠 ∈ {0, 1}𝑘
1: randomString(𝑘)
2: for 𝑖 = 0 to 𝑘 − 1 do
3: 𝑠𝑖 ← coinToss
4: end for
5: return 𝑠 ⃗ = (𝑠0 , . . . , 𝑠𝑘−1 )
6: end

Algorithm 1.2.3. Selecting a uniformly distributed random positive integer of


bounded bitlength
Input: 𝑘 ∈ ℕ
Output: 𝑏 ∈ ℕ0 with bitLength(𝑏) ≤ 𝑘
1: randomInt(𝑘)
2: 𝑠 ⃗ ← randomString(𝑘)
3: 𝑏 ← stringToInt(𝑠)⃗
4: return 𝑏
5: end

We also use the following terminology. If a probabilistic algorithm 𝐴 returns an


output from Output(𝐴, 𝑎) for a specific input 𝑎 ∈ Input(𝐴), we refer to the correspond-
ing algorithm run as a “success”. Otherwise, it is considered a “failure”. Notably, if
the output of 𝐴 on input 𝑎 is “Failure”, it indicates that the algorithm did not find a
correct output. However, if the output is not “Failure”, it is not immediately evident
whether the result is correct or not, that is, whether the algorithm run was a success
or not. This must be checked by other means.
A probabilistic algorithm that, upon termination, always returns a correct result
or “Failure” is called “error-free”.
Example 1.2.4. We present an algorithm that implements the Fermat test to deter-
mine whether a positive integer is composite. Given an input 𝑎 ∈ ℕ>1 , the algorithm
randomly selects 𝑏 ∈ ℤ𝑎 with the uniform distribution. If the condition
(1.2.1) 1 < gcd(𝑎, 𝑏) < 𝑎 ∨ 𝑏𝑎−1 ≢ 1 mod 𝑎
holds, the algorithm returns 1; otherwise, it returns 0. Fermat’s Little Theorem (see
[Buc04, Theorem 2.11.1]) guarantees that condition (1.2.1) implies the compositeness
of 𝑎. However, it is essential to note that the converse may not be true, since 𝑎 could be
a Carmichael number. Carmichael numbers are composite numbers that satisfy 𝑏𝑎−1 ≡
1 mod 𝑎 for all 𝑏 ∈ ℤ∗𝑎 . For example, 561, 1105, and 1729 are the first three Carmichael
18 1. Classical Computation

numbers. Moreover, as shown in [AGP94], there are infinitely many Carmichael num-
bers. Since Carmichael numbers are composite, the Fermat test will return 0 for these
inputs, making the algorithm non-error-free.
Exercise 1.2.5. (1) Write pseudocode for the Fermat test described in Example 1.2.4.
(2) Find a composite number 𝑎 such that on input of 𝑎 the algorithm of Example 1.2.4
sometimes returns 0 and sometimes 1.

There are the following two types of probabilistic algorithms.


(1) Monte Carlo algorithms. They always terminate but may not always be successful.
(2) Las Vegas algorithms. They may not terminate but when they terminate, they are
successful.
Algorithms 1.2.2 and 1.2.3 are examples of Monte Carlo algorithms. We will see
in Proposition 1.3.5 that Monte Carlo algorithms are exactly the possible subroutines
of probabilistic algorithms; i.e., they terminate on every permitted input and return
one of finitely many possible outputs according to a probability distribution. Another
example of a Monte Carlo algorithm is the following.
Example 1.2.6. Algorithm 1.2.8 is an error-free Monte Carlo factoring algorithm that
is based on the fact that a composite integer 𝑎 ∈ ℕ has a proper divisor 𝑏 ∈ ℕ such that
(1.2.2) bitLength(𝑏) ≤ m(𝑎) = ⌈(bitLength 𝑎)/2⌉.
This is shown in Exercise 1.2.7. On input of 𝑎 ∈ ℤ>1 , Algorithm 1.2.8 computes the
integer 𝑏 represented by a uniformly distributed random bit string of length m(𝑎). The
algorithm returns 𝑏 if this number is a proper divisor of 𝑎. Then the algorithm run was
successful. Otherwise, it returns “Failure” which means that the algorithm did not find
a proper divisor of 𝑎. The algorithm always terminates since it tests only a single 𝑏 but
it may not always be successful.
Exercise 1.2.7. Show that every composite number 𝑎 ∈ ℕ has a proper divisor with
bitlength at most m(𝑎). Also, show that m(𝑎) can be computed in linear time.

Algorithm 1.2.8. Monte Carlo factoring algorithm


Input: 𝑎 ∈ ℕ>1
Output: A proper divisor 𝑏 ∈ ℕ of 𝑎
1: 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
2: 𝑏 ← randomInt(m(𝑎))
3: if 1 < 𝑏 < 𝑎 ∧ 𝑎 mod 𝑏 = 0 then
4: return 𝑏
5: end if
6: return “Failure”
7: end

Example 1.2.9. Algorithm 1.2.10 is a Las Vegas factoring algorithm which calls
𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 until a proper divisor of 𝑎 is found. This may take forever. But if the al-
gorithm terminates, then it is successful.
1.2. Probabilistic algorithms 19

Algorithm 1.2.10. Las Vegas factoring algorithm


Input: 𝑎 ∈ ℕ>1
Output: A proper divisor 𝑏 ∈ ℕ of 𝑎
1: 𝗅𝗏𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
2: repeat
3: 𝑏 ← 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
4: until 𝑏 ≠ “Failure”
5: return 𝑏
6: end

The approach used in Algorithm 1.2.10 can be extended to create a more general
version, allowing any error-free Monte Carlo algorithm 𝐴 to be transformed into a Las
Vegas algorithm. This transformation is achieved through Algorithm 1.2.11. When
given an input 𝑎 ∈ Input(𝐴), this algorithm repeatedly executes 𝐴(𝑎) until a successful
outcome is obtained. As this algorithm is akin to performing a Bernoulli experiment,
we refer to it as the Bernoulli algorithm associated with 𝐴.

Algorithm 1.2.11. Bernoulli algorithm associated with an error-free Monte Carlo al-
gorithm 𝐴
Input: 𝑎 ∈ Input(𝐴)
Output: 𝑏 ∈ Output(𝐴, 𝑎)
1: 𝖻𝖾𝗋𝗇𝗈𝗎𝗅𝗅𝗂𝐴 (𝑎)
2: 𝑏 ← “Failure”
3: while 𝑏 = “Failure” do
4: 𝑏 ← 𝐴(𝑎)
5: end while
6: return 𝑏
7: end

On the other hand, every Las Vegas algorithm can indeed be transformed into an
error-free Monte Carlo algorithm. This conversion entails monitoring the number of
calls made to the probabilistic subroutines while the algorithm runs. The algorithm
terminates if the Las Vegas algorithm produces a successful outcome or if the count of
subroutine calls exceeds a predetermined threshold value, which may vary depending
on the specific input of the algorithm. In the event of success, the algorithm returns the
output of the Las Vegas algorithm. However, if the threshold is surpassed, it returns
the result “Failure.”
Exercise 1.2.12. Change Algorithm 1.2.10 to an error-free Monte Carlo algorithm that,
on input of 𝑎 ∈ ℤ>1 , performs at most bitLength(𝑎) coin tosses.
Exercise 1.2.13. Change Algorithm 1.2.10 to an error-free Monte Carlo algorithm that,
on input of 𝑎 ∈ ℤ>1 , performs at most bitLength(𝑎) coin tosses.

1.2.2. Probabilistic decision algorithms. We now introduce probabilistic de-


cision algorithms. As deterministic decision algorithms, their purpose is to decide the
20 1. Classical Computation

membership of 𝑠 ⃗ ∈ {0, 1}∗ in a language 𝐿 ⊂ {0, 1}∗ . Such an algorithm always re-
turns 1 or 0. It satisfies Output(𝐴, 𝑠)⃗ = {1} for all 𝑠 ⃗ ∈ 𝐿 and Output(𝐴, 𝑠)⃗ = {0} for all
𝑠 ⃗ ∈ {0, 1}∗ ⧵ 𝐿. However, recall that runs of probabilistic decision algorithms do not
have to be successful. So, the algorithm may return 0 if 𝑠 ⃗ ∈ 𝐿 and 1 if 𝑠 ⃗ ∈ {0, 1}∗ ⧵ 𝐿.
There are three different types of probabilistic decision algorithms. To define them,
let 𝐴 be a probabilistic algorithm that decides a language 𝐿.
(1) 𝐴 is called true-biased if it never returns false positives. So, if on input of 𝑠 ⃗ ∈ {0, 1}∗
the algorithm returns 1, then 𝑠 ⃗ ∈ 𝐿.
(2) 𝐴 is called false-biased if it never returns false negatives. So, if at the input of
𝑠 ⃗ ∈ {0, 1}∗ the algorithm returns 0, then 𝑠 ⃗ ∉ 𝐿.
(3) If 𝐴 is true-biased or false-biased, then it is also called an algorithm with one-sided
error.
(4) 𝐴 is called an algorithm with two-sided error if it can return false positives and
false negatives.
Note that a false-biased algorithm can always be transformed into a true-biased
algorithm. We only need to replace the language to be decided by its complement in
{0, 1}∗ and change the outputs 0 and 1.
Example 1.2.14. Consider Algorithm 1.2.15 that decides whether or not the integer
that corresponds to a string in {0, 1}∗ is composite or not. On the input of 𝑠 ⃗ ∈ {0, 1}∗ , the
algorithm computes the corresponding integer 𝑎 and calls 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋. If this subroutine
returns a proper divisor of 𝑎, then the algorithm returns 1. Otherwise, it returns 0.
This is a true-biased Monte Carlo decision algorithm. If it returns 1, then 𝑠 ⃗ represents
a composite integer. But if it returns 0, then the integer represented by 𝑠 ⃗ may or may
not be composite.

Algorithm 1.2.15. True-biased Monte Carlo compositeness decision algorithm


Input: 𝑠 ⃗ ∈ {0, 1}∗
Output: 1 if stringToInt(𝑠)⃗ is composite and 0 otherwise
1: 𝗆𝖼𝖢𝗈𝗆𝗉𝗈𝗌𝗂𝗍𝖾(𝑠)⃗
2: 𝑎 ← stringToInt(𝑠)⃗
3: 𝑏 ← 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
4: if 𝑏 ∈ ℕ then
5: return 1
6: else
7: return 0
8: end if
9: end

Example 1.2.16. Algorithm 1.2.17 is a somewhat artificial example of a Monte Carlo


decision algorithm with two-sided error. On input of 𝑠 ⃗ ∈ {0, 1}∗ it computes 𝑎 =
stringToInt(𝑠).⃗ Then it tosses a coin, calls 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋, and returns 1 if the coin toss gives
1 or 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) returns a proper divisor of 𝑎. Otherwise, it returns 0. The algorithm
1.3. Analysis of probabilistic algorithms 21

returns a false negative answer if 𝑎 is composite and coinToss and 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 both return
0. Also, it returns a false positive answer if 𝑎 is a prime number and coinToss gives 1.

Algorithm 1.2.17. Monte Carlo compositeness decision algorithm with two-sided er-
ror
Input: 𝑠 ⃗ ∈ {0, 1}∗
Output: 1 if stringToInt(𝑠)⃗ is composite and 0 otherwise
1: 𝗆𝖼𝖢𝗈𝗆𝗉𝗈𝗌𝗂𝗍𝖾2(𝑎)
2: 𝑎 ← stringToInt(𝑠)⃗
3: 𝑐 ← coinToss
4: 𝑏 ← 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎)
5: if 𝑐 = 1 ∨ 𝑏 ∈ ℕ then
6: return 1
7: else
8: return 0
9: end if
10: end

1.3. Analysis of probabilistic algorithms


This section discusses the analysis of the time complexity and success probability of
probabilistic algorithms.

1.3.1. A discrete probability space. Our first goal is to define a discrete prob-
ability space that is the basis of the analyses. In this section, 𝐴 denotes a probabilistic
algorithm. We first introduce some notation.
Consider a run 𝑅 of 𝐴 with input 𝑎 ∈ Input(𝐴) and let 𝑙 ∈ ℕ0 ∪ {∞} be the num-
ber of probabilistic subroutine calls in 𝑅. For instance, in Algorithm 1.2.2 we have
Input(𝐴) = ℕ and for 𝑎 ∈ ℕ it holds that 𝑙 = 𝑎. In contrast, in Algorithm 1.2.10, the
number 𝑙 of probabilistic subroutine calls may be infinite.
For all 𝑘 ∈ ℕ, 𝑘 ≤ 𝑙, let 𝑎𝑘 be the input of the 𝑘th probabilistic subroutine call in 𝑅 if
this subroutine requires an input, let 𝑟 𝑘 be its output, and let 𝑝 𝑘 be the probability that
on input of 𝑎𝑘 the output 𝑟 𝑘 occurs. These quantities are well-defined since we require
that probabilistic algorithms may only use probabilistic subroutines that on any input
terminate and return one of finitely many possible outputs according to some proba-
bility distribution. For example, for the probabilistic subroutine coinToss there is no
1
input, the output is 0 or 1, and the probability of both outputs is 2 . We call 𝑟 ⃗ = (𝑟 𝑘 )𝑘≤𝑙
the random sequence of the run 𝑅. So the random sequence of a run of randomInt with
input 𝑎 ∈ ℕ is in {0, 1}𝑎 .
We denote the set of all random sequences of runs of 𝐴 with input 𝑎 by Rand(𝐴, 𝑎)
and the set of finite strings in Rand(𝐴, 𝑎) by FRand(𝐴, 𝑎). So for 𝐴 = randomInt
and 𝑎 ∈ ℕ we have Rand(𝐴, 𝑎) = FRand(𝐴, 𝑎) = {0, 1}𝑎 . We note that for any
𝑎 ∈ Input(𝐴), each 𝑟 ⃗ ∈ Rand(𝐴, 𝑎) is the random sequence of exactly one run of 𝐴. We
22 1. Classical Computation

call it the run of 𝐴 corresponding to 𝑟.⃗ This run terminates if and only if 𝑟 ⃗ ∈ FRand(𝐴, 𝑎)
in which case we write 𝐴(𝑎, 𝑟)⃗ for the return value of this run.
Finally, let 𝑘 ∈ ℕ0 , 𝑘 ≤ 𝑙, and let 𝑟 ⃗ = (𝑟0 , . . . , 𝑟 𝑘−1 ) be a prefix of a random sequence
of a run of 𝐴 with input 𝑎. Also, for 0 ≤ 𝑖 < 𝑘 denote by 𝑝 𝑖 the probability for the return
value 𝑟 𝑖 to occur. Then we set
𝑘−1
(1.3.1) Pr𝐴,𝑎 (𝑟)⃗ = ∏ 𝑝 𝑖 .
𝑖=0

This is the probability that 𝑟 ⃗ occurs as the prefix of the random sequence of a run of 𝐴
with input 𝑎. For instance, if 𝐴 = randomInt and 𝑎 ∈ ℕ, then for all 𝑘 ∈ ℕ0 with 𝑘 ≤ 𝑎
1
and all 𝑟 ⃗ ∈ {0, 1}𝑘 , we have Pr𝐴,𝑎 (𝑟)⃗ = 2𝑘 .
Exercise 1.3.1. Determine Rand(𝐴, 𝑎), FRand(𝐴, 𝑎), and Pr𝐴,𝑎 for 𝐴 = 𝗅𝗏𝖥𝖺𝖼𝗍𝗈𝗋 spec-
ified in Algorithm 1.2.10 and 𝑎 ∈ Input(𝐴) = ℕ>1 .

The next lemma allows the definition of the probability distribution that we are
looking for.
Lemma 1.3.2. Let 𝑎 ∈ Input(𝐴). The (possibly infinite) sum
(1.3.2) ∑ Pr(𝑟)⃗

𝑟∈FRand(𝐴,𝑎)

converges, its limit is in the interval [0, 1], and it is independent of the ordering of the terms
in the sum.

Proof. First, note the following. If the sum in (1.3.2) is convergent, then it is absolute
convergent since the terms in the sum are nonnegative. So Theorem C.1.4 implies that
its limit is independent of the ordering of the terms in the sum.
To prove the convergence of the sum, set
(1.3.3) 𝑡𝑘 = ∑ Pr𝐴,𝑎 (𝑟)⃗

𝑟∈FRand, |𝑟|⃗ ≤𝑘

for all 𝑘 ∈ ℕ0 . Then the sum in (1.3.2) is convergent if and only if the sequence (𝑡 𝑘 ) con-
verges. For 𝑘 ∈ ℕ0 let Rand𝑘 be the set of all prefixes of length at most 𝑘 of sequences
in Rand(𝐴, 𝑎). We will prove below that
(1.3.4) ∑ Pr𝐴,𝑎 (𝑟)⃗ = 1

𝑟∈Rand 𝑘

for all 𝑘 ∈ ℕ0 . This implies


(1.3.5) 𝑡𝑘 ≤ ∑ Pr𝐴,𝑎 (𝑟)⃗ = 1

𝑟∈Rand 𝑘

for all 𝑘 ∈ ℕ0 . Since the elements of the sequence (𝑡 𝑘 ) are nondecreasing this proves
the convergence of (𝑡 𝑘 ) and thus of the infinite sum (1.3.2).
We will now prove (1.3.4) by induction on 𝑘. Since Rand0 only contains the empty
sequence, (1.3.4) holds for 𝑘 = 0. For the inductive step, assume that 𝑘 ∈ ℕ0 and

that (1.3.4) holds for 𝑘. Denote by Rand𝑘 the set of all sequences of length at most 𝑘

in Rand(𝐴, 𝑎) and denote by Rand𝑘 the set of sequences of length 𝑘 that are proper
1.3. Analysis of probabilistic algorithms 23


prefixes of strings in Rand(𝐴, 𝑎). For 𝑟 ⃗ ∈ Rand𝑘 let 𝑚(𝑟)⃗ be the number of possible
outputs of the (𝑘 + 1)st call of a probabilistic subroutine when the sequence of return
values of the previous calls was 𝑟,⃗ let 𝑟 𝑖 (𝑟)⃗ be the 𝑖th of these outputs, and let 𝑝 𝑖 (𝑟)⃗ be its
probability. These quantities exist by the definition of probabilistic algorithms. Then
we have
′ ″
(1.3.6) Rand𝑘+1 = Rand𝑘 ∪{𝑟‖𝑟
⃗ 𝑖 (𝑟)⃗ ∶ 𝑟 ⃗ ∈ Rand𝑘 and 1 ≤ 𝑖 ≤ 𝑚(𝑟)}.

Also, we have
𝑚(𝑟)⃗
(1.3.7) ∑ 𝑝 𝑖 (𝑟)⃗ = 1
𝑖=1


for all 𝑟 ⃗ ∈ Rand𝑘 . This implies

𝑚(𝑟)⃗
∑ Pr𝐴,𝑎 (𝑟)⃗ = ∑ Pr𝐴,𝑎 (𝑟)⃗ + ∑ ∑ Pr𝐴,𝑎 (𝑟||𝑠
⃗ 𝑖 (𝑟))


𝑟∈Rand ′ ″ 𝑖=1
𝑘+1 ⃗
𝑟∈Rand𝑘 ⃗
𝑟∈Rand 𝑘

𝑚(𝑟)⃗
= ∑ Pr𝐴,𝑎 (𝑟)⃗ + ∑ Pr𝐴,𝑎 (𝑟)⃗ ∑ 𝑝 𝑖 (𝑟)⃗
′ ″ 𝑖=1

𝑟∈Rand𝑘 ⃗
𝑟∈Rand𝑘

(1.3.8) = ∑ Pr𝐴,𝑎 (𝑟)⃗ + ∑ Pr𝐴,𝑎 (𝑟)⃗


′ ″

𝑟∈Rand 𝑘 ⃗
𝑟∈Rand𝑘

= ∑ Pr𝐴,𝑎 (𝑟)⃗ = 1. □

𝑟∈Rand𝑘

Lemma 1.3.2 allows the definition of the probability distribution that we are look-
ing for. This is done in the following proposition.

Proposition 1.3.3. For every 𝑎 ∈ Input(𝐴) we define

(1.3.9) Pr𝐴,𝑎 (∞) = 1 − ∑ Pr𝐴,𝑎 (𝑟).




𝑟∈FRand(𝐴,𝑎)

Then (FRand(𝐴, 𝑎) ∪ {∞}, Pr𝐴,𝑎 ) is a discrete probability space. Also, if Pr𝐴,𝑎 (∞) = 0,
then (FRand(𝐴, 𝑎), Pr𝐴,𝑎 ) is a discrete probability space.

Exercise 1.3.4. Prove Proposition 1.3.3.

For 𝑎 ∈ Input(𝑎) and 𝑟 ⃗ ∈ FRand(𝐴, 𝑎), the value Pr𝐴,𝑎 (𝑟)⃗ is the probability that
𝑟 ⃗ is the random sequence of a run of 𝐴 with input 𝑎. Also, Pr𝐴,𝑎 (∞) is the probability
that on input of 𝑎, the algorithm 𝐴 does not terminate.
An important type of algorithms 𝐴 that satisfy Pr𝐴,𝑎 (∞) = 0 for all 𝑎 ∈ Input(𝑎)
is Monte Carlo algorithms. We now show that they are exactly the probabilistic algo-
rithms that, according to the specification in Section 1.2.1, can be called by probabilistic
algorithms as subroutines.
24 1. Classical Computation

Proposition 1.3.5. Let 𝐴 be a Monte Carlo algorithm and let 𝑎 ∈ Input(𝐴). Then the
following hold.
(1) The running time of 𝐴 on input of 𝑎 is bounded by some 𝑘 ∈ ℕ that may depend on
𝑎.
(2) On input of 𝑎, algorithm 𝐴 returns one of finitely many possible outputs according
to a probability distribution.

Proof. We first show that the length of all 𝑟 ⃗ ∈ FRand(𝐴, 𝑎) is bounded by some 𝑘 ∈ ℕ.
This shows that there are only finitely many possible runs of 𝐴 on input of 𝑎 which
implies the first assertion.
Assume that no such upper bound exists. We inductively construct prefixes 𝑟 𝑘⃗ =
(𝑟0 , . . . , 𝑟 𝑘 ), 𝑘 ∈ 𝑁0 , of an infinite sequence 𝑟 ⃗ = (𝑟0 , 𝑟1 , . . .) that are also prefixes of
arbitrarily long strings in Rand(𝐴, 𝑎); that is, for all 𝑘 ∈ ℕ0 and 𝑙 ∈ ℕ the sequence 𝑟 𝑘⃗
is a prefix of a sequence in Rand(𝐴, 𝑎) of length at least 𝑙. Then 𝑟 ⃗ is an infinite sequence
in Rand(𝐴, 𝑎) that contradicts the assumption that 𝐴 is a Monte Carlo algorithm.
For the base case, we set 𝑟0⃗ = (). This is a prefix of all strings in Rand(𝐴, 𝑎) that, by
our assumption, may be arbitrarily long. For the inductive step, assume that 𝑘 ∈ ℕ and
that we have constructed 𝑟 𝑘−1 ⃗ = (𝑟0 , . . . , 𝑟 𝑘−1 ). By the definition of probabilistic algo-
rithms, there are finitely many possibilities to select 𝑟 𝑘 in such a way that the sequence
(𝑟0 , . . . , 𝑟 𝑘 ) is the prefix of a string in Rand(𝐴, 𝑎). For at least one of these choices, this
sequence is a prefix of arbitrarily long strings in Rand(𝐴, 𝑎) because, by the induction
hypothesis, 𝑟 𝑘−1 ⃗ has this property. We select such an 𝑟 𝑘 and this concludes the induc-
tive construction and the proof of the first assertion.
Together with Proposition 1.3.3, the first assertion of the proposition implies the
second one. □

1.3.2. The success probability of Monte Carlo algorithms. In addition to


the running time, the probability of success is also crucial for the efficiency of a Monte
Carlo algorithm. We now define this probability.
Definition 1.3.6. Let 𝐴 be a Monte Carlo algorithm, let 𝑎 ∈ Input(𝐴), and denote by
Randsucc (𝐴, 𝑎) the set of all 𝑟 ⃗ ∈ Rand(𝐴, 𝑎) such that the run of 𝐴 associated with 𝑟 ⃗ is
successful; i.e., 𝐴(𝑎, 𝑟)⃗ ∈ Output(𝐴, 𝑎). Then we set
(1.3.10) 𝑝𝐴 (𝑎) = ∑ Pr𝐴,𝑎 (𝑟)⃗

𝑟∈Rand succ (𝐴,𝑎)

and call this quantity the success probability of 𝐴 on input of 𝑎. Also, the value
(1.3.11) 𝑞𝐴 (𝑎) = 1 − 𝑝𝐴 (𝑎)
is called the failure probability of 𝐴 on input of 𝑎.

Exercise 1.3.7. Prove that for all 𝑎 ∈ Input(𝐴), the sum in (1.3.10) is convergent and
its limit is independent of the ordering of the terms in the sum.
Example 1.3.8. Let 𝐴 = 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 specified in Algorithm 1.2.8 and let 𝑎 ∈ Input(𝐴) =
ℕ>1 . Then Randsucc (𝐴, 𝑎) is the set of all sequences (𝑏) where 𝑏 is a proper divisor of
1.3. Analysis of probabilistic algorithms 25

𝑎 of bitlength at most m(𝑎). By Exercise 1.2.7, this set is not empty. Therefore, the
success probability 𝑝𝐴 (𝑎) of 𝐴 on input of 𝑎 is at least 1/2m(𝑎) .

We can use the definition of the success probability to show that Bernoulli algo-
rithms terminate with probability 1.
Proposition 1.3.9. Let 𝐴 be a Bernoulli algorithm. Then we have Pr𝐴,𝑎 (∞) = 0 for all
𝑎 ∈ Input(𝐴).

Proof. Denote by 𝐴′ the error-free Monte Carlo algorithm used in 𝐴. Let 𝑎 ∈ Input(𝐴′ ).
Then FRand(𝐴, 𝑎) consists of all strings 𝑟 ⃗ = 𝑟1⃗ || ⋯ ||𝑟 𝑘⃗ where 𝑘 ∈ ℕ, 𝑟 𝑖⃗ ∈ Rand(𝐴′ , 𝑎)
for 1 ≤ 𝑖 ≤ 𝑘, 𝐴′ (𝑎, 𝑟 𝑖⃗ ) = “Failure” for 1 ≤ 𝑖 < 𝑘, and 𝐴′ (𝑎, 𝑟 𝑘⃗ ) ≠ “Failure”. So we
obtain

𝑝𝐴′ (𝑎)
(1.3.12) ∑ Pr𝐴,𝑎 (𝑠) = 𝑝𝐴′ (𝑎) ∑ (1 − 𝑝𝐴′ (𝑎))𝑘 = = 1.

𝑟∈FRand(𝐴,𝑎) 𝑘=0
𝑝𝐴′ (𝑎)

This implies the assertion. □

1.3.3. Expected running time. The probability space defined in Proposition


1.3.3 also allows the definition of the expected running time of random algorithms.
Definition 1.3.10. Let 𝐴 be a probabilistic algorithm and let 𝑎 ∈ Input(𝐴) such that
Pr𝐴,𝑎 (∞) = 0. Then the expected running time of 𝐴 on input of 𝑎 is defined as the
expectation of the random variable time𝐴,𝑎 that sends 𝑟 ⃗ ∈ FRand(𝐴, 𝑎) to the running
time of the algorithm run associated with 𝑟.⃗ It is denoted by eTime𝐴 (𝑎). So we have
(1.3.13) eTime𝐴 (𝑎) = ∑ time𝐴,𝑎 (𝑟)Pr
⃗ 𝐴,𝑎 (𝑟).


𝑟∈FRand(𝐴,𝑎)

Example 1.3.11. Let 𝐴 = 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 which is specified in Algorithm 1.2.8 and let 𝑎 ∈
Input(𝐴). Then FRand(𝐴, 𝑎) is the set of all one-element sequences (𝑏), where 𝑏 is
an integer that can be represented by a bit string of length m(𝑎). So | FRand(𝐴, 𝑎)| ≤
2m(𝑎) . Also, by Proposition 1.3.5 we have Pr𝐴,𝑎 (∞) = 0. So eTime𝐴 (𝑎) is defined. Since
2
each run of 𝐴 on input 𝑎 has running time O(size 𝑎), we have

2 1 2
(1.3.14) eTime𝐴 (𝑎) = O (size 𝑎 ∑ ) = O(size 𝑎).

𝑟∈FRand(𝐴,𝑎)
2m(𝑎)

So the expected running time is quadratic. However, the success probability of 𝐴 on


input of 𝑎 may be as small as 1/2m(𝑎) . As we will see in Section 1.3.4, this success
probability can be amplified by repeatedly calling 𝐴. But in order to obtain success
2
probability ≥ 3 , exponential expected running time is required.

The next proposition determines the expected running time of Bernoulli algorithms.
Proposition 1.3.12. Let 𝐴 be an error-free Monte Carlo algorithm, let 𝑎 ∈ Input(𝐴),
and let 𝑡 be an upper bound on the running time of 𝐴 with input of 𝑎. Then the expected
running time of 𝖻𝖾𝗋𝗇𝗈𝗎𝗅𝗅𝗂𝐴 (𝑎) specified in Algorithm 1.2.11 is O(𝑡/𝑝𝐴 (𝑎)).
26 1. Classical Computation

Proof. We use the fact that for all 𝑐 ∈ ℝ with 0 ≤ 𝑐 < 1 we have

𝑐
(1.3.15) ∑ 𝑘𝑐𝑘 = .
𝑖=0
(1 − 𝑐)2
So the expected number of calls of 𝐴 until 𝖻𝖾𝗋𝗇𝗈𝗎𝗅𝗅𝗂𝐴 (𝑎) is successful is

𝑝𝐴 (𝑎) 1
(1.3.16) 𝑝𝐴 (𝑎) ∑ 𝑘𝑞𝐴 (𝑎)𝑘 = 2
= .
𝑘=0
𝑝𝐴 (𝑎) 𝑝𝐴 (𝑎)
The statement about the expected running time is an immediate consequence of this
result. □
Example 1.3.13. Proposition 1.3.12 allows the analysis of 𝗅𝗏𝖥𝖺𝖼𝗍𝗈𝗋 specified in Algo-
rithm 1.2.10. Let 𝑛 ∈ ℕ and let 𝑎 ∈ ℕ>1 be an input of size 𝑛. It follows from Example
1.3.8 that the success probability of 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) is at least 1/2m(𝑎) ≥ 1/2𝑛/2+1 . Also,
the worst-case running time of 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) is O(𝑛2 ). It therefore follows from Proposi-
tion 1.3.12 that the expected running time of 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) is O(𝑛2 2𝑛/2 ). So the expected
running time is exponential which shows that this probabilistic algorithm has no ad-
vantage over the deterministic Algorithm 1.1.21.

1.3.4. Amplifying success probabilities. In Example 1.3.8, we have seen that


the success probability of 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 specified in Algorithm 1.2.8 with input 𝑎 ∈ ℕ>1 is at
least 1/2m(𝑎) . We now explain how this success probability and the success probability
of every error-free Monte Carlo algorithm 𝐴 can be amplified by repeatedly calling it
with the same input. Algorithm 1.3.14 implements this idea.

Algorithm 1.3.14. Repeated application of an error-free Monte Carlo algorithm


Input: 𝑎 ∈ Input(𝐴) for an error-free Monte Carlo algorithm 𝐴 used as a subroutine,
𝑘∈ℕ
Output: 𝑏 ∈ Output(𝐴, 𝑎)
1: 𝗋𝖾𝗉𝖾𝖺𝗍𝐴 (𝑎, 𝑘)
2: for 𝑖 = 1 to 𝑘 do
3: 𝑏 ← 𝐴(𝑎)
4: if 𝑏 ≠ “Failure” then
5: return 𝑏
6: end if
7: end for
8: return “Failure”
9: end

Definition 1.3.15. Let 𝑎 ∈ Input(𝐴). We denote the success probability of 𝗋𝖾𝗉𝖾𝖺𝗍𝐴 (𝑎, 𝑘)
by 𝑝𝐴 (𝑎, 𝑘) and the failure probability of this call by 𝑞𝐴 (𝑎, 𝑘) = 1 − 𝑝𝐴 (𝑎, 𝑘).

The next proposition shows that 𝑞𝐴 (𝑎, 𝑘) decreases exponentially in 𝑘.


Proposition 1.3.16. Let 𝑘 ∈ ℕ, and let 𝑎 ∈ Input(𝐴) with 𝑝𝐴 (𝑎) < 1. Then we have the
following:
(1.3.17) 𝑒−𝑘𝑝𝐴 (𝑎)/𝑞𝐴 (𝑎) ≤ 𝑞𝐴 (𝑎, 𝑘) ≤ 𝑒−𝑘𝑝𝐴 (𝑎) .
1.3. Analysis of probabilistic algorithms 27

Proof. Write 𝑝 = 𝑝𝐴 (𝑎) and 𝑞 = 𝑞𝐴 (𝑎) = 1 − 𝑝. Then we have


(1.3.18) 𝑞𝐴 (𝑎, 𝑘) = 𝑞𝑘 .
Since we assume that 𝑞 > 0, it follows from [Abr72, (4.1.33) and (4.1.36)] that
1
(1.3.19) 1 − ≤ log 𝑞 ≤ 𝑞 − 1.
𝑞
This implies
(1.3.20) 𝑘 log 𝑞 ≤ 𝑘(𝑞 − 1) = −𝑘𝑝
and
1 𝑞−1 𝑝
(1.3.21) 𝑘 log 𝑞 ≥ 𝑘(1 − ) = 𝑘 = −𝑘 .
𝑞 𝑞 𝑞
So (1.3.20) and (1.3.21) imply
(1.3.22) 𝑒−𝑘𝑝/𝑞 ≤ 𝑞𝑘 ≤ 𝑒−𝑘𝑝
as asserted. □

The next corollary shows how to choose 𝑘 in order to obtain a desired success prob-
ability. It also gives a lower bound for 𝑘 that corresponds to a given success probability.
Corollary 1.3.17. Let 𝑎 ∈ Input(𝐴) with 𝑝𝐴 (𝑎) > 0 and let 𝜀 ∈ ℝ with 0 < 𝜀 ≤ 1.
(1) If 𝑘 ≥ log(1/𝜀)/𝑝𝐴 (𝑎), then 𝑝𝐴 (𝑎, 𝑘) ≥ 1 − 𝜀.
(2) If 𝑝𝐴 (𝑎, 𝑘) ≥ 1 − 𝜀, then 𝑘 ≥ log(1/𝜀)𝑞𝐴 (𝑎)/𝑝𝐴 (𝑎).
Exercise 1.3.18. Prove Corollary 1.3.17.
Example 1.3.19. Consider 𝐴 = 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋 as specified in Algorithm 1.2.8. In Example
1.3.8, we have seen that 𝑝𝐴 (𝑎) ≥ 1/2m(𝑎) > 0 for all 𝑎 ∈ ℤ>1 . So 𝗋𝖾𝗉𝖾𝖺𝗍𝐴 can be used
to amplify this probability. For example, if we choose 𝜀 = 1/3 and 𝑘 ≥ (log 3)2m(𝑎) ≥
2
log(1/𝜀)/𝑝𝐴 (𝑎), then Corollary 1.3.17 implies 𝑝𝐴 (𝑎, 𝑘) ≥ 3 . Since
m(𝑎) ≥ bitLength(𝑎)/2,
this number 𝑘 of calls to 𝐴 is exponential in size 𝑎. Therefore, again, this algorithm
does not give an asymptotic advantage over the deterministic Algorithm 1.1.21.

We can also amplify the success probability of decision algorithms with errors.
Consider a true-biased decision algorithm 𝐴 that decides a language 𝐿. We can mod-
ify this algorithm to make it an error-free Monte Carlo algorithm. For this, we set
Output(𝐴, 𝑠)⃗ = {1} for all 𝑠 ⃗ ∈ 𝐿, Output(𝐴, 𝑠)⃗ = ∅ for all 𝑠 ⃗ ∈ {0, 1}∗ ⧵ 𝐿 and we re-
place the return value 0 by “Failure”. So, the success probability of 𝐴 can be amplified
using Algorithm 1.3.14. Analogously, the success probability of false-biased decision
algorithms can be amplified.
Next, we consider a Monte Carlo decision algorithm 𝐴 with two-sided error that
decides a language 𝐿. Such an algorithm never gives certainty about whether an input
𝑠 ⃗ ∈ {0, 1}∗ belongs to 𝐿 or not. However, the probability of success can be increased
by using a majority vote. To do this, we run the algorithm 𝑘 times with input 𝑠 ⃗ for
some 𝑘 ∈ ℕ and count the number of positive responses 1 and the number of negative
28 1. Classical Computation

answers 0 and return 1 or 0 depending on which answer has the majority. This is done
in Algorithm 1.3.20.

Algorithm 1.3.20. Success probability amplifier for a Monte Carlo decision algorithm
𝐴 with two-sided error
Input: 𝑠 ⃗ ∈ {0, 1}∗ , 𝑘 ∈ ℕ
Output: 1 if 𝑠 ⃗ ∈ 𝐿 and 0 if 𝑠 ⃗ ∈ {0, 1}∗ ⧵ 𝐿 where 𝐿 is the language decided by the Monte
Carlo decision algorithm 𝐴 that is used as a subroutine
1: 𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 (𝑠,⃗ 𝑘)
2: 𝑙=0
3: for 𝑖 = 1 to 𝑘 do
4: 𝑙 ← 𝑙 + 𝐴(𝑠)⃗
5: end for
6: if 𝑙 > 𝑘/2 then
7: return 1
8: else
9: return 0
10: end if
11: end

We will show that under certain conditions, Algorithm 1.3.20 amplifies the success
probability of decision algorithms with two-sided error. For this, we need the following
definition.
Definition 1.3.21. Assume that a Monte Carlo algorithm 𝐴 decides a language 𝐿, let
𝑠 ⃗ ∈ 𝐿, and let 𝑏 ∈ {0, 1}. Then we write Pr(𝐴(𝑠) = 𝑏) for the probability that on input
of 𝑠 ⃗ the algorithm 𝐴 returns 𝑏.
Proposition 1.3.22. Let 𝐴 be a Monte Carlo algorithm that decides a language 𝐿, let
1
𝑠 ⃗ ∈ 𝐿, and let 𝜀 ∈ ℝ>0 such that Pr(𝐴(𝑠)⃗ = 1) ≥ 2 + 𝜀. Then for all 𝑘 ∈ ℕ we have
2
(1.3.23) Pr(𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 (𝑠,⃗ 𝑘) = 1) > 1 − 𝑒−2𝑘𝜀 .

Proof. Let 𝑘 ∈ ℕ. We prove the assertion by showing that


2
(1.3.24) 𝑞 = Pr(𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 (𝑠,⃗ 𝑘) = 0) < 𝑒−2𝑘𝜀 .
Consider a run of 𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 with input 𝑠,⃗ 𝑘. Denote by 𝑟 ⃗ ∈ {0, 1}𝑘 the random
output sequence corresponding to this run. Then 𝐴 returns 0 if and only if at most 𝑘/2
entries in 𝑟 ⃗ are 1. The probability for such an 𝑟 ⃗ to occur is at most
𝑘 𝑘 𝑘
1 2 1 2 (1 − 4𝜀2 ) 2
(1.3.25) ( − 𝜀) ( + 𝜀) = .
2 2 2𝑘
Since the number of such sequences 𝑟 ⃗ is at most 2𝑘 and because by [Abr72, (4.2.30)]
we have 1 − 𝑥 < 𝑒−𝑥 for all 𝑥 > −1, it follows that
𝑘 2
(1.3.26) 𝑞 ≤ (1 − 4𝜀2 ) 2 < 𝑒−2𝑘𝜀 .
This concludes the proof. □
1.4. Complexity theory 29

Example 1.3.23. Let 𝐴 = 𝗆𝖼𝖢𝗈𝗆𝗉𝗈𝗌𝗂𝗍𝖾2 specified in Algorithm 1.2.17 which is the


Monte Carlo compositeness test with two-sided error and let 𝑠 ⃗ ∈ {0, 1}∗ such that
𝑎 = stringToInt(𝑠)⃗ is composite. The call 𝐴(𝑠)⃗ returns 1 if the first coin toss gives
1
1 which happens with probability 2 or 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) returns a proper divisor of 𝑎 =
1
stringToInt(𝑠)⃗ which occurs with probability ≥ 2𝑚
where 𝑚 = m(𝑎). Therefore, we
have
1 1𝑚 1 1
(1.3.27) Pr(𝐴(𝑠)⃗ = 1) ≥ 1 − (1 − ) = + 𝑚+1 .
2 2 2 2
1
So in Proposition 1.3.22 we can set 𝜀 = 2𝑚+1
and obtain
𝑘
2 −
(1.3.28) Pr(𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 (𝑠,⃗ 𝑘) = 1) ≥ 1 − 𝑒−2𝑘𝜀 = 1 − 𝑒 22𝑚+1

for all 𝑘 ∈ ℕ.

Exercise 1.3.24. Use the result in Example 1.4.7 to determine 𝑘 such that
2
Pr(𝗆𝖺𝗃𝗈𝗋𝗂𝗍𝗒𝖵𝗈𝗍𝖾𝐴 (𝑠,⃗ 𝑘) = 1) ≥ .
3

1.4. Complexity theory


Classical complexity theory allows us to assess the efficiency of algorithms and the
difficulty of solving computational problems. In this section, we present important
notions and results of this theory. They are required as a basis for quantum complexity
theory.

1.4.1. Computational problems. An important question in complexity theory


is: How efficiently can a computational problem be solved? In cryptography, for ex-
ample, it is crucial to know how quickly an encryption system can be broken. That is
why we start by defining computational problems

Definition 1.4.1. A computational problem is a triplet CP = (𝐼, 𝑂, 𝑅) where 𝐼 is a


subset of the Cartesian product of finitely many data types where 𝐼 and 𝑂 are subsets
of Cartesian products of finitely many data types.
Also, 𝑅 ⊂ 𝐼 × 𝑂 such that for all 𝑎 ∈ 𝐼 there is 𝑏 ∈ 𝑂 with (𝑎, 𝑏) ∈ 𝑅.

Definition 1.4.2. Let CP = (𝐼, 𝑂, 𝑅) be a computational problem.


(1) The elements of 𝐼 are called the instances of CP.
(2) If (𝑎, 𝑏) ∈ 𝑅, then 𝑏 is called a solution of the problem instance 𝑎.

Example 1.4.3. By the square root problem we mean the triplet (ℕ, ℤ, 𝑅) where 𝑅 =
{(𝑎, 𝑏) ∈ ℕ × ℤ ∶ 𝑏2 = 𝑎 or 𝑏 = 0 if 𝑎 is not a square in ℕ}. An instance of the square
root problem is 4. It has the two solutions −2 and 2. Another instance is 2. It has the
solution 0 that indicates that 2 is not a square in ℕ. We can also define this problem
differently by only allowing problem instances that are squares.
30 1. Classical Computation

We define what it means that an algorithm solves a computational problem.


Definition 1.4.4. Let CP = (𝐼, 𝑂, 𝑅) be a computational problem.
(1) We say that a deterministic algorithm 𝐴 solves CP if 𝐼 ⊂ Input(𝐴) and on input of
a problem instance 𝑎 ∈ 𝐼 the algorithm returns a solution of 𝑎.
(2) We say that a Monte Carlo algorithm 𝐴 solves CP if 𝐼 ⊂ Input(𝐴) and on input of
𝑎 ∈ 𝐼 a successful run of 𝐴 returns a solution of 𝑎.
(3) We say that a Las Vegas algorithm solves CP if 𝐼 ⊂ Input(𝐴) and on input of 𝑎 ∈ 𝐼
the algorithm either terminates and returns a solution of 𝑎 or does not terminate.
Example 1.4.5. The gcd problem is the triplet CP = (ℤ2 , ℕ0 , 𝑅) where 𝑅 = {(𝑎, 𝑏, 𝑐) ∈
ℤ3 ∶ 𝑐 = gcd(𝑎, 𝑏)}. An instance of this problem is (100, 35). The unique solution of
this instance is 5. Also, the Euclidean algorithm solves this problem.
Exercise 1.4.6. Find a deterministic algorithm that solves the square root problem
from Example 1.4.3 in polynomial time.
Example 1.4.7. By the integer factorization problem we mean the triplet (𝐶, ℕ, 𝑅) where
𝐶 is the set of all positive composite integers and
𝑅 = {(𝑎, 𝑏) ∈ 𝐶 × ℕ ∶ 𝑏 is a proper divisor of 𝑎}.
Algorithms 1.1.21, 1.2.8, and 1.2.10 are deterministic, Monte Carlo, and Las Vegas
algorithms that solve the integer factorization problem.

1.4.2. Complexity of computational problems. We define the complexity of


computational problems.
Definition 1.4.8. Let CP be a computational problem and let 𝑓 ∶ ℕ → ℝ>0 be a
function
(1) We say that CP can be solved in (deterministic) time O(𝑓) or has time complexity
O(𝑓) if there is a deterministic algorithm that solves CP and has running time
O(𝑓).
(2) We say that CP can be solved in (deterministic) linear, quasilinear, quadratic, cu-
bic, polynomial, subexponential, or exponential time or has this time complexity
if there is a deterministic algorithm that solves CP and has the respective time
complexity.
(3) The corresponding space complexities are defined analogously.

Example 1.4.9. As seen in Example 1.1.29, the gcd problem from Example 1.4.5 can
be solved in deterministic time O(𝑛3 ). As noted in this example, the gcd problem can
2
even be solved in deterministic time O(𝑛2 ) or O(𝑛 log 𝑛) and linear space. Thus this
problem can be solved in polynomial time or, more precisely, cubic, quadratic, or even
quasilinear time.
Example 1.4.10. As seen in Example 1.1.31, the integer factorization problem can be
solved in deterministic exponential time and linear space.

Now we introduce the corresponding probabilistic complexity notions.


1.4. Complexity theory 31

Definition 1.4.11. Let CP be a computational problem and let 𝑓 ∶ ℕ → ℝ>0 be a


function.
(1) We say that CP can be solved in probabilistic time O(𝑓) if there is a Monte Carlo
2
algorithm that solves CP and has running time O(𝑓) and success probability ≥ 3 .
(2) We say that CP can be solved in probabilistic linear, quasilinear, quadratic, cu-
bic, polynomial, subexponential, or exponential time if there is a Monte Carlo algo-
rithm with the respective running time that solves CP and has success probability
2
≥ 3.
2
Exercise 1.4.12 shows that the value 3
in Definition 1.4.11 may be replaced by any
1
real number in ] 2 , 1] without changing the complexity of the computational problem.
Exercise 1.4.12. Let CP be a computational problem, let 𝑓 ∶ ℕ → ℝ>0 be a function,
1
and let 𝑝 ∈ ] 2 , 1]. Use Proposition 1.3.22 to show that CP can be solved in probabilistic
time O(𝑓) if and only if there is a Monte Carlo algorithm that solves CP in time O(𝑓)
and has success probability ≥ 𝑝.
Example 1.4.13. It follows from Example 1.3.19 that Algorithm 1.3.14 with subroutine
𝐴 = 𝗆𝖼𝖥𝖺𝖼𝗍𝗈𝗋(𝑎) and 𝑘 = ⌈(log 3)2m(𝑎) ⌉ is an error-free Monte Carlo algorithm that
solves the integer factorization problem in probabilistic exponential time. We note
that this problem can even be solved in probabilistic subexponential time (see [LP92],
[BLP93]) but no classical polynomial time algorithm for this problem is known.

1.4.3. Complexity classes. In this section, we delve into the definition of com-
plexity classes, which serve to group languages that satisfy specific complexity con-
ditions. The foundation of this concept was laid in the early 1970s. Over the years,
complexity theory has witnessed the introduction of numerous complexity classes, and
extensive research has been conducted to study their interrelationships. For the scope
of this discussion, we will focus on a select few complexity classes that hold relevance
to our context.
We begin with the definition of the most basic complexity classes.
Definition 1.4.14. Let 𝑓 ∶ ℕ → ℝ>0 be a function.
(1) The complexity class DTIME(𝑓) is the set of all languages 𝐿 for which there is a
deterministic algorithm that decides 𝐿 and has time complexity O(𝑓).
(2) The complexity class DSPACE(𝑓) is the set of all languages 𝐿 for which there is a
deterministic algorithm that decides 𝐿 and has space complexity O(𝑓).

We also define the following more concrete complexity classes.


Definition 1.4.15. (1) The complexity class P is the set of all languages 𝐿 for which
there is a deterministic polynomial time algorithm which decides 𝐿.
(2) The complexity class PSPACE is the set of all languages 𝐿 for which there is a
deterministic polynomial space algorithm which decides 𝐿.
(3) The complexity class EXPTIME is the set of all languages 𝐿 for which there is a
deterministic exponential time algorithm which decides 𝐿.
32 1. Classical Computation

Exercise 1.4.16. Consider the language 𝐿 of all strings that correspond to squares in
ℕ. Show that 𝐿 is in P.
Example 1.4.17. As shown in 2002 by Manindra Agrawal, Neeraj Kayal, and Nitin
Saxena [AKS04], the language 𝐿 of all bit strings that correspond to composite integers
is in P. Therefore, it can be decided in polynomial time whether a positive integer is
a prime number composite. However, if the algorithm of Agrawal, Kayal, and Saxena
finds that a positive integer is composite, it does not give a proper divisor of this number.
Finding such a divisor appears to be a much harder problem (see Example 1.4.13).

We also define two probabilistic complexity classes.


Definition 1.4.18. (1) The complexity class PP is the set of all languages 𝐿 for which
there is a polynomial time Monte Carlo algorithm 𝐴 which decides 𝐿 and satisfies
1 1
Pr(𝐴(𝑠) = 1) > 2 for all 𝑠 ∈ 𝐿 and Pr(𝐴(𝑠) = 0) > 2 for all 𝑠 ∈ {0, 1}∗ ⧵ 𝐿.
(2) The complexity class BPP is the set of all languages 𝐿 for which there is a polyno-
2
mial time Monte Carlo algorithm 𝐴 which decides 𝐿 and satisfies Pr(𝐴(𝑠) = 1) ≥ 3
2
for all 𝑠 ∈ 𝐿 and Pr(𝐴(𝑠) = 0) ≥ 3
for all 𝑠 ∈ {0, 1}∗ ⧵ 𝐿.
2
We note that the constant 3
in Definition 1.4.18 can be replaced by any other con-
1
stant 𝑝 with < 𝑝 ≤ 11. This flexibility is established by Proposition 1.3.22, which
2
asserts that when commencing with a success probability exceeding 1/2, Algorithm
1.3.20 can be employed to obtain a success probability arbitrarily close to 1.
Finally, we introduce the complexity class NP. We begin with a motivating exam-
ple.
Example 1.4.19. In 1742, the German mathematician Christian Goldbach wrote a
letter to Leonard Euler in which he proposed the conjecture that every even integer
≥ 4 is the sum of two odd prime numbers. For instance, we have 4 = 1 + 3, 6 = 3 + 3,
and 8 = 3 + 5. To this day, this conjecture has neither been proven nor disproved by
a counterexample. In order to find such a counterexample, one would have to find an
even positive integer which is not the sum of two primes.
To frame this problem as a decision problem, we identify positive integers with
their binary expansions and consider the Goldbach language 𝐿 comprising all integers
which are the sum of two odd prime numbers. So the Goldbach conjecture states that
𝐿 is the set of all even integers ≥ 4. A proof of the Goldbach conjecture would imply
that 𝐿 ∈ P since deciding membership of 𝐿 would mean deciding whether an integer is
≥ 4 is even. But 𝐿 is not known to be in P. However, we can verify in polynomial time
that 𝑎 ∈ 𝐿 if we are given a prime number 𝑝 such that 𝑎−𝑝 is also a prime number. For
this, we apply the polynomial time primality test to 𝑝 and 𝑎 − 𝑝 that was mentioned in
Example 1.4.17. The prime number 𝑝 is called a certificate for the Goldbach language
membership of 𝑎.

There are many other languages 𝐿 that have a property analogous to that of the
Goldbach language presented in Example 1.4.19. Abstractly speaking, this property is
the following. For 𝑠 ⃗ ∈ {0, 1}∗ it may be hard to decide whether 𝑠 ⃗ ∈ 𝐿. But for each 𝑠 ⃗ ∈ 𝐿
there is a certificate 𝑡 which allows us to verify in polynomial time in |𝑠|⃗ that 𝑠 ⃗ ∈ 𝐿. For
1.4. Complexity theory 33

the Goldbach language, the certificate is the prime number 𝑝 such that 𝑎 − 𝑝 is a prime
number. The set of all languages with this property is denoted by NP, which stands for
nondeterministic polynomial time. This name comes from another NP modeling that
we do not discuss here (see [LP98]). Here is a formal definition of NP.

Definition 1.4.20. (1) The complexity class NP is the set of all languages 𝐿 with the
following properties.
(a) There is a deterministic polynomial time algorithm 𝐴 with Input(𝐴) = {0, 1}∗
× {0, 1}∗ such that 𝐴(𝑠,⃗ 𝑡)⃗ = 1 implies 𝑠 ⃗ ∈ 𝐿 for all 𝑠,⃗ 𝑡 ⃗ ∈ Σ∗ .
(b) There is 𝑐 ∈ ℕ that may depend on 𝐿 so that for all 𝑠 ⃗ ∈ 𝐿 there is 𝑡 ⃗ ∈ {0, 1}∗
with |𝑡|⃗ ≤ |𝑠|⃗ 𝑐 and 𝐴(𝑠,⃗ 𝑡)⃗ = 1.
If 𝑠 ⃗ ∈ 𝐿 and 𝑡 ⃗ ∈ {0, 1}∗ such that 𝐴(𝑠,⃗ 𝑡)⃗ = 1, then 𝑡 ⃗ is called a certificate for the
membership of 𝑠 ⃗ in 𝐿.
(2) The complexity class Co-NP is the set of all languages 𝐿 such that {0, 1}∗ ⧵ 𝐿 ∈ NP.

One of the big open research problems in computer science is finding out whether
P is equal to NP. It is one of the seven Millennium Prize Problems. They are well-
known mathematical problems that were selected by the Clay Mathematics Institute
in the year 2000. The Clay Institute has pledged a US$1 million prize for the correct
solution to any of the problems.
The complexity theory that we have explained so far only refers to solving language
decision problems but not to more general computational problems such as finding
proper divisors of composite integers. But, as illustrated in the next example, there is
a close connection between these two problem classes.

Example 1.4.21. Consider the set

(1.4.1) 𝐿 = {(𝑎, 𝑐) ∈ ℕ2 ∶ 𝑐 ≤ 𝑎, 𝑎 has a proper divisor ≤ 𝑐}.

By identifying the elements (𝑎, 𝑐) of 𝐿 with a linear length string representation in


size 𝑎, we consider 𝐿 as a language, that is, a subset of {0, 1}∗ . We will now show that 𝐿
is in P if and only if the integer factorization problem from Example 1.4.7 can be solved
in polynomial time.
Suppose that 𝐴 is a polynomial time algorithm that on input of a composite 𝑎 ∈ ℕ
finds a proper divisor of 𝑎. Then the following algorithm 𝐴′ decides 𝐿 in polynomial
time. On input of 𝑎 ∈ ℕ, the algorithm checks whether 𝑎 = 1 or 𝑎 is a prime number.
In both cases, 𝐴′ returns 0. As explained in Example 1.4.17, this test can be carried out
in polynomial time in size 𝑎. If 𝑎 is neither 1 nor a prime number, 𝐴′ invokes 𝐴 and
finds a proper divisor 𝑏 ∈ ℕ of 𝑎. If 𝑏 ≤ 𝑐, then 𝐴′ returns 1. Otherwise, this procedure
is applied to 𝑏 and 𝑎/𝑏 and so on until a sufficiently small divisor is found or until it is
clear that all prime divisors of the input are greater than 𝑐. Exercise 1.4.22 shows that
this algorithm has polynomial running time.
Conversely, let 𝐴 be an algorithm that decides 𝐿 in polynomial time. We present
a polynomial time algorithm 𝐴′ that uses 𝐴 as a subroutine and finds a proper divisor
of a composite integer 𝑎 ∈ ℕ. It uses two integers 𝑙, 𝑢 ∈ ℕ with 1 ≤ 𝑢 ≤ 𝑣 ≤ 𝑎.
They define an interval [𝑢, 𝑣] such that inside this interval there is a proper divisor
Random documents with unrelated
content Scribd suggests to you:
CHAPTER II.

ORGANIC ACT.
AN ACT TO PROVIDE A TEMPORARY GOVERNMENT FOR THE
TERRITORY OF COLORADO.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That all that part
of the territory of the United States included within the following
limits, viz: commencing on the thirty-seventh parallel of north
latitude, where the twenty-fifth meridian of longitude west from
Washington crosses the same; thence north on said meridian to the
forty-first parallel of north latitude; thence along said parallel west to
the thirty-second meridian of longitude west from Washington;
thence south on said meridian to the northern line of New Mexico;
thence along the thirty-seventh parallel of north latitude to the place
of beginning; be and the same is hereby erected into a temporary
government by the name of the Territory of Colorado: Provided, That
nothing in this act contained shall be construed to impair the rights
of person or property now pertaining to the Indians in said Territory,
so long as such rights shall remain unextinguished by treaty
between the United States and such Indians, or to include any
territory which, by treaty with any Indian tribe, is not, without the
consent of said tribe, to be included within the territorial limits or
jurisdiction of any State or Territory; but all such territory shall be
excepted out of the boundaries, and constitute no part of the
territory of Colorado, until said tribe shall signify their assent to the
President of the United States to be included within the said
Territory, or to affect the authority of the government of the United
States to make any regulations respecting such Indians, their lands,
property, or other rights, by treaty, law, or otherwise, which it would
have been competent for the government to make, if this act had
never passed: Provided further, That nothing in this act contained
shall be construed to inhibit the government of the United States
from dividing said Territory into two or more territories, in such
manner and at such times as Congress shall deem convenient and
proper, or from attaching any portion thereof to any other Territory
or State.

Sec. 2. And be it further enacted, That the executive power and


authority in and over said Territory of Colorado shall be vested in a
Governor, who shall hold his office four years, and until his successor
shall be appointed and qualified, unless sooner removed by the
President of the United States. The Governor shall reside within said
Territory, shall be Commander-in-Chief of the militia thereof, shall
perform the duties and receive the emoluments of Superintendent of
Indian Affairs, and shall approve all laws passed by the Legislative
Assembly before they shall take effect; he may grant pardons for
offenses against the laws of said Territory, and reprieves for offenses
against the laws of the United States, until the decision of the
President can be made known thereon; he shall commission all
officers who shall be appointed to office under the laws of said
Territory, and shall take care that the laws be faithfully executed.

Sec. 3. And be it further enacted, That there shall be a Secretary of


said Territory, who shall reside therein, and hold his office for four
years, unless sooner removed by the President of the United States;
he shall record and preserve all the laws and proceedings of the
Legislative Assembly hereinafter constituted, and all the acts and
proceedings of the Governor, in his executive department; he shall
transmit one copy of the laws and one copy of the executive
proceedings on or before the first day of December in each year, to
the President of the United States, and, at the same time, two
copies of the laws to the Speaker of the House of Representatives
and the President of the Senate for the use of Congress. And in case
of the death, removal, or resignation, or other necessary absence of
the Governor from the Territory, the Secretary shall have, and is
hereby authorized and required to execute and perform, all the
powers and duties of the Governor during such vacancy or necessary
absence, or until another Governor shall be duly appointed to fill
such vacancy.

Sec. 4. And be it further enacted, That the legislative power and


authority of said Territory shall be vested in the Governor and a
Legislative Assembly. The Legislative Assembly shall consist of a
Council and House of Representatives. The Council shall consist of
nine members, which may be increased to thirteen, having the
qualifications of voters as hereinafter prescribed, whose term of
service shall continue two years. The House of Representatives shall
consist of thirteen members, which may be increased to twenty-six,
possessing the same qualifications as prescribed for members of the
Council, and whose term of service shall continue one year. An
apportionment shall be made, as nearly equally as practicable,
among the several counties or districts for the election of the Council
and House of Representatives, giving to each section of the Territory
representation in the ratio of its population (Indians excepted) as
nearly as may be; and the members of the Council and House of
Representatives shall reside in, and be inhabitants of, the district for
which they may be elected respectively. Previous to the first election,
the Governor shall cause a census or enumeration of the inhabitants
of the several counties and districts of the Territory to be taken; and
the first election shall be held at such time and places, and be
conducted in such a manner as the Governor may direct; and he
shall, at the same time, declare the number of the members of the
Council and House of Representatives to which each of the counties
or districts shall be entitled under this act. The number of persons
authorized to be elected, having the highest number of votes in each
of said Council districts for members of the Council shall be declared
by the Governor to be duly elected to the Council; and the person or
persons authorized to be elected having the greatest number of
votes for the House of Representatives, equal to the number to
which each county or district shall be entitled, shall be declared by
the Governor to be elected members of the House of
Representatives: Provided, That in case of a tie between two or
more persons voted for, the Governor shall order a new election, to
supply the vacancy made by such tie. And the persons thus elected
to the Legislative Assembly shall meet at such place and on such day
as the Governor shall appoint; but thereafter the time, place, and
manner of holding and conducting all elections by the people, and
the apportioning and representation in the several counties or
districts to the Council and House of Representatives, according to
the population, shall be prescribed by law, as well as the day of the
commencement of the regular session of the Legislative Assembly;
Provided, That no session shall exceed the term of forty days, except
the first, which may be extended to sixty days, but no longer.

Sec. 5. And be it further enacted, That every free white male citizen
of the United States, above the age of twenty-one years, who shall
have been a resident of said Territory at the time of the passage of
this act, including those recognized as citizens by the treaty with the
Republic of Mexico, concluded February two, eighteen hundred and
forty-eight, and the treaty negotiated with the same country on the
thirtieth of December, eighteen hundred and fifty-three, shall be
entitled to vote at the first election, and shall be eligible to any office
within the said Territory; but the qualifications of voters and of
holding office at all subsequent elections shall be such as shall be
prescribed by the Legislative Assembly.

Sec. 6. And be it further enacted, That the legislative power of the


Territory shall extend to all rightful subjects of legislation consistent
with the Constitution of the United States and the provisions of this
act; but no laws shall be passed interfering with the primary disposal
of the soil; no tax shall be imposed upon the property of the United
States; nor shall the lands or other property of non-residents be
taxed higher than the lands or other property of residents; nor shall
any law be passed impairing the rights of private property; nor shall
any discrimination be made in taxing different kinds of property; but
all property subject to taxation shall be in proportion to the value of
the property taxed.

Sec. 7. And be it further enacted, That all township, district, and


county officers, not herein otherwise provided for, shall be appointed
or elected, as the case may be, in such manner as shall be provided
by the Governor and Legislative Assembly of the Territory. The
Governor shall nominate, and by and with the advice and consent of
the Legislative Assembly, appoint all officers not herein otherwise
provided for; and in the first instance the Governor alone may
appoint said officers, who shall hold their offices until the end of the
first session of the Legislative Assembly, and shall lay off the
necessary districts for members of the Council and House of
Representatives, and all other officers.

Sec. 8. And be it further enacted, That no member of the Legislative


Assembly shall hold or be appointed to any office which shall have
been created, or the salary or emoluments of which shall have been
increased while he was a member, during the term for which he was
elected, and for one year after the expiration of such term; and no
person holding a commission or appointment under the United
States, except postmasters, shall be a member of the Legislative
Assembly, or shall hold any office under the government of said
Territory.

Sec. 9. And be it further enacted, That the judicial power of said


Territory shall be vested in a Supreme Court, District Courts, Probate
Courts, and Justices of the Peace. The Supreme Court shall consist
of a Chief Justice and two Associate Justices, any two of whom shall
constitute a quorum, and who shall hold a term at the seat of
government of said Territory annually; and they shall hold their
offices during the period of four years; the said Territory shall be
divided into three judicial districts, and a District Court shall be held
in each of said districts by one of the Justices of the Supreme Court
at such time and place as may be prescribed by law; and the Judges
shall, after their appointments, respectively, reside in the districts
which shall be assigned them. The jurisdiction of the several courts
herein provided for, both appellate and original, and that of the
Probate Courts and of the Justices of the Peace, shall be as limited
by law: Provided, That Justices of the Peace and Probate Courts
shall not have jurisdiction of any matter in controversy where the
title or boundaries of land may be in dispute, or where the debt or
sum claimed shall exceed one hundred dollars; and the said
Supreme and District Courts, respectively, shall possess chancery as
well as common law jurisdiction; and authority for redress of all
wrongs committed against the constitution or laws of the United
States or of the Territory, affecting persons or property. Each District
Court or the Judge thereof shall appoint its Clerk, who shall also be
the register in chancery, and shall keep his office at the place where
the court may be held. Writs of error, bills of exception, and appeals,
shall be allowed in all cases from the final decisions of said District
Courts to the Supreme Court, under such regulations as may be
prescribed by law; but in no case removed to the Supreme Court
shall trial by jury be allowed in said Court. The Supreme Court, or
the Justices thereof, shall appoint its own Clerk, and every clerk shall
hold his office at the pleasure of the court for which he shall have
been appointed. Writs of error and appeals from the final decisions
of said Supreme Court shall be allowed, and may be taken to the
Supreme Court of the United States, in the same manner and under
the same regulations as from the Circuit Courts of the United States,
where the value of the property or the amount in controversy, to be
ascertained by the oath or affirmation of either party, or other
competent witness, shall exceed one thousand dollars; and each of
the said District Courts shall have and exercise the same jurisdiction,
in all cases arising under the constitution and laws of the United
States, as is vested in the Circuit and District Courts of the United
States; and the said Supreme and District Courts of the said
Territory, and the respective Judges thereof, shall and may grant
writs of habeas corpus in all cases in which the same are grantable
by the Judges of the United States in the District of Columbia; and
the first six days of every term of said courts, or so much thereof as
shall be necessary, shall be appropriated to the trial of causes arising
under the said constitution and laws, and writs of error and appeals
in all such cases shall be made to the Supreme Court of said
Territory the same as in other cases. The said Clerk shall receive in
all such cases the same fees which the Clerks of the District Courts
of Oregon received for similar services.

Sec. 10. And be it further enacted, That there shall be appointed an


Attorney for said Territory, who shall continue in office for four years,
unless sooner removed by the President, and who shall receive the
same fees and salary as the Attorney of the United States for the
Territory of Oregon. There shall also be a Marshal for the Territory
appointed, who shall hold his office for four years, unless sooner
removed by the President, and who shall execute all processes
issuing from said courts when exercising their jurisdiction as Circuit
and District Courts of the United States; he shall perform the duties,
be subject to the same regulations and penalties, and be entitled to
the same fees as the Marshal of the District Court of the United
States for the Territory of Oregon, and shall, in addition, be paid two
hundred dollars annually as a compensation for extra services.

Sec. 11. And be it further enacted, That the Governor, Secretary,


Chief Justice, and Associate Justices, Attorney, and Marshal shall be
nominated, and by and with the advice and consent of the Senate,
appointed by the President of the United States. The Governor and
Secretary to be appointed as aforesaid shall, before they act as such,
respectively take an oath or affirmation before the District Judge, or
some Justice of the Peace in the limits of said Territory duly
authorized to administer oaths and affirmations by the laws now in
force therein, or before the Chief Justice, or some Associate Justice
of the Supreme Court of the United States, to support the
constitution of the United States, and faithfully to discharge the
duties of their respective offices, which said oaths, when so taken,
shall be certified by the person by whom the same shall have been
taken; and such certificate shall be received and recorded by the
Secretary among the executive proceedings; and the Chief Justice
and Associate Justices, and all other civil officers in said Territory,
before they act as such, shall take a like oath or affirmation, before
the said Governor or Secretary, or some Judge or Justice of the
Peace of the Territory who may be duly commissioned and qualified,
which said oath or affirmation shall be certified and transmitted by
the person taking the same to the Secretary, to be by him recorded
as aforesaid; and afterwards the like oath or affirmation shall be
taken, certified and recorded in such manner and form as may be
prescribed by law. The Governor shall receive an annual salary of
fifteen hundred dollars as Governor, and one thousand dollars as
Superintendent of Indian Affairs; the Chief Justice and Associate
Justices shall receive an annual salary of eighteen hundred dollars.
The said salaries shall be paid quarter yearly at the Treasury of the
United States. The members of the Legislative Assembly shall be
entitled to receive three dollars each per day during their attendance
at the session thereof, and three dollars for every twenty miles travel
in going to and returning from the said sessions, estimated
according to the nearest usually traveled route. There shall be
appropriated annually the sum of one thousand dollars, to be
expended by the Governor, to defray the contingent expenses of the
Territory. There shall also be appropriated, annually, a sufficient sum
to be expended by the Secretary of the Territory, and upon an
estimate to be made by the Secretary of the Treasury of the United
States, to defray the expenses of the Legislative Assembly, the
printing of the laws, and other incidental expenses; and the
Secretary of the Territory shall annually account to the Secretary of
the Treasury of the United States for the manner in which the
aforesaid sum shall have been expended.

Sec. 12. And be it further enacted, That the Legislative Assembly of


the Territory of Colorado shall hold its first session at such time and
place in said Territory as the Governor thereof shall appoint and
direct; and at said first session, or as soon thereafter as they shall
deem expedient, the Governor and Legislative Assembly shall
proceed to locate and establish the seat of government for said
Territory at such place as they may deem eligible, which place,
however, shall thereafter be subject to be changed by the said
Governor and Legislative Assembly.

Sec. 13. And be it further enacted, That a delegate to the House of


Representatives of the United States, to serve during each Congress
of the United States, may be elected by the voters qualified to elect
members of the Legislative Assembly, who shall be entitled to the
same rights and privileges as are exercised and enjoyed by the
Delegates from the several other Territories of the United States to
the said House of Representatives. The first election shall be held at
such time and places, and be conducted in such manner as the
Governor shall appoint and direct; and at all subsequent elections
the times, places, and manner of holding elections shall be
prescribed by law. The person having the greatest number of votes
shall be declared by the Governor to be duly elected, and a
certificate thereof shall be given accordingly.

Sec. 14. And be it further enacted, That when the land in the said
Territory shall be surveyed, under the direction of the Government of
the United States, preparatory to bringing the same into market,
sections numbered sixteen and thirty-six in each town in said
Territory and be and the same are hereby reserved for the purpose
of being applied to schools in the States hereafter to be erected out
of the same.

Sec. 15. And be it further enacted, That temporarily, and until


otherwise provided by law, the Governor of said Territory may define
the judicial districts of said Territory, and assign the Judges who may
be appointed for said Territory, to the several districts, and also
appoint the times and places for holding courts in the several
counties or subdivisions in each of said judicial districts by
proclamation to be issued by him; but the Legislative Assembly, at
their first or any subsequent session, may organize, alter or modify
such judicial districts, and assign the Judges, and alter the times and
places of holding the courts, as to them shall seem proper and
convenient.
Sec. 16. And be it further enacted, That the Constitution and all laws
of the United States, which are not locally inapplicable, shall have
the same force and effect within the said Territory of Colorado as
elsewhere within the United States.

Sec. 17. And be it further enacted, That the President of the United
States, by and with the advice and consent of the Senate, shall be
and is hereby authorized to appoint a Surveyor General for Colorado,
who shall locate his office at such place as the Secretary of the
Interior shall from time to time direct, and whose duties, powers,
obligations, responsibilities, compensation, and allowances for clerk
hire, office rent, fuel, and incidental expenses, shall be the same as
those of the Surveyor General of New Mexico, under the direction of
the Secretary of the Interior, and such instructions as he may from
time to time deem it advisable to give him.

Approved February 28th, 1861.

AMENDMENTS TO THE ORGANIC ACT.


AN ACT TO AMEND AN ACT ENTITLED “AN ACT TO PROVIDE A
TEMPORARY GOVERNMENT FOR THE TERRITORY OF COLORADO.”

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That the second
section of the act to which this act is an amendment, be altered so
as to read as follows: The executive power and authority in and over
said Territory of Colorado, shall be vested in a Governor, who shall
hold his office for four years, and until his successor shall be
appointed and qualified, unless sooner removed by the President of
the United States. The Governor shall reside within said Territory,
shall be commander-in-chief of the militia thereof, shall perform the
duties, and shall receive the emoluments of Superintendent of
Indian Affairs; he may grant pardons for offences against the laws of
said Territory, and reprieves for offenses against the laws of the
United States, until the decision of the President shall be made
known thereon; he shall commission all officers who shall be
appointed to office under the laws of said Territory, and shall take
care that the laws be faithfully executed.

Sec. 2. And be it further enacted, That every bill which shall have
passed the Legislative Assembly shall, before it become a law, be
presented to the Governor of the Territory; if he approve, he shall
sign it; but if not he shall return it, with his objections, to the house
in which it originated, who shall enter the objections at large on
their journal, and proceed to reconsider it. If, after such
reconsideration, two-thirds of that house shall agree to pass the bill,
it shall be sent, together with the objections, to the other house, by
which it shall likewise be reconsidered, and if approved by two-thirds
of that house, it shall become a law. But in all such cases the votes
of both houses shall be determined by yeas and nays, to be entered
on the journal of each house respectively. If any bill shall not be
returned by the Governor within three days (Sundays excepted)
after it shall have been presented to him, the same shall be a law in
like manner as if he had signed it, unless the Assembly, by
adjournment, prevents its return, in which case it shall not be law.

Sec. 3. And be it further enacted, That section nine of the act to


which this act is amendatory be altered so as to read as follows:
Section 9. And be it further enacted, That the judicial power of said
Territory shall be vested in a Supreme Court, District Courts, Probate
Courts, and Justices of the Peace. The Supreme Court shall consist
of a Chief Justice and two Associate Justices, any two of whom shall
constitute a quorum, and who shall hold a term at the seat of
government of said Territory, annually, and they shall hold their
offices during the period of four years. The said Territory shall be
divided into three judicial districts, and a District Court shall be held
in each of said districts by one of the Justices of the Supreme Court,
at such time and place as may be prescribed by law; and the said
judges shall, after their appointments, respectively reside in the
districts which shall be assigned them. The jurisdiction of the several
courts herein provided for, both appellate and original, and of
Justices of the Peace, shall be as limited by law; Provided, That
Justices of the Peace shall not have jurisdiction of any matter in
controversy, when the title or boundaries of land may be in dispute,
or when the debt or sum claimed shall exceed three hundred dollars;
and the said Probate Court shall not have jurisdiction in any matter
in controversy, when the debt or sum claimed shall exceed the sum
of two thousand dollars; and said Supreme and District Courts shall
have authority for redress of all wrongs committed against the
constitution and laws of the United States; and the said Supreme,
District, and Probate Courts respectively, shall possess chancery, as
well as common law jurisdiction, and authority for the redress of all
wrongs committed against the laws of said Territory, affecting
persons or property. Each District Court, or the judge thereof, shall
appoint its clerk, who shall also be the Register in Chancery, and
shall keep his office at the place where the court may be held. Writs
of error, bills of exception and appeals shall be allowed from the final
decisions of said District and Probate Courts to the Supreme Court,
under such regulations as shall be prescribed by law; but in no case
remove to the Supreme Court, shall trial by jury be allowed in said
court. The Supreme Court, or the justices, thereof, shall appoint its
own clerk, and every clerk shall hold his office at the pleasure of the
court for which he shall have been appointed. Writs of error and
appeals from the final decisions of said Supreme Court shall be
allowed, and may be taken to the Supreme Court of the United
States in the same manner and under the same regulations as from
the Circuit Courts of the United States, when the value of the
property, or the amount in controversy, to be ascertained by the
oath or affirmation of either party, or other competent witness, shall
exceed one thousand dollars; and each of said Supreme and District
Courts shall have and exercise the same jurisdiction in all cases
arising under the constitution and laws of the United States, as is
vested in the Circuit and District Courts of the United States; and the
said Supreme and District Courts of said Territory, and the respective
judges thereof, shall and may grant writs of habeas corpus in all
cases in which the same are granted by the judges of the United
States in the District of Columbia; and the first six days of every
term of said courts, or so much thereof as shall be necessary, shall
be appropriated to the trial of causes arising under the said
constitution and laws; and writs of error and appeals in all such
cases shall be made to the Supreme Court of said Territory, the
same as in other cases. The said clerk shall receive in all such cases
the same fees which the clerks of the Districts Courts of Oregon
Territory received for similar services.

Sec. 4. And be it further enacted, That the provisions of sections one


and two of this act shall be applicable to the Territory of Dakota, and
shall have like effect as in the Territory of Colorado.

Approved March 2, 1863.

AN ACT AMENDATORY OF THE ORGANIC ACT OF COLORADO


TERRITORY.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That hereafter the
sessions of the Legislative Assembly of Colorado Territory shall be
biennial. Members of the Council shall be elected for the term of four
years, and members of the House for the term of two years, and
shall receive the sum of six dollars per day instead of three dollars
heretofore allowed, and shall also receive the same mileage now
allowed by law.

Sec. 2. And be it further enacted, That each house shall have


authority to elect, in addition to the officers now allowed by law, an
enrolling clerk, who shall receive five dollars per day. The chief clerk
shall receive six dollars per day, and the other officers elected by
said Legislature shall receive five dollars per day each.

Sec. 3. And be it further enacted, That the members of the


Legislative Assembly elected at the general election of said Territory
in the year eighteen hundred and sixty-seven, shall compose the first
Legislature under this act, and said Legislature shall meet at the
time now fixed by law for the meeting of the Legislative Assembly of
Colorado Territory.

Approved March 30th, 1867.

AN ACT TO REGULATE THE ELECTIVE FRANCHISE IN THE


TERRITORIES OF THE UNITED STATES.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That from and
after the passage of this act, there shall be no denial of the elective
franchise in any of the territories of the United States, now, or
hereafter to be organized, to any citizen thereof, on account of race,
color, or previous condition of servitude; and all acts or parts of acts,
either of Congress or the Legislative Assemblies of said Territories,
inconsistent with the provisions of this act are hereby declared null
and void.

SCHUYLER COLFAX,
Speaker of the House of Representatives.
LAFAYETTE S. FOSTER,
President of the Senate, pro tempore.

Endorsed by the President: Received on the 14th January, 1867.

[Note by the State Department.—The foregoing act having been presented to


the President of the United States for his approval, and not having been
returned by him to the House of Congress, in which it originated, within the
time prescribed by the Constitution of the United States, has become a law
without his approval.]

AN ACT AMENDATORY OF “AN ACT TO PROVIDE A TEMPORARY


GOVERNMENT FOR THE TERRITORY OF MONTANA.” APPROVED
MAY 26th, 1864.
Be it enacted by the Senate and House of Representatives of the
United States of America in Congress assembled, That the
Legislative Assemblies of the several Territories of the United States
shall not, after the passage of this act, grant private charters or
especial privileges, but they may, by general incorporation acts,
permit persons to associate themselves together as bodies corporate
for mining, manufacturing, and other industrial pursuits.

Sec. 7. And be it further enacted, That from and after the first day of
April next the salary of each of the judges of the several Supreme
Courts, in each of the organized Territories (except Montana and
Idaho), shall be two thousand five hundred dollars.

Sec. 8. And be it further enacted, That all acts and parts of acts
inconsistent with this act are hereby repealed.

Approved March 2d, 1867.

AN ACT MAKING APPROPRIATIONS FOR THE LEGISLATIVE,


EXECUTIVE, AND JUDICIAL EXPENSES OF THE GOVERNMENT FOR
THE YEAR ENDING THE THIRTIETH OF JUNE, EIGHTEEN HUNDRED
AND SEVENTY.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, * * * * * * That
hereafter the members of both branches of the Legislative
Assemblies of the several Territories shall be chosen for the term of
two years, and the sessions of the Legislative Assemblies shall be
biennial; and each Territorial Legislature shall, at its first session
after the passage of this act, make provision by law for carrying this
act into effect.

Approved March 3d, 1869.


AN ACT REGULATING THE COMPENSATION OF THE MEMBERS AND
OFFICERS OF THE LEGISLATIVE ASSEMBLIES OF THE SEVERAL
TERRITORIES OF THE UNITED STATES, AND LIMITING THE
DURATION OF THE SESSIONS OF SAID ASSEMBLIES.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That the sessions
of the Legislative Assemblies of the several Territories of the United
States shall be limited to forty days duration.

Sec. 2. That the members of each branch of said Legislatures shall


receive a compensation of six dollars per day during the sessions
herein provided for, and they shall receive such mileage as now
provided by law; Provided, That the President of the Council, and
Speaker of the House of Representatives shall each receive a
compensation of ten dollars per day, and that the additional officers
of each branch of said Legislative Assemblies shall consist of one
Chief Clerk, who shall receive a compensation of eight dollars per
day, and of one Assistant Clerk, one Enrolling Clerk, one Engrossing
Clerk, one Sergeant-at-arms, one Doorkeeper, one Messenger, and
one Watchman, who shall each receive a compensation of five
dollars per day during the sessions.

Sec. 3. That from and after the first day of July, eighteen hundred
and seventy-three, the annual salaries of the Governors of the
several Territories of the United States shall be three thousand five
hundred dollars, and the salaries of the Secretaries of said Territories
shall be two thousand five hundred dollars each.

Sec. 4. That the provisions of this act shall not apply to the District of
Columbia; Provided, That no law of any Territorial Legislature shall
be made or enforced by which any officer of a Territory herein
provided for, or the officers or members of any Territorial Legislature
shall be paid any compensation other than that provided by the laws
of the United States.
Approved January 23, 1873.
CHAPTER III.
In 1861 the Kansas officials had disappeared. The Provisional
government continued to exercise its partially acknowledged
authority until the arrival of the United States appointees for the new
Territory. These arrived on the 29th of May. The Federal officers,
who then came, with their sealed commissions, were: William Gilpin,
Governor; Lewis Ledyard Weld, Secretary; B. F. Hall, Chief Justice; S.
N. Pettis, and Charles Lee Armor, Associate Justices; Copeland
Townsend, Marshal; James E. Dalliba, Attorney General; F. M. Case,
Surveyor General. The Provisional government now ceased. Its laws
had been published, but not enforced, and its officers had the honor,
but not the pay, of the positions they held.

Governor Gilpin was welcomed with undisguised pleasure. His


greeting was a perfect ovation. The people now felt a new sense of
security, for the strong arm of the General Government was in their
midst. The Governor at once proceeded with commendable energy
to discharge the functions of his high office. His first duty was to see
the settlements of the Territory, and ascertain the character,
condition and wants of the people. This visitation was accomplished
with great celerity. Wherever the Governor went, the joy and
hospitality of the people knew no bounds. Everywhere he was
welcomed with bouquets, balls, congratulations. On his return to
Denver, in accordance with his prescribed duty, a census was
ordered. The returns exhibited a population of 25,329. The
proportion of men to women was nearly five to one. The Governor,
qualified July 8th, and was now in the full exercise of his authority.
The other co-ordinate branch of Federal Government had now to be
established. This was the United States Supreme Court. On July
10th, the Governor assigned the judges to their districts, and the
Supreme Court immediately organized. On July 11th, he issued a
proclamation, in which the Territory was declared to be one
Congressional District, and the Congressional District to be divided
into nine Council, and thirteen Representative Districts, and in which
the election of a delegate to Congress, and of Legislative Assembly
were ordered. The election was duly held on the 19th of August—
Hiram P. Bennet was elected delegate to Congress. The Legislature
of the Territory of Colorado convened on the 9th of September. They
adopted full civil, and criminal codes. They recognized the miners as
authority in mining legislation, acknowledged the legality of their
courts, adopted their laws, confirmed their decisions, and arranged
for the transfer of cases to the regular courts, so that no jarring, nor
inconvenience was experienced. Great praise is due to this legislative
body for the laws they enacted, and though some have been found
faulty, and others repealed, yet they have effectually served the
needs of the Territory. When the rebellion had been in progress for
several months, Gov. Gilpin issued a call for volunteers. Recruits
quickly responded to the call, and the first regiment of Colorado
infantry, under Col. John P. Slough, soon took the field. This infantry
was transformed into a cavalry regiment, and did good service in
repelling the Texan invasion early in 1862. During this year
immigration received a strong impetus. It was computed that the
daily arrivals, averaging one hundred, added in a short time ten
thousand to the population as returned by the census. The city of
Denver, including Auraria and Highland, was again incorporated in
November, 1861. Among the industries, placer mining was most
successfully prosecuted, California gulch alone yielding one million
dollars.

In April, 1862, Dr. John Evans superseded Governor William Gilpin.


The levy of the second regiment of Colorado cavalry was made this
year, and the troops ordered to Missouri. In 1863 they were
consolidated with the third regiment raised in Colorado. This body of
cavalry did effective service in Missouri, and in 1864 won
considerable renown in the movements executed against Price in his
last invasion. They took a prominent part in four battles, to wit: Mine
Creek, Oct. 22; Westport, Oct. 23; Charlot, Oct. 25; Newtonia, Nov.
4. The quantity of gold obtained by gulch mining this year exceeded
any previous yield. H. P. Bennet was re-elected delegate to Congress
in September.

In the year 1863 began in the East the stupendous speculation in


gold mines. The spirit of speculation had infected all classes of
people, and financial schemes were quickly devised to draw millions
from the public. Among these Colorado mines prominently figured.
On the 19th of April Denver lost, by a severe conflagration, a sum
estimated at a quarter of a million dollars. A branch telegraph line
was completed from Julesburg to Denver in October, whereby
telegraphic communication with the world was established. On the
7th of October a treaty was concluded with the Tabeguache band of
Utah Indians, by which the Indian title to all of the settled portions
of the mountains of Colorado, and most of the San Luis valley, was
extinguished.

The year 1864 was the gloomy period of the rebellion. Speculation
became a mania. Stock companies of the most gigantic character
were organized on the basis of Colorado gold mines. It need hardly
be said that thousands lost large sums by reckless investments in
gold mining stocks. In the spring the Indians of the plains,
composed of Sioux, Cheyennes, and Arapahoes, combined to carry
on a bloody and exterminating war against the whites. They
attacked the coaches; murdered, scalped, and mutilated the
passengers. Exposed dwellings were surrounded and the inmates
massacred. Emboldened by little or no resistance, they admitted no
pause to their savage butcheries. This thoroughly roused the people
to punish the hostile fiends. Twelve hundred men, under the
command of Col. J. M. Chivington, hurried forward to meet the
merciless savages, and arrest their work of horrors. They found and
suddenly assailed a large troop of Cheyennes, about seven hundred
in number, and with hearts steeled against mercy, dealt swift
retribution, sparing neither age nor sex, until nearly all were
destroyed. This stunning blow checked the Indian outrages. A
temporary quiet ensued, and the roads were again animated with
coaches and wagon trains. Much credit is due to Captain Tyler, who,
with his brave company, opened and protected the line of
communication with the States. On May 19th, a more disastrous
calamity befell Denver than the fire of the preceding year. An
appalling flood swept down Cherry Creek, overwhelming large
buildings, and sweeping them and their contents down its
destructive current. Twenty persons perished in the ruthless waters.
The damages were computed to be a million dollars. Near the close
of the Thirty-eighth Congress, a bill was passed, in response to a
petition of the Colorado Legislature, enabling the territory to
organize a State government and enter the Union. Under its
provisions a convention met in Denver July 4th, 1864, and framed a
constitution. This was rejected by the people on the second Tuesday
of October. In the fall of 1864, A. A. Bradford was elected delegate
to Congress.

In 1865 the Indians renewed hostilities, apparently determined to


force back immigration. All intercourse with the East was interrupted
for a time. Business was paralyzed. Lonely ranches were invaded,
and their occupants fiendishly massacred. This second outbreak of
the Indians was effectually checked by United States troops. In the
spring of this year all parties concurred in another attempt to
organize a state. A convention met in Denver in August, and framed
a constitution, which was adopted by a majority of 155. A State
legislature, and the complement of State officers, were elected
November 14th. Ex-Governor William Gilpin was chosen State
Governor. Ex-Governor John Evans and Jerome B. Chaffee were
chosen senators by the legislature. Application for the admission of
Colorado as a state was made during each session of the Thirty-
ninth Congress. A strong disinclination to grant the application was
manifested. An exigency, however, arose, which changed their
disposition. The President, Andrew Johnson, had been impeached.
The success of the impeachment was involved in doubt. To secure
two senators and a representative, an enabling act was passed to
admit the new state. The President, as might be expected, vetoed
the bill. Governor John Evans was superseded by Alexander
Cummings, who qualified October 19th.

In 1866 a reaction followed the prostration of trade and industry


consequent upon the Indian outrages of the preceding year. An
unwonted stimulus pervaded the territory. Mining pursuits were
followed with fresh vigor. In Denver and other places building was
carried on with unparalleled activity. Money became plentiful, and
many laid the foundations of large fortunes. George M. Chilcott was
elected delegate. Up to this time the bullion deposited in the mint
amounted to 12,401,372 dollars, said to be less than half of the real
yield.

On May 27th, 1867, A. C. Hunt superseded Governor Cummings. The


struggle for statehood ended with the winter of 1867-8, when it was
found impossible to pass the bill over the veto. In the fall the Denver
Board of Trade was organized, which principally labored to initiate
the enterprise of building a railroad to join the Union Pacific road at
Cheyenne. Near the close of the year the Union Pacific road reached
Cheyenne. The Denver Pacific Railway and Telegraph Company was
incorporated November 18th, 1867. During this year the various
interests of Colorado were ably represented at the Universal
Exposition in Paris. The first gold medal was awarded to the minerals
of Colorado. The French Government, moved by Colorado’s display
at the Exposition, appointed an Imperial Commissioner, who visited
the territory and reported his observations therein for the benefit of
capital and science in France. The Kiowas and Comanches, the
Cheyennes and Arapahoes were removed to reservations bordering
on Colorado and Kansas, where their southern boundary lines meet.
By their treaties they stipulate to withdraw opposition to immigrants,
settlers, and lines of railroad.

In 1868 A. A. Bradford was again elected delegate to Congress.


On June 15th, 1869, Edward M. McCook superseded Governor A. C.
Hunt.

The Denver Pacific Railway Company had been formed in 1867. Its
principal object, as stated in the articles of incorporation, was to
build a railroad and telegraph line to Cheyenne, and there connect
with the Union Pacific road. After some delay the funds were
secured, the construction of the road hastened, and on the 23d day
of June, 1870, the first train arrived in Denver. On the 15th day of
August, the Kansas Pacific Railway, 640 miles in length, was
completed. In September, seventeen miles of the Colorado Central
were finished. The connection of Golden with Denver was thereby
effected. During this year successful efforts were made to plant
colonies in choice sections of the Territory. The Meeker-Greeley
colony was organized in New York in the winter of 1869-70, and
located in the spring. It now has a population of 2,000, happy and
prosperous, and distinguished by prohibition laws and devotion to
temperance. The town site of the colony is a delta formed by the
Cache-a-la-Poudre and South Platte rivers. The Chicago-Colorado
colony is largely composed of Western men, and is animated by a
liberal progressive spirit. The location of the colony is in every way
most desirable. The energy and enterprise of the colonists excite
great admiration. They have already a beautiful town, and a large
extent of country under cultivation. The German colony may also be
mentioned. It occupied Wet Mountain Valley, which lies in Pueblo
and Fremont counties. Thus, by rapid transit, the Territory was
brought into close communication with the States, and began to fill
up with thousands, who, independently, or in co-operative
association, settled for the purposes of agriculture. No sign so
cheering as a settlement of a country by intelligent, enterprising
farmers. Hardy, industrious miners had already crowded into the
mountains, and skillful, energetic farmers now collected on the
plains, intent to reap from them rich and abundant harvests. In the
fall, Jerome B. Chaffee was elected delegate to Congress.
This year, 1871, dates the settlement of the Colorado Springs colony,
distinguished for its rapid and prosperous growth. Situated seventy-
five miles south from Denver, it became the temporary terminus of
the Denver and Rio Grande railway, which was completed to that
point during this year. The railroad has since passed on to Pueblo,
and thence to La Veta, with branches to El Moro, and Canon City.

In 1872, Jerome B. Chaffee was re-elected delegate to Congress.

In 1873, a large immigration into the San Juan region commenced,


owing to reports of rich mineral discoveries. S. H. Elbert superseded
Gov. E. M. McCook. Following the custom of those removed from
office, the ex-Governor proceeded to Washington to confer with the
federal authorities, and in January, 1874, was re-appointed in place
of Gov. Elbert. Severe and bitter editorials filled the columns of the
press devoted to the fallen regime. A temporary division of the
Republican party ensued. A lively contest for political supremacy
followed and continued until the usual period for an election to
Congress, when the two sides of the party marshaled themselves,
the one to rebuke and the other to sustain the administration. The
malcontents not only turned the election against the Republican
nominee, H. P. H. Bromwell, but gave a large and unprecedented
majority to the Democratic nominee, Thomas M. Patterson. This
change in the popular vote deeply touched the administration, and it
was determined, in order to reconcile the disaffected, to remove the
obnoxious appointments, and fill the federal offices with men not
implicated in the controversy.

During the year 1874, the South Park railroad was finished to
Morrison.

John L. Routt, the successor to Gov. McCook, qualified on March


29th, 1875. He set to work without delay to unite the discordant
factions and succeeded. The people in general were now fully
persuaded that the time had come for demanding the privileges of
Statehood. The Republican delegate, Jerome B. Chaffee, had during
the winter of 1874-5, drawn up an Enabling Act with much skill, and
by persistent effort and untiring zeal, had, in the face of strong
opposition, effected the passage of the bill. Before its passage the
Act was amended so as to postpone the date of admission to July
4th, 1876.
CHAPTER IV.
An Act to amend the Act entitled “An Act to enable the people of
Colorado to form a constitution and State government, and for
the admission of said State into the Union on an equal footing
with the original States,” approved March 3, 1875.

ENABLING ACT.
Be it enacted by the Senate and House of Representatives of the
United States of America in Congress assembled, That the
inhabitants of the Territory of Colorado included in the boundaries
hereinafter designated be, and they are hereby, authorized to form
for themselves, out of said Territory, a State government, with the
name of the State of Colorado; which State, when formed, shall be
admitted into the Union upon an equal footing with the original
States in all respects whatsoever, as hereinafter provided.

Sec. 2. That the said State of Colorado shall consist of all the
territory included within the following boundaries, to wit:
Commencing on the thirty-seventh parallel of north latitude where
the twenty-fifth meridian of longitude west from Washington crosses
the same; thence north on said meridian, to the forty-first parallel of
north latitude; thence along said parallel west to the thirty-second
meridian of longitude west from Washington; thence south on said
meridian, to the thirty-seventh parallel of north latitude; thence
along said thirty-seventh parallel of north latitude, to the place of
beginning.
Sec. 3. That all persons qualified by law to vote for representatives
to the general assembly of said Territory, at the date of the passage
of this act, shall be qualified to be elected, and they are hereby
authorized to vote for and choose representatives to form a
convention under such rules and regulations as the governor of said
Territory, the chief justice, and the United States attorney thereof
may prescribe; and also to vote upon the acceptance or rejection of
such constitution as may be formed by said convention, under such
rules and regulations as said convention may prescribe; and the
aforesaid representatives to form the aforesaid convention shall be
apportioned among the several counties in said Territory in
proportion to the vote polled in each of said counties at the last
general election as near as may be; and said apportionment shall be
made for said Territory by the governor, United States district
attorney, and chief justice thereof, or any two of them; and the
governor of said Territory shall, by proclamation, order an election of
the representatives aforesaid to be held throughout the Territory at
such time as shall be fixed by the governor, chief justice, and United
States attorney, or any two of them, which proclamation shall be
issued within ninety days next after the first day of September,
eighteen hundred and seventy-five, and at least thirty days prior to
the time of said election; and such election shall be conducted in the
same manner as is prescribed by the laws of said Territory regulating
elections therein for members of the house of representatives; and
the number of members to said convention shall be the same as
now constitutes both branches of the legislature of the aforesaid
Territory.

Sec. 4. That the members of the convention thus elected shall meet
at the capital of said Territory, on a day to be fixed by said governor,
chief justice, and United States attorney, not more than sixty days
subsequent to the day of election, which time of meeting shall be
contained in the aforesaid proclamation mentioned in the third
section of this act, and, after organization, shall declare, on behalf of
the people of said Territory, that they adopt the Constitution of the
United States; whereupon the said convention shall be, and is
hereby, authorized to form a constitution and State government for
said Territory: Provided, That the constitution shall be republican in
form, and make no distinction in civil or political rights on account of
race or color, except Indians not taxed, and not be repugnant to the
Constitution of the United States and the principles of the
Declaration of Independence: And provided further, That said
convention shall provide, by an ordinance irrevocable without the
consent of the United States and the people of said State, first, that
perfect toleration of religious sentiment shall be secured, and no
inhabitant of said State shall ever be molested in person or property
on account of his or her mode of religious worship; secondly, that
the people inhabiting said Territory do agree and declare that they
forever disclaim all right and title to the unappropriated public lands
lying within said Territory, and that the same shall be and remain at
the sole and entire disposition of the United States, and that the
lands belonging to citizens of the United States residing without the
said State shall never be taxed higher than the lands belonging to
residents thereof, and that no taxes shall be imposed by the State on
lands or property therein belonging to, or which may hereafter be
purchased by the United States.

Sec. 5. That in case the constitution and State government shall be


formed for the people of said Territory of Colorado, in compliance
with the provisions of this act, said convention forming the same
shall provide, by ordinance, for submitting said constitution to the
people of said State for their ratification or rejection, at an election,
to be held at such time, in the month of July, eighteen hundred and
seventy-six, and at such places and under such regulations as may
be prescribed by said convention, at which election the lawful voters
of said new State shall vote directly for or against the proposed
constitution; and the returns of said election shall be made to the
acting governor of the Territory, who, with the chief justice and
United States attorney of said Territory, or any two of them, shall
canvass the same; and if a majority of legal votes shall be cast for
said constitution in said proposed State, the said acting governor
shall certify the same to the President of the United States, together
with a copy of said constitution and ordinances; whereupon it shall
be the duty of the President of the United States to issue his
proclamation declaring the State admitted into the Union on an
equal footing with the original States, without any further action
whatever on the part of Congress.

Sec. 6. That until the next general census said State shall be entitled
to one Representative in the House of Representatives of the United
States, which Representative, together with the governor and State
and other officers provided for in said constitution, shall be elected
on a day subsequent to the adoption of the constitution, and to be
fixed by said constitutional convention; and until said State officers
are elected and qualified under the provisions of the constitution,
the territorial officers shall continue to discharge the duties of their
respective offices.

Sec. 7. That sections numbered sixteen and thirty-six in every


township, and where such sections have been sold or otherwise
disposed of by any act of Congress, other lands, equivalent thereto,
in legal subdivisions of not more than one quarter-section, and as
contiguous as may be, are hereby granted to said State for the
support of common schools.

Sec. 8. That, provided the State of Colorado shall be admitted into


the Union in accordance with the foregoing provisions of this act,
fifty entire sections of the unappropriated public lands within said
State, to be selected and located by direction of the legislature
thereof, and with the approval of the President, on or before the first
day of January, eighteen hundred and seventy-eight, shall be, and
are hereby, granted, in legal subdivisions of not less than one
quarter-section, to said State for the purpose of erecting public
buildings at the capital of said State for legislative and judicial
purposes, in such manner as the legislature shall prescribe.

Sec. 9. That fifty other entire sections of land as aforesaid, to be


selected and located and with the approval as aforesaid, in legal
subdivisions as aforesaid, shall be, and they are hereby, granted to
said State for the purpose of erecting a suitable building for a
penitentiary or State prison in the manner aforesaid.

Sec. 10. That seventy-two other sections of land shall be set apart
and reserved for the use and support of a State university, to be
selected and approved in manner as aforesaid, and to be
appropriated and applied as the legislature of said State may
prescribe for the purpose named, and for no other purpose.

Sec. 11. That all salt-springs within said State, not exceeding twelve
in number, with six sections of land adjoining, and as contiguous as
may be to each, shall be granted to said State for its use, the said
land to be selected by the governor of said State within two years
after the admission of the State, and when so selected to be used
and disposed of on such terms, conditions, and regulations as the
legislature shall direct: Provided, That no salt-springs or lands the
right whereof is now vested in any individual or individuals, or which
hereafter shall be confirmed or adjudged to any individual or
individuals, shall by this act be granted to said State.

Sec. 12. That five per centum of the proceeds of the sales of
agricultural public lands lying within said State which shall be sold by
the United States subsequent to the admission of said State into the
Union, after deducting all the expenses incident to the same, shall
be paid to the said State for the purpose of making such internal
improvements within said State as the legislature thereof may direct:
Provided, That this section shall not apply to any lands disposed of
under the homestead laws of the United States, or to any lands now
or hereafter reserved for public or other uses.

Sec. 13. That any balance of the appropriations for the legislative
expenses of said Territory of Colorado remaining unexpended shall
be applied to and used for defraying the expenses of said
convention, and for the payment of the members thereof, under the
same rules and regulations and rates as are now provided by law for
the payment of the territorial legislature.

Sec. 14. That the two sections of land in each township herein
granted for the support of common schools shall be disposed of only
at public sale and at a price not less than two dollars and fifty cents
per acre, the proceeds to constitute a permanent school fund, the
interest of which to be expended in the support of common schools.

Sec. 15. That all mineral lands shall be excepted from the operation
and grants of this act.

Approved March 3, 1875.

An Act to amend the Act entitled “An Act to enable the people of
Colorado to form a constitution and State government, and for
the admission of said State into the Union on an equal footing
with the original States,” approved March 3, 1875.

Be it enacted by the Senate and House of Representatives of the


United States of America in Congress assembled, That so much of
section three of the act entitled “An act to enable the people of
Colorado to form a constitution and State government, and for the
admission of the said State into the Union on an equal footing with
the original States” approved March third, eighteen hundred and
seventy-five, as reads “and also to vote upon the acceptance or
rejection of such constitution as may be formed by said convention”
be amended so as to read as follows: “And all who are qualified
voters of said Territory under the laws thereof at such time as the
constitution to be framed shall be submitted to the people for
ratification or rejection shall be entitled to vote upon the question of
such ratification or rejection.”

Sec. 2. That section thirteen of said act be amended by adding at the


end of said section thirteen the following: “And if the balance of said
legislative appropriations does not amount to the sum of twenty
thousand dollars, then there shall be, and there hereby is,
appropriated, out of any money in the treasury not otherwise
appropriated, a sum sufficient, with the said unexpended
appropriations, to make the sum of twenty thousand dollars, which
shall be used for the purposes aforesaid: Provided, That any money
hereby appropriated not necessary for such purposes shall be
covered into the Treasury of the United States.”

Approved March 3, 1876.

Under this Act delegates to frame a constitution were duly elected.


They met in convention in December, 1875, and continued their
session to March 13th, 1876, when the convention adjourned sine
die.
CHAPTER V.

CONSTITUTION.

PREAMBLE.

We, the people of Colorado, with profound reverence for the


Supreme Ruler of the Universe, in order to form a more independent
and perfect government; establish justice; insure tranquility; provide
for the common defense; promote the general welfare and secure
the blessings of liberty to ourselves and our posterity, do ordain and
establish this Constitution for the “State of Colorado.”

ARTICLE I.

BOUNDARIES.

The boundaries of the State of Colorado shall be as follows:


Commencing on the thirty-seventh parallel of north latitude, where
the twenty-fifth meridian of longitude west from Washington crosses
the same; thence north on said meridian to the forty-first parallel of
north latitude; thence along said parallel west to the thirty-second
meridian of longitude west from Washington; thence south on said
meridian to the thirty-seventh parallel of north latitude; thence along
said thirty-seventh parallel of north latitude to the place of
beginning.
ARTICLE II.

BILL OF RIGHTS.

In order to assert our rights, acknowledge our duties, and proclaim


the principles upon which our government is founded, we declare:

Section 1. That all political power is vested in and derived from the
people; that all government, of right, originates from the people, is
founded upon their will only, and is instituted solely for the good of
the whole.

Sec. 2. That the people of this State have the sole and exclusive right
of governing themselves, as a free, sovereign and independent
State; and to alter and abolish their constitution and form of
government whenever they may deem it necessary to their safety
and happiness, provided such change be not repugnant to the
Constitution of the United States.

Sec. 3. That all persons have certain natural, essential and


inalienable rights, among which may be reckoned the right of
enjoying and defending their lives and liberties; that of acquiring,
possessing and protecting property; and of seeking and obtaining
their safety and happiness.

Sec. 4. That the free exercise and enjoyment of religious profession


and worship, without discrimination, shall forever hereafter be
guaranteed; and no person shall be denied any civil or political right,
privilege, or capacity, on account of his opinions concerning religion;
but the liberty of conscience hereby secured shall not be construed
to dispense with oaths or affirmations, excuse acts of licentiousness,
or justify practices inconsistent with the good order, peace, or safety
of the State. No person shall be required to attend or support any
ministry or place of worship, religious sect, or denomination against
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like