Foundations of Quantum Programming
Mingsheng Ying
University of Technology Sydney, Australia Institute of Software, Chinese Academy of Sciences
Tsinghua University, China
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
How to program quantum computers?
I Quantum algorithms:
Deutsch-Josza, Grover, Shor, HHL, ...
Quantum algorithm zoo (http://math.nist.gov/quantum/zoo/)
I Quantum computers:
Google (53 qubits —quantum supremacy— 2019) IBM Q (50 qubits — 2018)
Intel, Rigetti, IonQ, ...
How to program quantum computers?
I Quantum algorithms:
Deutsch-Josza, Grover, Shor, HHL, ...
Quantum algorithm zoo (http://math.nist.gov/quantum/zoo/)
I Quantum computers:
Google (53 qubits —quantum supremacy— 2019) IBM Q (50 qubits — 2018)
Intel, Rigetti, IonQ, ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
Quantum programming platforms
I Q# @Microsoft
I Cirq @Google
I Qiskit @IBM
I Quil @Riggeti
I Quipper @Dalhousie
I isQ @Institute of Software, Chinese Academy of Sciences
I ...
This lecture
I Principlesunderlyingallof the quantum programming languages
I Notthe languages themselves.
I Reference:
M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.
This lecture
I Principlesunderlyingallof the quantum programming languages
I Notthe languages themselves.
I Reference:
M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.
This lecture
I Principlesunderlyingallof the quantum programming languages
I Notthe languages themselves.
I Reference:
M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Programming languages and tools
Programming languages are notations used forspecifying,organising andreasoningabout computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?
I Compilers
I Program test, debugging, analysis
I How to verify correctness of your programs?
I ...
Quantum circuits vs Quantum programs
Example:Quantum walk on a circle with an absorbing boundary.
I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.
I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with
orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.
I The state space of the walk — H =Hp⊗Hd.
I The initial state —|0ip|Lid.
Quantum circuits vs Quantum programs
Example:Quantum walk on a circle with an absorbing boundary.
I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.
I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with
orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.
I The state space of the walk — H =Hp⊗Hd.
I The initial state —|0ip|Lid.
Quantum circuits vs Quantum programs
Example:Quantum walk on a circle with an absorbing boundary.
I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.
I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with
orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.
I The state space of the walk — H =Hp⊗Hd.
I The initial state —|0ip|Lid.
Quantum circuits vs Quantum programs
Example:Quantum walk on a circle with an absorbing boundary.
I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.
I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with
orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.
I The state space of the walk — H =Hp⊗Hd.
I The initial state —|0ip|Lid.
Quantum circuits vs Quantum programs
I Each step of the walk:
1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:
M = {Myes= |1ih1| ⊗Id, Mno =I−Myes};
2. A “coin-tossing”operator C= √1
2
1 1
1 −1
is applied on the direction space;
3. A shift operator
S=
n−1
∑
i=0
|i 1ihi| ⊗ |LihL| +
n−1
∑
i=0
|i⊕1ihi| ⊗ |RihR|
is performed on the state space H.
I Question:How to specify it in the circuit language?
Quantum circuits vs Quantum programs
I Each step of the walk:
1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:
M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};
2. A “coin-tossing”operator C= √1
2
1 1
1 −1
is applied on the direction space;
3. A shift operator
S=
n−1
∑
i=0
|i 1ihi| ⊗ |LihL| +
n−1
∑
i=0
|i⊕1ihi| ⊗ |RihR|
is performed on the state space H.
I Question:How to specify it in the circuit language?
Quantum circuits vs Quantum programs
I Each step of the walk:
1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:
M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};
2. A “coin-tossing”operator C= √1
2
1 1
1 −1
is applied on the direction space;
3. A shift operator
S=
n−1
∑
i=0
|i 1ihi| ⊗ |LihL| +
n−1
∑
i=0
|i⊕1ihi| ⊗ |RihR|
is performed on the state space H.
I Question:How to specify it in the circuit language?
Quantum circuits vs Quantum programs
I Each step of the walk:
1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:
M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};
2. A “coin-tossing”operator C= √1
2
1 1
1 −1
is applied on the direction space;
3. A shift operator
S=
n−1
∑
i=0
|i 1ihi| ⊗ |LihL| +
n−1
∑
i=0
|i⊕1ihi| ⊗ |RihR|
is performed on the state space H.
I Question:How to specify it in the circuit language?
Quantum circuits vs Quantum programs
I Each step of the walk:
1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:
M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};
2. A “coin-tossing”operator C= √1
2
1 1
1 −1
is applied on the direction space;
3. A shift operator
S=
n−1
∑
i=0
|i 1ihi| ⊗ |LihL| +
n−1
∑
i=0
|i⊕1ihi| ⊗ |RihR|
is performed on the state space H.
I Question:How to specify it in the circuit language?
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
Classical while-Language
S ::= skip|u :=t|S1; S2|if b then S1else S2fi
|while b do S od.
I Conditional statement can be generalised to case statement:
if G1→S1
G2→S2
...
Gn →Sn
fi or more compactly:
if(i·Gi→Si)fi
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....
I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.
Boolean= H2(2−dimensional), integer= H∞=
( ∞
n=−
∑
∞αn|ni:
∑
∞ n=−∞|αn|2<∞ )
.
I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:
Hq=
n O i=1
Hqi.
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....
I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.
Boolean= H2(2−dimensional), integer= H∞=
( ∞
n=−
∑
∞αn|ni:
∑
∞ n=−∞|αn|2<∞ )
.
I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:
Hq=
n O i=1
Hqi.
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....
I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.
Boolean= H2(2−dimensional), integer= H∞=
( ∞
n=−
∑
∞αn|ni:
∑
∞ n=−∞|αn|2<∞ )
.
I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:
Hq=
n O i=1
Hqi.
Syntax of Quantum Programs
S ::= skip|q := |0i |q :=U[q] |S1; S2
|if(m·M[q] =m→Sm)fi
|while M[q] =1 do S od.
Exercise 1
Write quantum walk as a program in quantum while-language.
Syntax of Quantum Programs
S ::= skip|q := |0i |q :=U[q] |S1; S2
|if(m·M[q] =m→Sm)fi
|while M[q] =1 do S od.
Exercise 1
Write quantum walk as a program in quantum while-language.
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables: Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables: Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Notations
I partial density operator: positive operator ρ, tr(ρ) ≤1.
I D(H)— the set of partial density operators inH.
I State Hilbert space of all quantum variables:
Hall = O
q∈Var
Hq.
I ↓— empty program; i.e. termination.
I Configuration: pairhS, ρi, where:
1. S is a quantum program or the empty program↓;
2. ρ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:
hS, ρi → hS0, ρ0i
Operational Semantics
(SK)
hskip, ρi → h↓, ρi
(IN)
hq := |0i, ρi → h↓, ρq0i
where : ρq0=
∑
i
|0iqhi|ρ|iiqh0| (UT)
hq :=U[q], ρi → h↓, UρU†i
(SC) hS1, ρi → hS10, ρ0i hS1; S2, ρi → hS10; S2, ρ0i
where : ↓; S2=S2.
Operational Semantics
(IF)
hif(m·M[q] =m→Sm)fi, ρi → hSm, MmρM†mi
for each possible outcome m of measurement M= {Mm}.
(L0)
hwhile M[q] =1 do S od, ρi → h↓, M0ρM†0i
(L1)
hwhile M[q] =1 do S od, ρi → hS; while M[q] =1 do S od, M1ρM†1i
Computation of Programs
1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):
hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...
such that ρn , 0 for all n (except the last n in the case of a finite sequence).
2. If this sequence cannot be extended, it is called acomputation.
I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.
I If it is infinite, we say it diverges.
Computation of Programs
1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):
hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...
such that ρn , 0 for all n (except the last n in the case of a finite sequence).
2. If this sequence cannot be extended, it is called acomputation.
I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.
I If it is infinite, we say it diverges.
Computation of Programs
1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):
hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...
such that ρn , 0 for all n (except the last n in the case of a finite sequence).
2. If this sequence cannot be extended, it is called acomputation.
I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.
I If it is infinite, we say it diverges.
Computation of Programs
1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):
hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...
such that ρn , 0 for all n (except the last n in the case of a finite sequence).
2. If this sequence cannot be extended, it is called acomputation.
I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.
I If it is infinite, we say it diverges.
Notation
I
hS, ρi →n hS0, ρ0i
if there are configurationshS1, ρ1i, ...,hSn−1, ρn−1isuch that hS, ρi → hS1, ρ1i →...→ hSn−1, ρn−1i → hS0, ρ0i,
I →∗for the reflexive and transitive closures of→: hS, ρi →∗ hS0, ρ0i
if and only ifhS, ρi →n hS0, ρ0ifor some n≥0.
Notation
I
hS, ρi →n hS0, ρ0i
if there are configurationshS1, ρ1i, ...,hSn−1, ρn−1isuch that hS, ρi → hS1, ρ1i →...→ hSn−1, ρn−1i → hS0, ρ0i,
I →∗for the reflexive and transitive closures of→: hS, ρi →∗ hS0, ρ0i
if and only ifhS, ρi →n hS0, ρ0ifor some n≥0.
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
Semantic Function
Semantic function of program S:
~S :D(Hall) → D(Hall)
~S(ρ) =
∑
|ρ0 :hS, ρi →∗ h↓, ρ0i|Exercise 2
Try to compute semantic function of your quantum walk program.
Semantic Function
Semantic function of program S:
~S :D(Hall) → D(Hall)
~S(ρ) =
∑
|ρ0 :hS, ρi →∗ h↓, ρ0i|Exercise 2
Try to compute semantic function of your quantum walk program.
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU†.
4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m). 6. ~while M[q] =1 do S od(ρ) = ???
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|.
3. ~q :=U[q](ρ) =UρU†. 4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m). 6. ~while M[q] =1 do S od(ρ) = ???
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU†.
4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m). 6. ~while M[q] =1 do S od(ρ) = ???
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU†.
4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m). 6. ~while M[q] =1 do S od(ρ) = ???
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU†.
4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m).
6. ~while M[q] =1 do S od(ρ) = ???
Structural Representation
1. ~skip(ρ) =ρ.
2. ~q := |0i(ρ) =∑i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU†.
4. ~S1; S2(ρ) =~S2(~S1(ρ)).
5. ~if(m·M[q] =m→Sm)fi(ρ) =∑m~Sm(MmρM†m). 6. ~while M[q] =1 do S od(ρ) = ???
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L; 3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L; 3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:
1. Reflexivity: xvx for all x∈L;
2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;
3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.
I x∈L is called theleast elementwhen xvy for all y∈L.
I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.
I x is called the least upper bound of X, written x=FX, if
I x is an upper bound of X;
I for any upper bound y of X, xvy.
Basic Lattice Theory
I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does
X) for any X⊆L.
I Acomplete partial order(CPO) is a partial order(L,v):
1. it has the least element 0;
2. F∞n=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....
Basic Lattice Theory
I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does
X) for any X⊆L.
I Acomplete partial order(CPO) is a partial order(L,v):
1. it has the least element 0;
2. F∞n=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....
Basic Lattice Theory
I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does
X) for any X⊆L.
I Acomplete partial order(CPO) is a partial order(L,v): 1. it has the least element 0;
2. F∞n=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....
Basic Lattice Theory
I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does
X) for any X⊆L.
I Acomplete partial order(CPO) is a partial order(L,v): 1. it has the least element 0;
2. F∞n=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....
Basic Lattice Theory
I A function f from L into itself is
I monotoneif:
xvy⇒f(x) vf(y);
I continuousif:
f G
n
xn
!
=G
n
f(xn) for any increasing sequence{xn}in L.
Basic Lattice Theory
I A function f from L into itself is
I monotoneif:
xvy⇒f(x) vf(y);
I continuousif:
f G
n
xn
!
=G
n
f(xn) for any increasing sequence{xn}in L.
Basic Lattice Theory
I A function f from L into itself is
I monotoneif:
xvy⇒f(x) vf(y);
I continuousif:
f G
n
xn
!
=G
n
f(xn) for any increasing sequence{xn}in L.
Tarski Fixed Point Theorem
I If(L,v)is a complete lattice and function f : L→L monotone, then f has a fixed point.
I Let(L,v)be a CPO and function f : L→L continuous. Then f has the least fixed point
µf = G∞
n=0
f(n)(0)
where f(0)(0) =0 and f(n+1)(0) =f(f(n)(0))for n≥0.
Exercise 3
Use Tarski fixed point theorem to proveSchröder-Bernstein theorem: if f : X→Y and g : Y→X are one-to-one mappings, then there is a bijection between X and Y.
Tarski Fixed Point Theorem
I If(L,v)is a complete lattice and function f : L→L monotone, then f has a fixed point.
I Let(L,v)be a CPO and function f : L→L continuous. Then f has the least fixed point
µf = G∞
n=0
f(n)(0)
where f(0)(0) =0 and f(n+1)(0) =f(f(n)(0))for n≥0.
Exercise 3
Use Tarski fixed point theorem to proveSchröder-Bernstein theorem:
if f : X→Y and g : Y→X are one-to-one mappings, then there is a bijection between X and Y.
CPO of Partial Density Operators
I Löwner order: operators AvB⇔B−A is positive.
I (D(H),v)is a CPO with the zero operator 0Has its least element.
Exercise 4
Prove the above statement forfinite-dimensionalH.
CPO of Partial Density Operators
I Löwner order: operators AvB⇔B−A is positive.
I (D(H),v)is a CPO with the zero operator 0Has its least element.
Exercise 4
Prove the above statement forfinite-dimensionalH.
CPO of Super-operators
I Each super-operator inHis a continuous function from (D(H),v)into itself.
I QO(H)— the set of superoperators in Hilbert spaceH.
I Löwner order between operators can be lifted to a partial order between super-operators:
E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)
I (QO(H),v)is a CPO.
CPO of Super-operators
I Each super-operator inHis a continuous function from (D(H),v)into itself.
I QO(H)— the set of superoperators in Hilbert spaceH.
I Löwner order between operators can be lifted to a partial order between super-operators:
E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)
I (QO(H),v)is a CPO.
CPO of Super-operators
I Each super-operator inHis a continuous function from (D(H),v)into itself.
I QO(H)— the set of superoperators in Hilbert spaceH.
I Löwner order between operators can be lifted to a partial order between super-operators:
E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)
I (QO(H),v)is a CPO.
CPO of Super-operators
I Each super-operator inHis a continuous function from (D(H),v)into itself.
I QO(H)— the set of superoperators in Hilbert spaceH.
I Löwner order between operators can be lifted to a partial order between super-operators:
E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)
I (QO(H),v)is a CPO.
Syntactic Approximation
I abortdenotes a program such that
~abort(ρ) =0Hallfor all ρ∈ D(H).
I Write:
while≡while M[q] =1 do S od.
I For integer k≥0, the kth syntactic approximation while(k)of while:
while(0) ≡ abort,
while(k+1) ≡ if M[q] =0→skip
1→S; while(k) fi
Syntactic Approximation
I abortdenotes a program such that
~abort(ρ) =0Hallfor all ρ∈ D(H).
I Write:
while≡while M[q] =1 do S od.
I For integer k≥0, the kth syntactic approximation while(k)of while:
while(0) ≡ abort,
while(k+1) ≡ if M[q] =0→skip
1→S; while(k) fi
Syntactic Approximation
I abortdenotes a program such that
~abort(ρ) =0Hallfor all ρ∈ D(H).
I Write:
while≡while M[q] =1 do S od.
I For integer k≥0, the kth syntactic approximation while(k)of while:
while(0) ≡ abort,
while(k+1) ≡ if M[q] =0→skip
1→S; while(k) fi
Semantic Function of Loops
while
= G∞
k=0
while(k) ,
whereFstands for the least upper bound in CPO(QO (Hall),v).
Fixed Point Characterisation
For any ρ∈ D(Hall):
~while(ρ) =M0ρM†0+~while~SM1ρM1†
.
Exercise 5
Prove the above equality.
Semantic Function of Loops
while
= G∞
k=0
while(k) ,
whereFstands for the least upper bound in CPO(QO (Hall),v).
Fixed Point Characterisation
For any ρ∈ D(Hall):
~while(ρ) =M0ρM†0+~while~SM1ρM1†
.
Exercise 5
Prove the above equality.
Semantic Function of Loops
while
= G∞
k=0
while(k) ,
whereFstands for the least upper bound in CPO(QO (Hall),v).
Fixed Point Characterisation
For any ρ∈ D(Hall):
~while(ρ) =M0ρM†0+~while~SM1ρM1†
.
Exercise 5
Prove the above equality.
Termination and Divergence Probabilities
I For any quantum program S and ρ∈ D(Hall): tr(~S(ρ)) ≤tr(ρ).
I tr(~S(ρ))is the probability that program S with input ρ terminates.
Termination and Divergence Probabilities
I For any quantum program S and ρ∈ D(Hall): tr(~S(ρ)) ≤tr(ρ).
I tr(~S(ρ))is the probability that program S with input ρ terminates.
Outline
Introduction
Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems
Quantum predicates = Quantum effects
I Aquantum effectis a (Hermitian) operator 0vMvI; that is, 0≤tr(Mρ) ≤1 for all density operators.
I tr(Mρ)may be interpreted as the expected degree to which quantum state ρ satisfies quantum predicate M.
Quantum predicates = Quantum effects
I Aquantum effectis a (Hermitian) operator 0vMvI; that is, 0≤tr(Mρ) ≤1 for all density operators.
I tr(Mρ)may be interpreted as the expected degree to which quantum state ρ satisfies quantum predicate M.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Correctness Formulas
I A correctness formula (Hoare triple) is a statement of the form:
{P}S{Q} where:
I S is a quantum program;
I P, Q are quantum predicates inHall.
I P is called the precondition, Q the postcondition.
Partial Correctness, Total Correctness
I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.
Partial Correctness, Total Correctness (Continued)
I The correctness formula{P}S{Q}is true in the sense of total correctness, written
|=tot{P}S{Q}, if:
tr(Pρ) ≤tr(Q~S(ρ))
for all ρ∈ D(Hall), where ~S is the semantic function of S.
I The correctness formula{P}S{Q}is true in the sense of partial correctness, written
|=par{P}S{Q}, if:
tr(Pρ) ≤tr(Q~S(ρ)) + [tr(ρ) −tr(~S(ρ))] for all ρ∈ D(Hall).
Partial Correctness, Total Correctness (Continued)
I The correctness formula{P}S{Q}is true in the sense of total correctness, written
|=tot{P}S{Q}, if:
tr(Pρ) ≤tr(Q~S(ρ))
for all ρ∈ D(Hall), where ~S is the semantic function of S.
I The correctness formula{P}S{Q}is true in the sense of partial correctness, written
|=par {P}S{Q}, if:
tr(Pρ) ≤tr(Q~S(ρ)) + [tr(ρ) −tr(~S(ρ))]
for all ρ∈ D(Hall).
Proof System for Partial Correctness
(Ax−Sk) {P}Skip{P} (Ax−In)If type(q) =Boolean, then
{|0iqh0|P|0iqh0| + |1iqh0|P|0iqh1|}q := |0i{P}
If type(q) =integer, then
( ∞
n=−∞
∑
|niqh0|P|0iqhn| )
q := |0i{P}
(Ax−UT) {U†PU}q :=Uq{P}
Proof System for Partial Correctness (Continued)
(R−SC) {P}S1{Q} {Q}S2{R} {P}S1; S2{R}
(R−IF) {Pm}Sm{Q}for all m
∑mM†mPmMm if(m·M[q] =m→Sm)fi{Q}
(R−LP) {Q}SM†0PM0+M†1QM1
{M†0PM0+M†1QM1}while M[q] =1 do S od{P}
(R−Or) PvP0 {P0}S{Q0} Q0vQ {P}S{Q}
Soundness Theorem
For any quantum while-program S and quantum predicates P, Q∈ P (Hall):
`qPD{P}S{Q}implies |=par {P}S{Q}.
Exercise 6
Prove soundness theorem.
(Relative) Completeness Theorem
For any quantum while-program S and quantum predicates P, Q∈ P (Hall):
|=par{P}S{Q}implies `qPD{P}S{Q}.
Soundness Theorem
For any quantum while-program S and quantum predicates P, Q∈ P (Hall):
`qPD{P}S{Q}implies |=par {P}S{Q}.
Exercise 6
Prove soundness theorem.
(Relative) Completeness Theorem
For any quantum while-program S and quantum predicates P, Q∈ P (Hall):
|=par{P}S{Q}implies `qPD{P}S{Q}.