• No results found

Foundations of Quantum Programming

N/A
N/A
Protected

Academic year: 2021

Share "Foundations of Quantum Programming"

Copied!
122
0
0

Loading.... (view fulltext now)

Full text

(1)

Foundations of Quantum Programming

Mingsheng Ying

University of Technology Sydney, Australia Institute of Software, Chinese Academy of Sciences

Tsinghua University, China

(2)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(3)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(4)

How to program quantum computers?

I Quantum algorithms:

Deutsch-Josza, Grover, Shor, HHL, ...

Quantum algorithm zoo (http://math.nist.gov/quantum/zoo/)

I Quantum computers:

Google (53 qubits —quantum supremacy— 2019) IBM Q (50 qubits — 2018)

Intel, Rigetti, IonQ, ...

(5)

How to program quantum computers?

I Quantum algorithms:

Deutsch-Josza, Grover, Shor, HHL, ...

Quantum algorithm zoo (http://math.nist.gov/quantum/zoo/)

I Quantum computers:

Google (53 qubits —quantum supremacy— 2019) IBM Q (50 qubits — 2018)

Intel, Rigetti, IonQ, ...

(6)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(7)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(8)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(9)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(10)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(11)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(12)

Quantum programming platforms

I Q# @Microsoft

I Cirq @Google

I Qiskit @IBM

I Quil @Riggeti

I Quipper @Dalhousie

I isQ @Institute of Software, Chinese Academy of Sciences

I ...

(13)

This lecture

I Principlesunderlyingallof the quantum programming languages

I Notthe languages themselves.

I Reference:

M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.

(14)

This lecture

I Principlesunderlyingallof the quantum programming languages

I Notthe languages themselves.

I Reference:

M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.

(15)

This lecture

I Principlesunderlyingallof the quantum programming languages

I Notthe languages themselves.

I Reference:

M. S. Ying, Foundations of Quantum Programming, Morgan Kaufmann 2016,Chapters 3 and 4.

(16)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(17)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(18)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(19)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(20)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(21)

Programming languages and tools

Programming languages are notations used forspecifying,organising andreasoningabout computations.

[R. Sethi, Programming languages: Concepts and Constructs]

I Semantics

I Turing-complete?

I Compilers

I Program test, debugging, analysis

I How to verify correctness of your programs?

I ...

(22)

Quantum circuits vs Quantum programs

Example:Quantum walk on a circle with an absorbing boundary.

I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.

I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with

orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.

I The state space of the walk — H =Hp⊗Hd.

I The initial state —|0ip|Lid.

(23)

Quantum circuits vs Quantum programs

Example:Quantum walk on a circle with an absorbing boundary.

I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.

I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with

orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.

I The state space of the walk — H =Hp⊗Hd.

I The initial state —|0ip|Lid.

(24)

Quantum circuits vs Quantum programs

Example:Quantum walk on a circle with an absorbing boundary.

I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.

I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with

orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.

I The state space of the walk — H =Hp⊗Hd.

I The initial state —|0ip|Lid.

(25)

Quantum circuits vs Quantum programs

Example:Quantum walk on a circle with an absorbing boundary.

I Hd=span{|Li,|Ri}— thedirectionspace,|Liand|Riindicate directions left and right, respectively.

I Hp=span{|0i,|1i, ...,|n−1i}— thepositionspace with

orthonormal basis states, the vector|iidenotes position i for each 0≤i≤n−1.

I The state space of the walk — H =Hp⊗Hd.

I The initial state —|0ip|Lid.

(26)

Quantum circuits vs Quantum programs

I Each step of the walk:

1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:

M = {Myes= |1ih1| ⊗Id, Mno =I−Myes};

2. A “coin-tossing”operator C= 1

2

 1 1

1 −1



is applied on the direction space;

3. A shift operator

S=

n−1

i=0

|i 1ihi| ⊗ |LihL| +

n−1

i=0

|i⊕1ihi| ⊗ |RihR|

is performed on the state space H.

I Question:How to specify it in the circuit language?

(27)

Quantum circuits vs Quantum programs

I Each step of the walk:

1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:

M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};

2. A “coin-tossing”operator C= 1

2

 1 1

1 −1



is applied on the direction space;

3. A shift operator

S=

n−1

i=0

|i 1ihi| ⊗ |LihL| +

n−1

i=0

|i⊕1ihi| ⊗ |RihR|

is performed on the state space H.

I Question:How to specify it in the circuit language?

(28)

Quantum circuits vs Quantum programs

I Each step of the walk:

1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:

M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};

