foundations of quantum programming - tsinghua...
TRANSCRIPT
![Page 1: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/1.jpg)
Foundations of Quantum Programming
Mingsheng Ying
University of Technology Sydney, AustraliaInstitute of Software, Chinese Academy of Sciences
Tsinghua University, China
![Page 2: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/2.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 3: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/3.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 4: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/4.jpg)
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:
IBM Q (20 qubits — Nov 2017; 50 qubits — 2018)
Google (49 qubits — 2018)
Intel (17 qubits — Oct 2017)
![Page 5: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/5.jpg)
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:
IBM Q (20 qubits — Nov 2017; 50 qubits — 2018)
Google (49 qubits — 2018)
Intel (17 qubits — Oct 2017)
![Page 6: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/6.jpg)
Quantum programming languages
I Q# @Microsoft
I Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 7: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/7.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @Google
I Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 8: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/8.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @Riggeti
I Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 9: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/9.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @Dalhousie
I Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 10: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/10.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @Princeton
I Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 11: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/11.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETH
I QWire @UPennI Q|SI> @UTS
![Page 12: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/12.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPenn
I Q|SI> @UTS
![Page 13: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/13.jpg)
Quantum programming languages
I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS
![Page 14: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/14.jpg)
This lectureI Principles underlying all of the quantum programming
languages
I Not the languages themselves.
I Reference:M. S. Ying, Foundations of Quantum Programming, MorganKaufmann 2016, Chapters 3 and 4.
![Page 15: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/15.jpg)
This lectureI Principles underlying all of the quantum programming
languagesI Not the languages themselves.
I Reference:M. S. Ying, Foundations of Quantum Programming, MorganKaufmann 2016, Chapters 3 and 4.
![Page 16: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/16.jpg)
This lectureI Principles underlying all of the quantum programming
languagesI Not the languages themselves.
I Reference:M. S. Ying, Foundations of Quantum Programming, MorganKaufmann 2016, Chapters 3 and 4.
![Page 17: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/17.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I Semantics
I Turing-complete?I ComiplersI Program analysis: Termination, ...I How to verify correctness of your programs?I ......
![Page 18: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/18.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I SemanticsI Turing-complete?
I ComiplersI Program analysis: Termination, ...I How to verify correctness of your programs?I ......
![Page 19: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/19.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I SemanticsI Turing-complete?I Comiplers
I Program analysis: Termination, ...I How to verify correctness of your programs?I ......
![Page 20: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/20.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I SemanticsI Turing-complete?I ComiplersI Program analysis: Termination, ...
I How to verify correctness of your programs?I ......
![Page 21: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/21.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I SemanticsI Turing-complete?I ComiplersI Program analysis: Termination, ...I How to verify correctness of your programs?
I ......
![Page 22: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/22.jpg)
Programming languages and tools
Programming languages are notations used for specifying, organisingand reasoning about computations.
[R. Sethi, Programming languages: Concepts and Constructs]
I SemanticsI Turing-complete?I ComiplersI Program analysis: Termination, ...I How to verify correctness of your programs?I ......
![Page 23: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/23.jpg)
Quantum circuit vs Quantum programs
Example: Quantum walk on a circle with an absorbing boundary.I Hd = span{|L〉, |R〉}— the direction space, |L〉 and |R〉 indicate
directions left and right, respectively.
I Hp = span{|0〉, |1〉, ..., |n− 1〉}— the position space withorthonormal basis states, the vector |i〉 denotes position i for each0 ≤ i ≤ n− 1.
I The state space of the walk — H = Hp ⊗Hd.I The initial state — |0〉p|L〉d.
![Page 24: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/24.jpg)
Quantum circuit vs Quantum programs
Example: Quantum walk on a circle with an absorbing boundary.I Hd = span{|L〉, |R〉}— the direction space, |L〉 and |R〉 indicate
directions left and right, respectively.I Hp = span{|0〉, |1〉, ..., |n− 1〉}— the position space with
orthonormal basis states, the vector |i〉 denotes position i for each0 ≤ i ≤ n− 1.
I The state space of the walk — H = Hp ⊗Hd.I The initial state — |0〉p|L〉d.
![Page 25: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/25.jpg)
Quantum circuit vs Quantum programs
Example: Quantum walk on a circle with an absorbing boundary.I Hd = span{|L〉, |R〉}— the direction space, |L〉 and |R〉 indicate
directions left and right, respectively.I Hp = span{|0〉, |1〉, ..., |n− 1〉}— the position space with
orthonormal basis states, the vector |i〉 denotes position i for each0 ≤ i ≤ n− 1.
I The state space of the walk — H = Hp ⊗Hd.
I The initial state — |0〉p|L〉d.
![Page 26: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/26.jpg)
Quantum circuit vs Quantum programs
Example: Quantum walk on a circle with an absorbing boundary.I Hd = span{|L〉, |R〉}— the direction space, |L〉 and |R〉 indicate
directions left and right, respectively.I Hp = span{|0〉, |1〉, ..., |n− 1〉}— the position space with
orthonormal basis states, the vector |i〉 denotes position i for each0 ≤ i ≤ n− 1.
I The state space of the walk — H = Hp ⊗Hd.I The initial state — |0〉p|L〉d.
![Page 27: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/27.jpg)
Quantum circuit vs Quantum programsI 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 = |1〉〈1| ⊗ Id, Mno = I−Myes};
2. A “coin-tossing”operator C = 1√2
(1 11 −1
)is applied on the
direction space;3. A shift operator
S =n−1
∑i=0|i 1〉〈i| ⊗ |L〉〈L|+
n−1
∑i=0|i⊕ 1〉〈i| ⊗ |R〉〈R|
is performed on the state space H.
I Question: How to specify it in the circuit language?
![Page 28: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/28.jpg)
Quantum circuit vs Quantum programsI 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 = |1〉〈1| ⊗ Id, Mno = I−Myes};
2. A “coin-tossing”operator C = 1√2
(1 11 −1
)is applied on the
direction space;3. A shift operator
S =n−1
∑i=0|i 1〉〈i| ⊗ |L〉〈L|+
n−1
∑i=0|i⊕ 1〉〈i| ⊗ |R〉〈R|
is performed on the state space H.
I Question: How to specify it in the circuit language?
![Page 29: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/29.jpg)
Quantum circuit vs Quantum programsI 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 = |1〉〈1| ⊗ Id, Mno = I−Myes};
2. A “coin-tossing”operator C = 1√2
(1 11 −1
)is applied on the
direction space;
3. A shift operator
S =n−1
∑i=0|i 1〉〈i| ⊗ |L〉〈L|+
n−1
∑i=0|i⊕ 1〉〈i| ⊗ |R〉〈R|
is performed on the state space H.
I Question: How to specify it in the circuit language?
![Page 30: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/30.jpg)
Quantum circuit vs Quantum programsI 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 = |1〉〈1| ⊗ Id, Mno = I−Myes};
2. A “coin-tossing”operator C = 1√2
(1 11 −1
)is applied on the
direction space;3. A shift operator
S =n−1
∑i=0|i 1〉〈i| ⊗ |L〉〈L|+
n−1
∑i=0|i⊕ 1〉〈i| ⊗ |R〉〈R|
is performed on the state space H.
I Question: How to specify it in the circuit language?
![Page 31: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/31.jpg)
Quantum circuit vs Quantum programsI 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 = |1〉〈1| ⊗ Id, Mno = I−Myes};
2. A “coin-tossing”operator C = 1√2
(1 11 −1
)is applied on the
direction space;3. A shift operator
S =n−1
∑i=0|i 1〉〈i| ⊗ |L〉〈L|+
n−1
∑i=0|i⊕ 1〉〈i| ⊗ |R〉〈R|
is performed on the state space H.
I Question: How to specify it in the circuit language?
![Page 32: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/32.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 33: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/33.jpg)
Classical while-Language
S ::= skip | u := t |S1; S2 | if b then S1 else S2 fi| 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
![Page 34: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/34.jpg)
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variablesq, q′, q0, q1, q2, ....
I Each quantum variable q ∈ Var has a typeHq (a Hilbert space),e.g.
Boolean = H2, integer = H∞.
I A quantum register is a finite sequence q = q1, ..., qn of distinctquantum variables. State Hilbert space:
Hq =n⊗
i=1
Hqi .
![Page 35: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/35.jpg)
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variablesq, q′, q0, q1, q2, ....
I Each quantum variable q ∈ Var has a typeHq (a Hilbert space),e.g.
Boolean = H2, integer = H∞.
I A quantum register is a finite sequence q = q1, ..., qn of distinctquantum variables. State Hilbert space:
Hq =n⊗
i=1
Hqi .
![Page 36: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/36.jpg)
Quantum while-Language
I Alphabet: a countably infinite set Var of quantum variablesq, q′, q0, q1, q2, ....
I Each quantum variable q ∈ Var has a typeHq (a Hilbert space),e.g.
Boolean = H2, integer = H∞.
I A quantum register is a finite sequence q = q1, ..., qn of distinctquantum variables. State Hilbert space:
Hq =n⊗
i=1
Hqi .
![Page 37: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/37.jpg)
Syntax of Quantum Programs
S ::= skip | q := |0〉 | q := U[q] | S1; S2
| if (�m ·M[q] = m→ Sm) fi| while M[q] = 1 do S od.
Exercise 1Write quantum walk as a program in quantum while-language.
![Page 38: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/38.jpg)
Syntax of Quantum Programs
S ::= skip | q := |0〉 | q := U[q] | S1; S2
| if (�m ·M[q] = m→ Sm) fi| while M[q] = 1 do S od.
Exercise 1Write quantum walk as a program in quantum while-language.
![Page 39: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/39.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 40: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/40.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 41: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/41.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 42: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/42.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 43: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/43.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.
I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 44: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/44.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 45: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/45.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;
2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.I Transition:
〈S, ρ〉 → 〈S′, ρ′〉
![Page 46: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/46.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 47: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/47.jpg)
NotationsI 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 =⊗
q∈VarHq.
I E — empty program; i.e. termination.I Configuration: pair 〈S, ρ〉, where:
1. S is a quantum program or the empty program E;2. ρ ∈ D(Hall), denoting the (global) state of quantum variables.
I Transition:〈S, ρ〉 → 〈S′, ρ′〉
![Page 48: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/48.jpg)
Operational Semantics
(SK) 〈skip, ρ〉 → 〈E, ρ〉
(IN)〈q := |0〉, ρ〉 → 〈E, ρ
q0〉
where : ρq0 = ∑
i|0〉q〈i|ρ|i〉q〈0|
(UT) 〈q := U[q], ρ〉 → 〈E, UρU†〉
(SC)〈S1, ρ〉 → 〈S′1, ρ′〉
〈S1; S2, ρ〉 → 〈S′1; S2, ρ′〉
where : E; S2 = S2.
![Page 49: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/49.jpg)
Operational Semantics
(IF)〈if (�m ·M[q] = m→ Sm) fi, ρ〉 → 〈Sm, MmρM†
m〉
for each possible outcome m of measurement M = {Mm}.
(L0)〈while M[q] = 1 do S od, ρ〉 → 〈E, M0ρM†
0〉
(L1)〈while M[q] = 1 do S od, ρ〉 → 〈S; while M[q] = 1 do S od, M1ρM†
1〉
![Page 50: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/50.jpg)
Computation of Programs
1. A (finite or infinite) transition sequence of program S with inputρ ∈ D(Hall):
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn, ρn〉 → 〈Sn+1, ρn+1〉 → ...
such that ρn , 0 for all n (except the last n in the case of a finitesequence).
2. If this sequence cannot be extended, it is called a computation.
I If it is finite and its last configuration is 〈E, ρ′〉, we say it terminatesin ρ′.
I If it is infinite, we say it diverges.
![Page 51: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/51.jpg)
Computation of Programs
1. A (finite or infinite) transition sequence of program S with inputρ ∈ D(Hall):
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn, ρn〉 → 〈Sn+1, ρn+1〉 → ...
such that ρn , 0 for all n (except the last n in the case of a finitesequence).
2. If this sequence cannot be extended, it is called a computation.
I If it is finite and its last configuration is 〈E, ρ′〉, we say it terminatesin ρ′.
I If it is infinite, we say it diverges.
![Page 52: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/52.jpg)
Computation of Programs
1. A (finite or infinite) transition sequence of program S with inputρ ∈ D(Hall):
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn, ρn〉 → 〈Sn+1, ρn+1〉 → ...
such that ρn , 0 for all n (except the last n in the case of a finitesequence).
2. If this sequence cannot be extended, it is called a computation.I If it is finite and its last configuration is 〈E, ρ′〉, we say it terminates
in ρ′.
I If it is infinite, we say it diverges.
![Page 53: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/53.jpg)
Computation of Programs
1. A (finite or infinite) transition sequence of program S with inputρ ∈ D(Hall):
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn, ρn〉 → 〈Sn+1, ρn+1〉 → ...
such that ρn , 0 for all n (except the last n in the case of a finitesequence).
2. If this sequence cannot be extended, it is called a computation.I If it is finite and its last configuration is 〈E, ρ′〉, we say it terminates
in ρ′.I If it is infinite, we say it diverges.
![Page 54: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/54.jpg)
NotationI Write:
〈S, ρ〉 →n 〈S′, ρ′〉
if there are configurations 〈S1, ρ1〉, ..., 〈Sn−1, ρn−1〉 such that
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn−1, ρn−1〉 → 〈S′, ρ′〉,
I Write→∗ for the reflexive and transitive closures of→:
〈S, ρ〉 →∗ 〈S′, ρ′〉
if and only if 〈S, ρ〉 →n 〈S′, ρ′〉 for some n ≥ 0.
![Page 55: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/55.jpg)
NotationI Write:
〈S, ρ〉 →n 〈S′, ρ′〉
if there are configurations 〈S1, ρ1〉, ..., 〈Sn−1, ρn−1〉 such that
〈S, ρ〉 → 〈S1, ρ1〉 → ...→ 〈Sn−1, ρn−1〉 → 〈S′, ρ′〉,
I Write→∗ for the reflexive and transitive closures of→:
〈S, ρ〉 →∗ 〈S′, ρ′〉
if and only if 〈S, ρ〉 →n 〈S′, ρ′〉 for some n ≥ 0.
![Page 56: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/56.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 57: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/57.jpg)
Semantic FunctionSemantic function of program S:
~S� : D(Hall)→ D(Hall)
~S�(ρ) = ∑{|ρ′ : 〈S, ρ〉 →∗ 〈E, ρ′〉|
}
Exercise 2Try to compute semantic function of your quantum walk program.
![Page 58: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/58.jpg)
Semantic FunctionSemantic function of program S:
~S� : D(Hall)→ D(Hall)
~S�(ρ) = ∑{|ρ′ : 〈S, ρ〉 →∗ 〈E, ρ′〉|
}Exercise 2Try to compute semantic function of your quantum walk program.
![Page 59: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/59.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.
2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.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�(ρ) = ???
![Page 60: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/60.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.
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�(ρ) = ???
![Page 61: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/61.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.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�(ρ) = ???
![Page 62: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/62.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.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�(ρ) = ???
![Page 63: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/63.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.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�(ρ) = ???
![Page 64: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/64.jpg)
Structural Representation
1. ~skip�(ρ) = ρ.2. ~q := |0〉�(ρ) = ∑i |0〉q〈i|ρ|i〉q〈0|.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�(ρ) = ???
![Page 65: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/65.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:
1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 66: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/66.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;
2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 67: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/67.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;
3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 68: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/68.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 69: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/69.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.
I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for allx ∈ X.
I x is called the least upper bound of X, written x =⊔
X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 70: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/70.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.
I x is called the least upper bound of X, written x =⊔
X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 71: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/71.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 72: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/72.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;
I for any upper bound y of X, x v y.
![Page 73: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/73.jpg)
Basic Lattice TheoryI A partial order (L,v): L is a nonempty set, v is a binary relation
on L satisfying:1. Reflexivity: x v x for all x ∈ L;2. Antisymmetry: x v y and y v x imply x = y for all x, y ∈ L;3. Transitivity: x v y and y v z imply x v z for all x, y, z ∈ L.
I x ∈ L is called the least element when x v y for all y ∈ L.I x ∈ L is called an upper bound of a subset X ⊆ L if y v x for all
x ∈ X.I x is called the least upper bound of X, written x =
⊔X, if
I x is an upper bound of X;I for any upper bound y of X, x v y.
![Page 74: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/74.jpg)
Basic Lattice TheoryI A complete partial order (CPO) is a partial order (L,v):
1. it has the least element 0;2.⊔∞
n=0 xn exists for any increasing sequence {xn}:
x0 v ... v xn v xn+1 v ....
I A function f from L into itself is continuous if
f
(⊔n
xn
)=⊔n
f (xn)
for any increasing sequence {xn} in L.
![Page 75: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/75.jpg)
Basic Lattice TheoryI A complete partial order (CPO) is a partial order (L,v):
1. it has the least element 0;
2.⊔∞
n=0 xn exists for any increasing sequence {xn}:
x0 v ... v xn v xn+1 v ....
I A function f from L into itself is continuous if
f
(⊔n
xn
)=⊔n
f (xn)
for any increasing sequence {xn} in L.
![Page 76: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/76.jpg)
Basic Lattice TheoryI A complete partial order (CPO) is a partial order (L,v):
1. it has the least element 0;2.⊔∞
n=0 xn exists for any increasing sequence {xn}:
x0 v ... v xn v xn+1 v ....
I A function f from L into itself is continuous if
f
(⊔n
xn
)=⊔n
f (xn)
for any increasing sequence {xn} in L.
![Page 77: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/77.jpg)
Basic Lattice TheoryI A complete partial order (CPO) is a partial order (L,v):
1. it has the least element 0;2.⊔∞
n=0 xn exists for any increasing sequence {xn}:
x0 v ... v xn v xn+1 v ....
I A function f from L into itself is continuous if
f
(⊔n
xn
)=⊔n
f (xn)
for any increasing sequence {xn} in L.
![Page 78: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/78.jpg)
Knaster-Tarski Theorem
Let (L,v) be a CPO and function f : L→ L continuous. Then f hasthe least fixed point
µf =∞⊔
n=0f (n)(0)
where {f (0)(0) = 0,f (n+1)(0) = f (f (n)(0)) for n ≥ 0.
![Page 79: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/79.jpg)
CPO of Partial Density Operators
I Löwner order: operators A v B⇔ B−A is positive.
I (D(H),v) is a CPO with the zero operator 0H as its leastelement.
Exercise 3Prove the above statement for finite-dimensionalH.
![Page 80: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/80.jpg)
CPO of Partial Density Operators
I Löwner order: operators A v B⇔ B−A is positive.I (D(H),v) is a CPO with the zero operator 0H as its least
element.
Exercise 3Prove the above statement for finite-dimensionalH.
![Page 81: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/81.jpg)
CPO of Super-operators
I Each super-operator inH is 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.
![Page 82: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/82.jpg)
CPO of Super-operators
I Each super-operator inH is 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 orderbetween super-operators:
E v F ⇔ E(ρ) v F (ρ) for all ρ ∈ D(H)
I (QO(H),v) is a CPO.
![Page 83: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/83.jpg)
CPO of Super-operators
I Each super-operator inH is 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.
![Page 84: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/84.jpg)
CPO of Super-operators
I Each super-operator inH is 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.
![Page 85: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/85.jpg)
Syntactic Approximation
I abort denotes 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) ofwhile:
while(0) ≡ abort,while(k+1) ≡ if M[q] = 0→ skip
� 1→ S; while(k)
fi
![Page 86: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/86.jpg)
Syntactic Approximation
I abort denotes 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) ofwhile:
while(0) ≡ abort,while(k+1) ≡ if M[q] = 0→ skip
� 1→ S; while(k)
fi
![Page 87: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/87.jpg)
Syntactic Approximation
I abort denotes 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) ofwhile:
while(0) ≡ abort,while(k+1) ≡ if M[q] = 0→ skip
� 1→ S; while(k)
fi
![Page 88: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/88.jpg)
Semantic Function of Loops
�while
�=
∞⊔k=0
�while(k)
�,
where⊔
stands for the least upper bound in CPO (QO (Hall) ,v).
Fixed Point CharacterisationFor any ρ ∈ D(Hall):
~while�(ρ) = M0ρM†0 + ~while�
(~S�
(M1ρM†
1
)).
Exercise 4Prove the above equality.
![Page 89: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/89.jpg)
Semantic Function of Loops
�while
�=
∞⊔k=0
�while(k)
�,
where⊔
stands for the least upper bound in CPO (QO (Hall) ,v).
Fixed Point CharacterisationFor any ρ ∈ D(Hall):
~while�(ρ) = M0ρM†0 + ~while�
(~S�
(M1ρM†
1
)).
Exercise 4Prove the above equality.
![Page 90: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/90.jpg)
Semantic Function of Loops
�while
�=
∞⊔k=0
�while(k)
�,
where⊔
stands for the least upper bound in CPO (QO (Hall) ,v).
Fixed Point CharacterisationFor any ρ ∈ D(Hall):
~while�(ρ) = M0ρM†0 + ~while�
(~S�
(M1ρM†
1
)).
Exercise 4Prove the above equality.
![Page 91: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/91.jpg)
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.
![Page 92: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/92.jpg)
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.
![Page 93: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/93.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 94: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/94.jpg)
Quantum predicates = Quantum effects
I A quantum effect is a (Hermitian) operator 0 v M v I; that is,0 ≤ tr(Mρ) ≤ 1 for all density operators.
I tr(Mρ) may be interpreted as the expected degree to whichquantum state ρ satisfies quantum predicate M.
![Page 95: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/95.jpg)
Quantum predicates = Quantum effects
I A quantum effect is a (Hermitian) operator 0 v M v I; that is,0 ≤ tr(Mρ) ≤ 1 for all density operators.
I tr(Mρ) may be interpreted as the expected degree to whichquantum state ρ satisfies quantum predicate M.
![Page 96: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/96.jpg)
Correctness FormulasI 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 preconditionP, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 97: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/97.jpg)
Correctness FormulasI 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 preconditionP, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 98: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/98.jpg)
Correctness FormulasI 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 preconditionP, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 99: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/99.jpg)
Correctness FormulasI 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 preconditionP, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 100: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/100.jpg)
Correctness FormulasI 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 CorrectnessI Partial correctness: If an input to program S satisfies precondition
P, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 101: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/101.jpg)
Correctness FormulasI 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 CorrectnessI Partial correctness: If an input to program S satisfies precondition
P, then either S does not terminate, or it terminates in a statesatisfying postcondition Q.
I Total correctness: If an input to program S satisfies precondition P,then S must terminate and it terminates in a state satisfyingpostcondition Q.
![Page 102: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/102.jpg)
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 partialcorrectness, written
|=par {P}S{Q},
if:tr(Pρ) ≤ tr(Q~S�(ρ)) + [tr(ρ)− tr(~S�(ρ))]
for all ρ ∈ D(Hall).
![Page 103: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/103.jpg)
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).
![Page 104: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/104.jpg)
Proof System for Partial Correctness
(Ax− Sk) {P}Skip{P}
(Ax− In) If type(q) = Boolean, then
{|0〉q〈0|P|0〉q〈0|+ |1〉q〈0|P|0〉q〈1|}q := |0〉{P}
If type(q) = integer, then
{∞
∑n=−∞
|n〉q〈0|P|0〉q〈n|}
q := |0〉{P}
(Ax−UT) {U†PU}q := Uq{P}
![Page 105: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/105.jpg)
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{
∑m M†mPmMm
}if (�m ·M[q] = m→ Sm) fi{Q}
(R− LP){Q}S
{M†
0PM0 + M†1QM1
}{M†
0PM0 + M†1QM1}while M[q] = 1 do S od{P}
(R−Or)P v P′ {P′}S{Q′} Q′ v Q
{P}S{Q}
![Page 106: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/106.jpg)
Soundness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
`qPD {P}S{Q} implies |=par {P}S{Q}.
Exercise 5Prove soundness theorem.
(Relative) Completeness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
|=par {P}S{Q} implies `qPD {P}S{Q}.
![Page 107: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/107.jpg)
Soundness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
`qPD {P}S{Q} implies |=par {P}S{Q}.
Exercise 5Prove soundness theorem.
(Relative) Completeness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
|=par {P}S{Q} implies `qPD {P}S{Q}.
![Page 108: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/108.jpg)
Soundness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
`qPD {P}S{Q} implies |=par {P}S{Q}.
Exercise 5Prove soundness theorem.
(Relative) Completeness TheoremFor any quantum while-program S and quantum predicatesP, Q ∈ P(Hall):
|=par {P}S{Q} implies `qPD {P}S{Q}.
![Page 109: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/109.jpg)
Bound (Ranking) Functions
I Let P ∈ P(Hall) be a quantum predicate, real number ε > 0.
I A functiont : D(Hall)→ ω
is a (P, ε)-bound function of quantum loop
while M[q] = 1 do S od
if for all ρ ∈ D(Hall):
1. t(~S�
(M1ρM†
1))≤ t(ρ);
2. tr(Pρ) ≥ ε implies
t(~S�
(M1ρM†
1
))< t(ρ)
![Page 110: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/110.jpg)
Bound (Ranking) Functions
I Let P ∈ P(Hall) be a quantum predicate, real number ε > 0.I A function
t : D(Hall)→ ω
is a (P, ε)-bound function of quantum loop
while M[q] = 1 do S od
if for all ρ ∈ D(Hall):
1. t(~S�
(M1ρM†
1))≤ t(ρ);
2. tr(Pρ) ≥ ε implies
t(~S�
(M1ρM†
1
))< t(ρ)
![Page 111: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/111.jpg)
Bound (Ranking) Functions
I Let P ∈ P(Hall) be a quantum predicate, real number ε > 0.I A function
t : D(Hall)→ ω
is a (P, ε)-bound function of quantum loop
while M[q] = 1 do S od
if for all ρ ∈ D(Hall):1. t
(~S�
(M1ρM†
1))≤ t(ρ);
2. tr(Pρ) ≥ ε implies
t(~S�
(M1ρM†
1
))< t(ρ)
![Page 112: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/112.jpg)
Bound (Ranking) Functions
I Let P ∈ P(Hall) be a quantum predicate, real number ε > 0.I A function
t : D(Hall)→ ω
is a (P, ε)-bound function of quantum loop
while M[q] = 1 do S od
if for all ρ ∈ D(Hall):1. t
(~S�
(M1ρM†
1))≤ t(ρ);
2. tr(Pρ) ≥ ε implies
t(~S�
(M1ρM†
1
))< t(ρ)
![Page 113: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/113.jpg)
Proof System for Total Correctness
(R− LT)
• {Q}S{M†0PM0 + M†
1QM1}• for any ε > 0, tε is a (M†
1QM1, ε)− bound functionof loop while M[q] = 1 do S od{M†
0PM0 + M†1QM1}while M[q] = 1 do S od{P}
![Page 114: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/114.jpg)
Soundness TheoremFor any quantum program S and quantum predicates P, Q ∈ P(Hall):
`qTD {P}S{Q} implies |=tot {P}S{Q}.
(Relative) Completeness TheoremFor any quantum program S and quantum predicates P, Q ∈ P(Hall):
|=tot {P}S{Q} implies `qTD {P}S{Q}.
![Page 115: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/115.jpg)
Soundness TheoremFor any quantum program S and quantum predicates P, Q ∈ P(Hall):
`qTD {P}S{Q} implies |=tot {P}S{Q}.
(Relative) Completeness TheoremFor any quantum program S and quantum predicates P, Q ∈ P(Hall):
|=tot {P}S{Q} implies `qTD {P}S{Q}.
![Page 116: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/116.jpg)
Outline
Introduction
Syntax of Quantum Programs
Operational Semantics
Denotational Semantics
(Floyd-)Hoare Logic for Quantum Programs
Research Problems
![Page 117: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/117.jpg)
Research problems
1. Compute the expected running time of the quantum walk.
2. Develop a logic for recursive quantum programs.3. Parallel or distributed quantum programs?4. Improve the invariant generation and termination analysis
algorithms for quantum programs.
Further reading
[1] M. S. Ying, S. G. Ying and X. D. Wu, Invariants of quantumprograms: characterisations and generation, POPL 2017.
[2] Y. J. Li and M. S. Ying, Algorithmic analysis of terminationproblem for quantum programs, POPL 2018.
![Page 118: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/118.jpg)
Research problems
1. Compute the expected running time of the quantum walk.2. Develop a logic for recursive quantum programs.
3. Parallel or distributed quantum programs?4. Improve the invariant generation and termination analysis
algorithms for quantum programs.
Further reading
[1] M. S. Ying, S. G. Ying and X. D. Wu, Invariants of quantumprograms: characterisations and generation, POPL 2017.
[2] Y. J. Li and M. S. Ying, Algorithmic analysis of terminationproblem for quantum programs, POPL 2018.
![Page 119: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/119.jpg)
Research problems
1. Compute the expected running time of the quantum walk.2. Develop a logic for recursive quantum programs.3. Parallel or distributed quantum programs?
4. Improve the invariant generation and termination analysisalgorithms for quantum programs.
Further reading
[1] M. S. Ying, S. G. Ying and X. D. Wu, Invariants of quantumprograms: characterisations and generation, POPL 2017.
[2] Y. J. Li and M. S. Ying, Algorithmic analysis of terminationproblem for quantum programs, POPL 2018.
![Page 120: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/120.jpg)
Research problems
1. Compute the expected running time of the quantum walk.2. Develop a logic for recursive quantum programs.3. Parallel or distributed quantum programs?4. Improve the invariant generation and termination analysis
algorithms for quantum programs.
Further reading
[1] M. S. Ying, S. G. Ying and X. D. Wu, Invariants of quantumprograms: characterisations and generation, POPL 2017.
[2] Y. J. Li and M. S. Ying, Algorithmic analysis of terminationproblem for quantum programs, POPL 2018.
![Page 121: Foundations of Quantum Programming - Tsinghua Universityconference.iiis.tsinghua.edu.cn/QCSS2018/wp-content/uploads/2018/... · Foundations of Quantum Programming Mingsheng Ying University](https://reader031.vdocuments.mx/reader031/viewer/2022021811/5cc967b588c99348378c4970/html5/thumbnails/121.jpg)
Thank You!