A Comparison of Quantum Hoare Logic and Quantum Propositional Dynamic Logic
Total Page:16
File Type:pdf, Size:1020Kb
A comparison of Quantum Hoare Logic and Quantum Propositional Dynamic Logic Pelle Nelissen June 26, 2020 Bachelor thesis Mathematics and Physics & Astronomy Supervisors: prof. dr. C.J.M. Schoutens, prof. dr. S.J.L. Smets Institute of Physics Institute for Logic, Language and Computation Faculty of Science University of Amsterdam Abstract Propositional Dynamic Logic (PDL) and Hoare Logic (HL) are two logical languages capable of verifying the correctness of classical computer programs. In order to verify the correctness of quantum computer programs, LQP [3] and QHL [31] were developed as quantum versions of PDL and HL respectively. In this thesis, we compare the two languages by applying them to two typically `quantum' algorithms { the Mermin paradox [20] and the Elitzur-Vaidman bomb tester [10]. We conclude that LQP is more equipped for formal logical purposes such as proving decidability and QHL is more applicable in quantum physics as a means of easily calculating the output of a given quantum program. Finally, we informally show that the expressivity of LQP and QHL are not comparable in the sense that both languages can express statements that the other language cannot express. Title: A comparison of Quantum Hoare Logic and Quantum Propositional Dynamic Logic Author: Pelle Nelissen, [email protected], 11184205 Supervisors: prof. dr. C.J.M. Schoutens, prof. dr. S.J.L. Smets Second graders: dr. M. Walter, dr. M. Ozols End date: June 26, 2020 Institute of Physics University of Amsterdam Science Park 904, 1098 XH Amsterdam https://iop.uva.nl Institute for Logic, Language and Computation University of Amsterdam Science Park 107, 1098 XG Amsterdam https://illc.uva.nl 2 Contents 1. Introduction 4 2. Quantum Mechanics 6 2.1. Fundamental concepts . .6 2.2. Quantum measurements . .9 2.3. The spookiness of quantum mechanics . 11 3. Quantum Hoare Logic 16 3.1. Preliminaries . 16 3.2. Correctness verification . 21 3.3. Examples . 25 4. Logic of Quantum Programs 30 4.1. Preliminaries . 30 4.2. Syntax and semantics . 34 4.3. Proof theory . 37 4.4. The ∗-operator . 41 4.5. Examples . 43 5. Comparison of QHL and LQP 48 6. Conclusion and future work 51 Bibliography 53 Populaire samenvatting 56 A. Omitted proofs in Chapter 2. Quantum Mechanics 58 B. Omitted proofs in Chapter 3. Quantum Hoare Logic 61 C. Omitted proofs in Chapter 4. Logic of Quantum Programs 66 3 1. Introduction It is safe to say that computers play a vital role in modern human society. And with computers come computer programs that have become more and more complex over time. Nevertheless, we depend strongly on the ability of those computer programs to execute their tasks flawlessly, be it to secure communication channels between banks or to safely transfer classified information between governments. Hence, several logical languages were designed to verify the correctness of programs, i.e. to prove that the (sometimes enormous numbers of) lines of code of a program do not contain any mistakes or bugs and that the code performs the desired task correctly. Two examples of such languages are Propositional Dynamic Logic (PDL) and Hoare Logic (HL) (see e.g. [15]). Over the past few decades, the intriguing invention of quantum computers has led to a similar development concerning quantum programs. Even though the largest quantum computer at the time of writing consists of only 53 quantum bits (qubits) [26], it can be expected that quantum computers will play a crucial role in our future society. As a result, quantum mechanical versions of the above mentioned logics are currently in development. For instance, Baltag and Smets [3] and Ying [31] have developed quantum mechanical versions of PDL and HL respectively. Whereas classical PDL was developed as an extension to classical HL (see e.g. [15]), their quantum mechanical counterparts are being developed simultaneously and their authors base themselves on different traditions. Baltag and Smets [2] connect their work to a dynamification of propositional logic { by viewing actions instead of static propositions as the protagonist { in what they call the \Dutch school" (see e.g. [30]) and a dynamification of traditional quantum logic1 in what they call the \Brussels school" (see e.g. [27]). This results in a dynamic Logic of Quantum Programs (LQP) that is an extension to PDL in the sense that its syntax includes (almost) all formulas of classical PDL and its semantics are a special case of the semantics of PDL [3]. The semantics of LQP can be defined without reference to Hilbert spaces (the traditional language of quantum mechanics), but this abstraction leads to some difficulty in making quantitative statements about phases and probabilities. However, Baltag et al. [4] later expanded their language by introducing the necessary tools to reason about certain probabilistic processes quantitatively. This Probabilistic Logic of Quantum Programs (PLQP) was further extended by Bergfeld et al. [5]. The work of Ying [31] originates in the recent development of several quantum pro- gramming languages. Since Knill [18] proposed a first quantum programming language, several other quantum programming languages were designed (see [11] and [24] for an overview). For instance, Selinger [25] designed a quantum programming language suited for more traditional and intuitive programming { containing quantum versions of if-else 1For an overview of traditional quantum logic and the several logical approaches to quantum pro- grams that followed from traditional quantum logic, see [5, §2.2]. 4 constructions and while-loops { than the common quantum circuit approach (see e.g. [7]). Several authors have developed formal semantics for such quantum programming languages (see [11] and [24]). Amongst them are D'hondt and Panangaden [8], who introduced Hermitian operators (see section 2.1) as quantum predicates. Ying [31] pre- sented the first Hoare-style proof system for the verification of quantum programs based on the language of Selinger [25] and the semantics of D'hondt and Panangaden [8]. This thesis attempts to analyse and compare the logics of Baltag and Smets [2] and Ying [31]. To this end, we introduce two counterintuitive and typically `quantum' ex- periments { the Mermin paradox [20] and the Elitzur-Vaidman bomb tester [10]. The Mermin paradox was designed to display the fundamental differences between classical physics and quantum mechanics. It shows how certain experimental results fail to be described by so-called `local hidden variables' { unknown intrinsic variables of physical objects that contain enough information to act `quantum-like' without depending on quantum mechanics as a legitimate physical theory (see e.g. [14, §12.2]). The Elitzur- Vaidman bomb tester is a thought experiment resulting in a method of extracting infor- mation from a quantum mechanical system without disturbing it, in a sense. This seems to be a contradiction to a fundamental postulate in quantum mechanics stating that measurements on a physical system force the system to nondeterministically `collapse' to one of several pre-determined states (see section 2.2). After giving the traditional quantum mechanical analyses of these experiments in terms of Hilbert spaces, we model the Mermin paradox and the Elitzur-Vaidman bomb tester in both logics. This allows us to compare their methods of dealing with the more complex and counterintuitive aspects of quantum programming compared to classical programming. The importance of formal methods of quantum program verification is most easily seen by pointing out that such counterintuitive quantum effects can easily lead to fatal errors in writing quantum programs. If we want to minimise the vulnerability of e.g. secure communication through quantum computing, we must commit to developing rigorous proof systems for the correctness of quantum programs and thoroughly testing their effectiveness. This is a major task that can only be achieved by a joint effort of logicians, physicists, computer scientists and many other specialists. For example, the logical development of appropriate quantum programming languages and their formal semantics has the potential of contributing greatly to current quantum computational research in physics, where the focus is mainly on traditional quantum circuits (see e.g. [7]). Analysing quantum programs/algorithms in terms of quantum circuits does not easily allow for if-else constructions or while-loops, which are important building blocks for most classical software. Especially the logic of Ying [31] yields an accessible method of calculating the output of more complex quantum programs without invoking heavy theorems of analysis or algebra. This thesis is organised as follows. In chapter 2, some fundamental aspects of quantum mechanics are summarised and the Mermin paradox and Elitzur-Vaidman bomb tester are introduced. In chapters 3 and 4, the logic of Ying [31] respectively Baltag and Smets [3] are described and consequently applied to the Mermin paradox and Elitzur-Vaidman bomb tester. Finally, we reflect on the differences between and similarities of the two logics in chapter 5 and draw our conclusions in chapter 6. 5 2. Quantum Mechanics The theory of quantum mechanics is based on a number of postulates. These postulates cannot be proven and function as fundamental assumptions. The theory that follows from these few postulates accurately describes a wealth of physical systems and is es- pecially powerful on very small length scales and very at very low temperatures. It does, however, give rise to particularly counterintuitive results, the most famous exam- ple being Schr¨odinger'scat [23]. Some of the less familiar examples include the Mermin paradox [20] and the Elitzur-Vaidman bomb tester [10]. In this section, we give a brief overview of the fundamentals of quantum mechanics (loosely based on [21]), followed by a closer look at quantum measurements and finally we introduce the Mermin paradox and the Elitzur-Vaidman bomb tester. 2.1. Fundamental concepts The first postulate of quantum mechanics states that any physical system can be de- scribed by the mathematical structure of Hilbert spaces.