2. A “coin-tossing”operator C= 1

2

 1 1

1 −1



is applied on the direction space;

3. A shift operator

S=

n−1

i=0

|i 1ihi| ⊗ |LihL| +

n−1

i=0

|i⊕1ihi| ⊗ |RihR|

is performed on the state space H.

I Question:How to specify it in the circuit language?

(29)

Quantum circuits vs Quantum programs

I Each step of the walk:

1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:

M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};

2. A “coin-tossing”operator C= 1

2

 1 1

1 −1



is applied on the direction space;

3. A shift operator

S=

n−1

i=0

|i 1ihi| ⊗ |LihL| +

n−1

i=0

|i⊕1ihi| ⊗ |RihR|

is performed on the state space H.

I Question:How to specify it in the circuit language?

(30)

Quantum circuits vs Quantum programs

I Each step of the walk:

1. Measure the system to see whether the current position is 1 (absorbing boundary). If “yes”, terminates; otherwise, continues:

M = {Myes= |1ih1| ⊗Id, Mno=I−Myes};

2. A “coin-tossing”operator C= 1

2

 1 1

1 −1



is applied on the direction space;

3. A shift operator

S=

n−1

i=0

|i 1ihi| ⊗ |LihL| +

n−1

i=0

|i⊕1ihi| ⊗ |RihR|

is performed on the state space H.

I Question:How to specify it in the circuit language?

(31)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(32)

Classical while-Language

S ::= skip|u :=t|S1; S2|if b then S1else S2fi

|while b do S od.

I Conditional statement can be generalised to case statement:

if G1→S1

 G2→S2

...

 Gn →Sn

fi or more compactly:

if(i·Gi→Si)fi

(33)

Quantum while-Language

I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....

I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.

Boolean= H2(2−dimensional), integer= H=

(

n=−

αn|ni:

n=−

|αn|2<∞ )

.

I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:

Hq=

n O i=1

Hqi.

(34)

Quantum while-Language

I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....

I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.

Boolean= H2(2−dimensional), integer= H=

(

n=−

αn|ni:

n=−

|αn|2<∞ )

.

I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:

Hq=

n O i=1

Hqi.

(35)

Quantum while-Language

I Alphabet: a countably infinite set Var of quantum variables q, q0, q0, q1, q2, ....

I Each quantum variable q∈Var has atypeHq(a Hilbert space), e.g.

Boolean= H2(2−dimensional), integer= H=

(

n=−

αn|ni:

n=−

|αn|2<∞ )

.

I A quantumregisteris a finite sequence q=q1, ..., qnof distinct quantum variables. State Hilbert space:

Hq=

n O i=1

Hqi.

(36)

Syntax of Quantum Programs

S ::= skip|q := |0i |q :=U[q] |S1; S2

|if(m·M[q] =m→Sm)fi

|while M[q] =1 do S od.

Exercise 1

Write quantum walk as a program in quantum while-language.

(37)

Syntax of Quantum Programs

S ::= skip|q := |0i |q :=U[q] |S1; S2

|if(m·M[q] =m→Sm)fi

|while M[q] =1 do S od.

Exercise 1

Write quantum walk as a program in quantum while-language.

(38)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(39)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables: Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(40)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables: Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(41)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(42)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(43)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(44)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(45)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(46)

Notations

I partial density operator: positive operator ρ, tr(ρ) ≤1.

I D(H)— the set of partial density operators inH.

I State Hilbert space of all quantum variables:

Hall = O

