COMP90084 Quantum Software Fundamentals
Prerequisites 1. Complex Numbers
- can also be represented as
, where is the real part and is the imaginary part - commutative 可交换的:
- associative 结合的:
- distributive 分配的:
- addition:
- let
- then
- let
- multiplication:
- let
- then
- let
- subtraction:
- division:
- let
- then
- then
- then
- let
- modulus:
- algebraically complete: any polynomial equation has a solution in such a field 所有的代数方程的解都在这个域中
实数不是 复数是
- conjugate:
- if
- if
- field isopmorphism: a bijective homomorphism between two fields
- bijection: one-to-one and onto 单射和满射
- 每一个输入值都有正好一个输出值以及每一个输出值都有正好一个输入值
- parallelogram law 平行四边形定律
- 向量相加
- polar/Catesian representation
- 极坐标系
Prequisites 2. Vector Spaces
addition:
- let
- then
- commutative:
- associative:
- let
inverse:
Abelian group 阿贝尔群: addition, inverse, associative, commutative
scalar: an abitrarily complex number
multiply an element by a scalar:
transpose 转置:
conjugate 共轭,复数相反,实数不变:
adjoint/dagger 伴随,转置+共轭:
matrix multiplication:
isomorphism 同构,双射(双向一一对应)
- 可以认为两个空间性质相同,仅命名不同
linear independence 线性无关
- linear combination:
- 一组向量的线性组合不等于0
only when- basis: a set of linearly independent vectors that span the space
- canonical/standard basis: a set of vectors with one 1 and the rest are 0
- dimension: the number of vectors in the basis
- linear combination:
trace: sum of the diagonal elements
eigenvalue and eigenvector 特征值和特征向量
- for a matrix
, if , then is the eigenvalue and is the eigenvector
- for a matrix
symmetric matrix 对称矩阵
hermitian matrix 共轭转置矩阵
invertible matrix 可逆矩阵
unitary matrix 幺正矩阵
tensor product 张量积
orthogonal:
- for two vectors
- if
, then and are orthogonal
- for two vectors
normalised:
Bra-ket Notation
also called Dirac notation
linear algebra in complex vector space
ket 表示量子态向量,通常用于描述系统的状态:
bra 表示量子态向量的共轭转置(Hermitian 共轭),用于内积计算:
inner product:
- "bracket"
- also called dot product/scalar product
- result in a scalar
outer product:
- result in a matrix
- 量子比特的旋转可以表示为一个向量在复平面上的旋转
- 旋转操作可以用幺正矩阵(如 Pauli 矩阵和旋转矩阵)来表示
- 这些矩阵可以通过指数映射(如 e 的幺正矩阵次方)来生成
Kets Algebra
1. Linear Algebra to Quantum Computing
- 为什么学?
- 解决经典计算机无法解决的问题
- 对于量子纠错可能性的乐观主义
- 这是什么?
- 基于量子力学的计算机学说
- 量子化学,量子深度学习
- 后量子密码学
- Physical Qubits:
- Particles with polarization(photon) 光子
- Trapped ions 离子阱
- Cold Atoms 冷原子
- Quantum dots 量子点
- Using Defect in Crystals 晶体缺陷
- Superconductors 超导体
- Major Players
- IBM, Google, Microsoft
- D-Wave, uses Quantum annealing to solve optimization problems
- Model of Quantum Computer
- Input
- Quantum Processor on Cloud
- Prepare a state
- Apply gates
- Measure
- Output: the probability distribution of the measurement
2. Classical to Quantum Systems and Basic Quantum Theory
Quantum Dynamics 量子动力学
- 时间演化算符
- 薛定谔方程
- 哈密顿量
- 态的演化
- 量子态的叠加
- 量子测量
the state
is a superposition of basic state- being simultaneously in all states
- detect the state with probability
- when observed, it will collapse to one of the basic states
時間反演對稱
模不变
- 量子态的模的表示:
和 的模相等
- 量子态的模的表示:
设
是一个可观测量, 是一个量子态。如果测量的结果是特征值 ,则测量后的量子态将始终是对应于 的特征向量superposition 叠加:
and are complex amplitudes 复振幅- an arbitrary state can be represented as a linear combination of basis states
spin 自旋
- prototypical way to implement quantum bits of information, or qubits
- clockwise/anticlockwise
transition amplitude 转移振幅
- inner product
- determine how likely a start state will change to an end state (after measurement)
entanglement 纠缠
- connect two qubits using a gate
Bell state
- 量子比特间的强纠缠关系
- 两个量子比特要么都在状态
,要么都在状态 ,且这两种情况的概率相等 - 最大纠缠态,两个量子比特的状态之间没有相位差,量子态无法分解成两个量子态的直积
- 两个量子比特要么都在状态
- 两个量子比特的状态之间存在一个相位差
3. Qubits and Quantum Gates
qubit pair:
orclassical gates
- NOT: filp 0 to 1, 1 to 0
- AND: 1 if both are 1
- OR: 1 if either is 1
- NAND: 0 if both are 1
- NOT
AND
- NOT
- XOR: 1 if either is 1, but not both
- NOT
OR
- NOT
- NOT: filp 0 to 1, 1 to 0
Jyā, koti-jyā and utkrama-jyā 印度的三角函数
bloch sphere 布洛赫球: 用于表示量子比特状态的几何图形
- X, Y axis:
- Z axis:
- X, Y axis:
Pauli X,Y,Z
- 沿 X 轴旋转 180 度
- X is also called NOT gate
- eigenvalues: 1 and -1
- eigenvectors:
- left
- right
- left
- 沿 Y 轴旋转 180 度
- Y is also called bit-flip gate
转换为 ,或者从 转换为- eigenvalues: 1 and -1
- eigenvectors:
- in
- out
- in
- 沿 Z 轴旋转 180 度
- Z is also called phase-flip gate
- 从
转换为 - eigenvalues: 1 and -1
- eigenvectors:
- up
- down
- up
phase shift gate:
S: 添加一个
的相位T: 添加一个
的相位Hadamard gate
- 制备叠加态
CNOT
- control qubit, target qubit
- if control qubit is 1, then target qubit is flipped
control-U gates
- if control qubit is 1, then apply U on target qubit
Deutch gate:
- if both control qubits are 1, then apply a phase shift on target
Toffoli gate: 3 qubits, 2 control and 1 target
- if both control qubits are 1, then the target qubit is flipped
Fredkin gate: 3 qubits, 1 control and 2 target
- if the control qubit is 1, then the target qubits are swapped
all Quantum gates are reversible
4. Quantum Circuits
n Hadamand gates:
reversible function execution:
- control:
--> --> - target:
--> -->
- control:
simple circuit
- CNOT: dot +
- CZ: dot dot
- SWAP: xx
- unitary: box U
no-cloning theorem: cannot copy an arbitrary unknown quantum state
- 证明:假设可以复制,那么可以通过两个相同的量子比特,得到一个新的固定的量子比特。但这是不可能的
teleportation
- 克隆是在不破坏原本的量子比特的情况下复制一个量子比特
- 传输是将一个量子比特的状态从一个量子比特传输到另一个量子比特,原本的量子态会被破坏
- take
in first system and nothing in second system, then teleport to second system
superdense coding
- teleportation in reverse
quantum parallelism: exponential numbers were inputted simultaneously, result was given in next clock, by quantum function
given a quantum representation, only one result can be given, not all solutions
the point is: what algorithm can take advantage of quantum mechanism?
5. NP Problems, Simulated Annealing and QUBO
- quadratic unconstrained binary optimization 二次无约束二元优化
- quantum mechanics can solve combinatorial optimization problems
- finding optimal objects that satisfy a certain condition
- Knapsack problem
- given a set of items, each with a weight and a value
- determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible
- n items
is 1 if the item is included, 0 otherwise is the value of the item is the maximum weight- maximize
- subject to
- max-cut
- edges have weights
- find a cut that maximizes the sum of the weights of the edges that are cut
- minimum vetec cover
- find the minimum number of vertices that cover all edges
- simulated annealing 模拟退火
- a probabilistic technique for approximating the global optimum of a given function
- local search (Monte Carlo)
- find solution from neighbors
- Metropolis algorithm
- reproduce annealing process
is the energy of state- if
, change current state to state - if
, change current state to state with probability
- quadratic unconstrained binary optimization (QUBO)
- subject to
- Q is symmetric or upper triangular
- NP problem
6.1. Ising Hamiltonian and Quantum Adiabatic Annealing
- physical system generates optimal solution
- map optimization problem to physical system ... cool the system to zero ... obtain the lowest energy state
- an observable is represented by Hermitian matrix ... its eigenvalues are the measured values ... diagonalize the matrix and eigenvalues are the diagonal elements
- Adiabatic theorem
- if a system is in the ground state of a Hamiltonian, and the Hamiltonian is slowly changed, then the system will remain in the ground state
6.2. QAOA
- quantum approximate optimization algorithm 量子近似优化算法
Tips
A gpt's explaination of QAOA:
量子近似优化算法(Quantum Approximate Optimization Algorithm,QAOA)是一种混合量子经典算法,用于解决组合优化问题。QAOA 结合了量子计算的并行性和经典优化的灵活性,旨在找到近似最优解。以下是 QAOA 的高层次解释:
QAOA 的基本概念
QAOA 通过构造一个参数化的量子电路来近似求解组合优化问题。该算法的核心思想是通过调整参数,使得量子电路生成的量子态在测量后能够提供优化问题的近似最优解。
QAOA 的步骤
问题表示:
- 将组合优化问题表示为一个二次无约束二进制优化(QUBO)问题或等价的 Ising 模型。
- 目标是找到一个二进制向量
,使得目标函数 最小化。
初始量子态:
- 准备一个初始量子态,通常是所有量子比特的均匀叠加态
,其中 是问题的变量数。
- 准备一个初始量子态,通常是所有量子比特的均匀叠加态
参数化量子电路:
- 构造一个参数化的量子电路,该电路由两个交替应用的单元组成:
- 成本哈密顿量演化:应用与目标函数
对应的成本哈密顿量 。 - 混合哈密顿量演化:应用混合哈密顿量
,通常是所有量子比特上的 Pauli-X 门的和。
- 成本哈密顿量演化:应用与目标函数
- 这些单元交替应用
次,形成一个深度为 的量子电路。每个单元的演化时间由参数 和 控制。
- 构造一个参数化的量子电路,该电路由两个交替应用的单元组成:
量子态演化:
- 初始量子态通过参数化量子电路演化,生成一个新的量子态:
- 其中
和 。
- 初始量子态通过参数化量子电路演化,生成一个新的量子态:
测量和优化:
- 对演化后的量子态进行测量,得到一个二进制向量
。 - 计算目标函数
的值。 - 使用经典优化算法调整参数
和 ,以最小化目标函数的期望值 。
- 对演化后的量子态进行测量,得到一个二进制向量
迭代:
- 重复量子态演化、测量和参数优化的过程,直到找到近似最优解。
QAOA 的优点
- 并行性:利用量子计算的并行性,可以同时探索多个解空间。
- 灵活性:通过调整参数,可以适应不同的优化问题。
- 近似最优解:即使在量子计算资源有限的情况下,QAOA 也能找到高质量的近似解。
QAOA 的应用
QAOA 可以应用于各种组合优化问题,包括但不限于:
- 最大割问题(Max-Cut)
- 旅行商问题(TSP)
- 图着色问题
- 集合覆盖问题
- 资源分配问题
7.1. Quantum Key Distribution
- Alice and Bob agree in advance a set with two different basis, say the z-basis or the x-basis
- Alice sends encoded qubits to Bob using random basis each time
- Bob measures these qubits using random basis
- A qubit sent and received correctly if the basis match. They use this fact to arrive at common correctly received bits
- But how do they discover correct matching?
- They can announce the basis after the process, they determine which positions of the key has same basis.
- How do they know Eve has not read?
- They can compare on a subset of qubits, if their recovered bits are same in all bits in the subset then can conclude that Eve was not there. They can use the rest of bits as a shared key.
7.2. Quantum Fourier Transform
- DFT (Discrete Fourier Transform)
- map vectors from time domain to frequency domain
- periodic function
8. RSA and Shor Algorithms
story of cryptography
- Alice, Eve, Bob
operators:
,modular inverse
- if
, then is the modular inverse of usually denoted as
- if
Euler's totient function / Euler's phi function
- a,b are relatively prime if
is the number of positive integers less than n that are relatively prime to n- reduced set of residues is a set that contains all numbers less than n that are relatively prime to n
, where p is a prime number , where p and q are prime numbers
- a,b are relatively prime if
RSA PKC
- Ron Rivest, Adi Shamir, Leonard Adleman public key cryptography
- utilize modular exponentiation
- parameter set
, where and are large prime numbers is a random number , where called Euler's totient function 同余,在模下相等- public:
- Alice:
- Bob:
- 证明如果
,则- 费马小定理/欧拉定理: 如果x,n互质,则
- 证明1:
, 当p是质数,a不是p的倍数时成立。因为两边的p-1个数里都有p-1种可能的余数,两边实际等价的 - 证明2:
,展开后,除了第一项,其他项都是 的倍数,所以等于1
- 证明1:
period of modular exponentiation
- example:
x 0 1 2 3 4 5 6 7 8 f 1 2 4 8 1 2 4 8 1 bit needed to represent
in binary- because
Shor's algorithm
- use quantum circuit to find period of big N
- let
, be the input strings, where and - input:
- pass through m Hadamard gates
: - pass through unitary operator
: - the bottom n qubits store the superposition of many states
, measure and collapse: - apply quantum Fourier transform (QFT) on the top m qubits to generate answer: r
9. Quantum Machine Learning
...