foundations of quantum programming - tsinghua...

Post on 01-May-2019

222 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Foundations of Quantum Programming

Mingsheng Ying

University of Technology Sydney, AustraliaInstitute of Software, Chinese Academy of Sciences

Tsinghua University, China

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

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:

IBM Q (20 qubits — Nov 2017; 50 qubits — 2018)

Google (49 qubits — 2018)

Intel (17 qubits — Oct 2017)

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)

Quantum programming languages

I Q# @Microsoft

I Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @Google

I Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @Riggeti

I Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @Dalhousie

I Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @Princeton

I Project Q @ETHI QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETH

I QWire @UPennI Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPenn

I Q|SI> @UTS

Quantum programming languages

I Q# @MicrosoftI Open Fermion @GoogleI Quil @RiggetiI Quipper @DalhousieI Scaffold @PrincetonI Project Q @ETHI QWire @UPennI Q|SI> @UTS

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.

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.

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.

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 ......

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 ......

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 ......

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 ......

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 ......

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 ......

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.

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.

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.

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.

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?

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?

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?

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?

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?

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

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

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 .

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 .

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 .

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.

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.

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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′, ρ′〉

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.

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〉

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.

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.

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.

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.

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.

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.

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

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.

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.

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�(ρ) = ???

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�(ρ) = ???

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�(ρ) = ???

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�(ρ) = ???

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�(ρ) = ???

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�(ρ) = ???

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

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

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

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.

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.

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.

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

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

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.

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.

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.

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.

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.

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.

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.

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.

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).

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

{|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}

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}

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}.

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}.

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}.

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(ρ)

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(ρ)

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(ρ)

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(ρ)

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}

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}.

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}.

Outline

Introduction

Syntax of Quantum Programs

Operational Semantics

Denotational Semantics

(Floyd-)Hoare Logic for Quantum Programs

Research Problems

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.

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.

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.

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.

Thank You!

top related