q∈Var

Hq.

I ↓— empty program; i.e. termination.

I Configuration: pairhS, ρi, where:

1. S is a quantum program or the empty program↓;

2. ρ∈ D(Hall), denoting the (global) state of quantum variables.

I Transition:

hS, ρi → hS0, ρ0i

(47)

Operational Semantics

(SK)

hskip, ρi → h↓, ρi

(IN)

hq := |0i, ρi → h↓, ρq0i

where : ρq0=

i

|0iqhi|ρ|iiqh0| (UT)

hq :=U[q], ρi → h↓, UρUi

(SC) hS1, ρi → hS10, ρ0i hS1; S2, ρi → hS10; S2, ρ0i

where : ↓; S2=S2.

(48)

Operational Semantics

(IF)

hif(m·M[q] =m→Sm)fi, ρi → hSm, MmρMmi

for each possible outcome m of measurement M= {Mm}.

(L0)

hwhile M[q] =1 do S od, ρi → h↓, M0ρM0i

(L1)

hwhile M[q] =1 do S od, ρi → hS; while M[q] =1 do S od, M1ρM1i

(49)

Computation of Programs

1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):

hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...

such that ρn , 0 for all n (except the last n in the case of a finite sequence).

2. If this sequence cannot be extended, it is called acomputation.

I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.

I If it is infinite, we say it diverges.

(50)

Computation of Programs

1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):

hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...

such that ρn , 0 for all n (except the last n in the case of a finite sequence).

2. If this sequence cannot be extended, it is called acomputation.

I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.

I If it is infinite, we say it diverges.

(51)

Computation of Programs

1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):

hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...

such that ρn , 0 for all n (except the last n in the case of a finite sequence).

2. If this sequence cannot be extended, it is called acomputation.

I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.

I If it is infinite, we say it diverges.

(52)

Computation of Programs

1. A (finite or infinite)transition sequenceof program S with input ρ∈ D(Hall):

hS, ρi → hS1, ρ1i →...→ hSn, ρni → hSn+1, ρn+1i →...

such that ρn , 0 for all n (except the last n in the case of a finite sequence).

2. If this sequence cannot be extended, it is called acomputation.

I If it is finite and its last configuration ish↓, ρ0i, we say it terminates in ρ0.

I If it is infinite, we say it diverges.

(53)

Notation

I

hS, ρi →n hS0, ρ0i

if there are configurationshS1, ρ1i, ...,hSn−1, ρn−1isuch that hS, ρi → hS1, ρ1i →...→ hSn−1, ρn−1i → hS0, ρ0i,

Ifor the reflexive and transitive closures of→: hS, ρi → hS0, ρ0i

if and only ifhS, ρi →n hS0, ρ0ifor some n≥0.

(54)

Notation

I

hS, ρi →n hS0, ρ0i

if there are configurationshS1, ρ1i, ...,hSn−1, ρn−1isuch that hS, ρi → hS1, ρ1i →...→ hSn−1, ρn−1i → hS0, ρ0i,

Ifor the reflexive and transitive closures of→: hS, ρi → hS0, ρ0i

if and only ifhS, ρi →n hS0, ρ0ifor some n≥0.

(55)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(56)

Semantic Function

Semantic function of program S:

~S :D(Hall) → D(Hall)

~S(ρ) =

|ρ0 :hS, ρi → h↓, ρ0i|

Exercise 2

Try to compute semantic function of your quantum walk program.

(57)

Semantic Function

Semantic function of program S:

~S :D(Hall) → D(Hall)

~S(ρ) =

|ρ0 :hS, ρi → h↓, ρ0i|

Exercise 2

Try to compute semantic function of your quantum walk program.

(58)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU.

4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm). 6. ~while M[q] =1 do S od(ρ) = ???

(59)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|.

3. ~q :=U[q](ρ) =UρU. 4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm). 6. ~while M[q] =1 do S od(ρ) = ???

(60)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU.

4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm). 6. ~while M[q] =1 do S od(ρ) = ???

(61)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU.

4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm). 6. ~while M[q] =1 do S od(ρ) = ???

(62)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU.

4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm).

6. ~while M[q] =1 do S od(ρ) = ???

(63)

Structural Representation

1. ~skip(ρ) =ρ.

2. ~q := |0i(ρ) =i|0iqhi|ρ|iiqh0|. 3. ~q :=U[q](ρ) =UρU.

4. ~S1; S2(ρ) =~S2(~S1(ρ)).

5. ~if(m·M[q] =m→Sm)fi(ρ) =m~Sm(MmρMm). 6. ~while M[q] =1 do S od(ρ) = ???

(64)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L; 3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(65)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L; 3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(66)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(67)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(68)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(69)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(70)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(71)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(72)

Basic Lattice Theory

I Apartial order(L,v): L is a nonempty set,vis a binary relation on L satisfying:

1. Reflexivity: xvx for all x∈L;

2. Antisymmetry: xvy and yvx imply x=y for all x, y∈L;

3. Transitivity: xvy and yvz imply xvz for all x, y, z∈L.

I x∈L is called theleast elementwhen xvy for all y∈L.

I x∈L is called an upper bound of a subset X⊆L if yvx for all x∈X.

I x is called the least upper bound of X, written x=FX, if

I x is an upper bound of X;

I for any upper bound y of X, xvy.

(73)

Basic Lattice Theory

I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does

X) for any X⊆L.

I Acomplete partial order(CPO) is a partial order(L,v):

1. it has the least element 0;

2. Fn=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....

(74)

Basic Lattice Theory

I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does

X) for any X⊆L.

I Acomplete partial order(CPO) is a partial order(L,v):

1. it has the least element 0;

2. Fn=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....

(75)

Basic Lattice Theory

I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does

X) for any X⊆L.

I Acomplete partial order(CPO) is a partial order(L,v): 1. it has the least element 0;

2. Fn=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....

(76)

Basic Lattice Theory

I Acomplete latticeis a partial order(L,v)such thatFX exists (and so does

X) for any X⊆L.

I Acomplete partial order(CPO) is a partial order(L,v): 1. it has the least element 0;

2. Fn=0xnexists for any increasing sequence{xn}: x0v...vxnvxn+1v....

(77)

Basic Lattice Theory

I A function f from L into itself is

I monotoneif:

xvy⇒f(x) vf(y);

I continuousif:

f G

n

xn

!

=G

n

f(xn) for any increasing sequence{xn}in L.

(78)

Basic Lattice Theory

I A function f from L into itself is

I monotoneif:

xvy⇒f(x) vf(y);

I continuousif:

f G

n

xn

!

=G

n

f(xn) for any increasing sequence{xn}in L.

(79)

Basic Lattice Theory

I A function f from L into itself is

I monotoneif:

xvy⇒f(x) vf(y);

I continuousif:

f G

n

xn

!

=G

n

f(xn) for any increasing sequence{xn}in L.

(80)

Tarski Fixed Point Theorem

I If(L,v)is a complete lattice and function f : L→L monotone, then f has a fixed point.

I Let(L,v)be a CPO and function f : L→L continuous. Then f has the least fixed point

µf = G

n=0

f(n)(0)

where f(0)(0) =0 and f(n+1)(0) =f(f(n)(0))for n≥0.

Exercise 3

Use Tarski fixed point theorem to proveSchröder-Bernstein theorem: if f : X→Y and g : Y→X are one-to-one mappings, then there is a bijection between X and Y.

(81)

Tarski Fixed Point Theorem

I If(L,v)is a complete lattice and function f : L→L monotone, then f has a fixed point.

I Let(L,v)be a CPO and function f : L→L continuous. Then f has the least fixed point

µf = G

n=0

f(n)(0)

where f(0)(0) =0 and f(n+1)(0) =f(f(n)(0))for n≥0.

Exercise 3

Use Tarski fixed point theorem to proveSchröder-Bernstein theorem:

if f : X→Y and g : Y→X are one-to-one mappings, then there is a bijection between X and Y.

(82)

CPO of Partial Density Operators

I Löwner order: operators AvB⇔B−A is positive.

I (D(H),v)is a CPO with the zero operator 0Has its least element.

Exercise 4

Prove the above statement forfinite-dimensionalH.

(83)

CPO of Partial Density Operators

I Löwner order: operators AvB⇔B−A is positive.

I (D(H),v)is a CPO with the zero operator 0Has its least element.

Exercise 4

Prove the above statement forfinite-dimensionalH.

(84)

CPO of Super-operators

I Each super-operator inHis a continuous function from (D(H),v)into itself.

I QO(H)— the set of superoperators in Hilbert spaceH.

I Löwner order between operators can be lifted to a partial order between super-operators:

E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)

I (QO(H),v)is a CPO.

(85)

CPO of Super-operators

I Each super-operator inHis a continuous function from (D(H),v)into itself.

I QO(H)— the set of superoperators in Hilbert spaceH.

I Löwner order between operators can be lifted to a partial order between super-operators:

E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)

I (QO(H),v)is a CPO.

(86)

CPO of Super-operators

I Each super-operator inHis a continuous function from (D(H),v)into itself.

I QO(H)— the set of superoperators in Hilbert spaceH.

I Löwner order between operators can be lifted to a partial order between super-operators:

E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)

I (QO(H),v)is a CPO.

(87)

CPO of Super-operators

I Each super-operator inHis a continuous function from (D(H),v)into itself.

I QO(H)— the set of superoperators in Hilbert spaceH.

I Löwner order between operators can be lifted to a partial order between super-operators:

E v F ⇔ E (ρ) v F (ρ)for all ρ∈ D(H)

I (QO(H),v)is a CPO.

(88)

Syntactic Approximation

I abortdenotes a program such that

~abort(ρ) =0Hallfor all ρ∈ D(H).

I Write:

whilewhile M[q] =1 do S od.

I For integer k≥0, the kth syntactic approximation while(k)of while:









while(0)abort,

while(k+1)if M[q] =0→skip

 1→S; while(k) fi

(89)

Syntactic Approximation

I abortdenotes a program such that

~abort(ρ) =0Hallfor all ρ∈ D(H).

I Write:

whilewhile M[q] =1 do S od.

I For integer k≥0, the kth syntactic approximation while(k)of while:









while(0)abort,

while(k+1)if M[q] =0→skip

 1→S; while(k) fi

(90)

Syntactic Approximation

I abortdenotes a program such that

~abort(ρ) =0Hallfor all ρ∈ D(H).

I Write:

whilewhile M[q] =1 do S od.

I For integer k≥0, the kth syntactic approximation while(k)of while:









while(0)abort,

while(k+1)if M[q] =0→skip

 1→S; while(k) fi

(91)

Semantic Function of Loops

while

= G

k=0

while(k) ,

whereFstands for the least upper bound in CPO(QO (Hall),v).

Fixed Point Characterisation

For any ρ∈ D(Hall):

~while(ρ) =M0ρM0+~while~SM1ρM1

 .

Exercise 5

Prove the above equality.

(92)

Semantic Function of Loops

while

= G

k=0

while(k) ,

whereFstands for the least upper bound in CPO(QO (Hall),v).

Fixed Point Characterisation

For any ρ∈ D(Hall):

~while(ρ) =M0ρM0+~while~SM1ρM1



.

Exercise 5

Prove the above equality.

(93)

Semantic Function of Loops

while

= G

k=0

while(k) ,

whereFstands for the least upper bound in CPO(QO (Hall),v).

Fixed Point Characterisation

For any ρ∈ D(Hall):

~while(ρ) =M0ρM0+~while~SM1ρM1



.

Exercise 5

Prove the above equality.

(94)

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.

(95)

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.

(96)

Outline

Introduction

Syntax of Quantum Programs Operational Semantics Denotational Semantics Quantum Hoare Logic Research Problems

(97)

Quantum predicates = Quantum effects

I Aquantum effectis a (Hermitian) operator 0vMvI; that is, 0≤tr() ≤1 for all density operators.

I tr()may be interpreted as the expected degree to which quantum state ρ satisfies quantum predicate M.

(98)

Quantum predicates = Quantum effects

I Aquantum effectis a (Hermitian) operator 0vMvI; that is, 0≤tr() ≤1 for all density operators.

I tr()may be interpreted as the expected degree to which quantum state ρ satisfies quantum predicate M.

(99)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(100)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(101)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(102)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(103)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(104)

Correctness Formulas

I A correctness formula (Hoare triple) is a statement of the form:

{P}S{Q} where:

I S is a quantum program;

I P, Q are quantum predicates inHall.

I P is called the precondition, Q the postcondition.

Partial Correctness, Total Correctness

I Partial correctness: If an input to program S satisfies precondition P, then either S does not terminate, or it terminates in a state satisfying postcondition Q.

I Total correctness: If an input to program S satisfies precondition P, then S must terminate and it terminates in a state satisfying postcondition Q.

(105)

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() ≤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() ≤tr(Q~S(ρ)) + [tr(ρ) −tr(~S(ρ))] for all ρ∈ D(Hall).

(106)

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() ≤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() ≤tr(Q~S(ρ)) + [tr(ρ) −tr(~S(ρ))]

for all ρ∈ D(Hall).

(107)

Proof System for Partial Correctness

(Ax−Sk) {P}Skip{P} (Ax−In)If type(q) =Boolean, then

{|0iqh0|P|0iqh0| + |1iqh0|P|0iqh1|}q := |0i{P}

If type(q) =integer, then

(

n=−∞

|niqh0|P|0iqhn| )

q := |0i{P}

(Ax−UT) {UPU}q :=Uq{P}

(108)

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

∑mMmPmMm if(m·M[q] =m→Sm)fi{Q}

(R−LP) {Q}SM0PM0+M1QM1

{M0PM0+M1QM1}while M[q] =1 do S od{P}

(R−Or) PvP0 {P0}S{Q0} Q0vQ {P}S{Q}

(109)

Soundness Theorem

For any quantum while-program S and quantum predicates P, Q∈ P (Hall):

`qPD{P}S{Q}implies |=par {P}S{Q}.

Exercise 6

Prove soundness theorem.

(Relative) Completeness Theorem

For any quantum while-program S and quantum predicates P, Q∈ P (Hall):

|=par{P}S{Q}implies `qPD{P}S{Q}.

(110)

Soundness Theorem

For any quantum while-program S and quantum predicates P, Q∈ P (Hall):

`qPD{P}S{Q}implies |=par {P}S{Q}.

Exercise 6

Prove soundness theorem.

(Relative) Completeness Theorem

For any quantum while-program S and quantum predicates P, Q∈ P (Hall):

|=par{P}S{Q}implies `qPD{P}S{Q}.

References

Related documents

2002 Nordiska Ministerrådet Gallery , Copenhagen, Denmark (paintings &amp; luminous performance; Dancers from local dance academy, musician). Corridor Gallery , Brooklyn, New

Main study parameters are hip pain and hip-related activity limitations (measured with the Hip disability Osteoarthritis Outcome Score (HOOS) [18,19]), direct costs and

guest-speakers, and mentoring; access to and participation of higher education institutions and the tourism industry in professional career events, workshops, conferences,

157 Given that the UoR is a highly successful institution, ranking third in the field of Education (The Guardian, 2018), it could have championed TAEDS as a flagship WP

In the opinion of the Supreme Court, the fact that the service providers were selected by means of a public tender did not justify the disputed agreements considering that

It is submitted that together, these three provisions in the Constitution (property protection and control of use, authority to make needful laws, and supremacy

The DNR has established an Urban Goose Management Plan for the Twin Cities Metropolitan Area (TCMA).. This Plan includes

Furthermore, the later the job seeker entered the current workplace, the less likely it would be for the job seeker to adopt the formal channel compared to using either the informal