In this paper we aim at applying established formal methods techniques to a recent software area: quantum programming. In particular, we aim at providing a stepwise derivation of Grover's quantum search algorithm. Our work shows that, in principle, traditional software engineering techniques such as specification and refinement can be applied to quantum programs. We have chosen Grover's algorithm as an example because it is one of the two main quantum algorithms. The algorithm can find with high probability an element in an unordered array of length L in just O(radicL) steps (while any classical probabilistic algorithm needs Omega(L) steps). The derivation starts from a rigorous probabilistic specification of the search problem, then we stepwise refine that specification via standard refinement laws and quantum laws, until we arrive at a quantum program. The final program will thus be correct by construction.
In this paper we aim at applying established formal methods techniques to a recent software area: quantum programming. In particular, we aim at providing a stepwise derivation of Grover's quantum search algorithm. Our work shows that, in principle, traditional software engineering techniques such as specification and refinement can be applied to quantum programs. We have chosen Grover's algorithm as an example because it is one of the two main quantum algorithms. The algorithm can find with high probability an element in an unordered array of length L in just O(radicL) steps (while any classical probabilistic algorithm needs Omega(L) steps). The derivation starts from a rigorous probabilistic specification of the search problem, then we stepwise refine that specification via standard refinement laws and quantum laws, until we arrive at a quantum program. The final program will thus be correct by construction.
IntroductionFor a search problem associated with a unsorted database, the remarkable Grover's quantum algorithm (1) provides a quadratic speedup over its classical counterpart.The search problem can be described as follows: for a given function f , there exists one unknown element in the set {0, 1, ..., N -1} that satisfies f (x)=-1, say x = τ, whereas the other N -1o n e sg i v e f (x)=1.How many times of evaluations of f are required to determine the element τ for f (τ)=-1?Through a conventional algorithm, one needs O(N) trials to achieve this aim.How about the utility of quantum algorithm for the search?For the scenario in the quantum world, the search problem can be rephrased in the quantum mechanical language: for a given unitary operator I τ , that is sometimes called the oracle operator, and a set of state vectors (orthonormal basis): s = {|0 , |1 , ..., |N -1 }, I τ |x = |x for all states in the set except I τ |x = -|x for x = τ.H owma n yqueriesofI τ are required to determine |τ ?By Grover's algorithm, one needs only O( √ N) quantum mechanical steps to find the marked state |τ out.It has been shown that Grover's algorithm is optimal since it needs minimal oracle calls to perform a quantum search (2).The quantum searching process will be briefly reviewed as follows.The first step of Grover's algorithm is to prepare a superposition state of all elements with uniform probability amplitude:Then apply the Grover kernel G = -I η I τ to |s ,w h er eI η is a unitary operator and contains no bias against the marked state.For large N,a f t e ra b o u tm = π √ N/4 repetitions of G operations, the probability to observe |τ is close to one, i.e., G m |s ∼ |τ .( 2 ) Since every single G involves one query of I τ ,onlyO( √ N) searching steps are required for a quantum search task.In what follows, we will first investigate on the general SU(2) formulation for the kernel of Grover's searching operator G.The discussions of quantum searching certainty, robustness, and the analog analogue version of the Grover's algorithm will be given afterwards.
The development of quantum programs is becoming a reality due to the rapid advancement of quantum computing. Over the past few years, a multitude of hardware platforms, algorithms, and programming languages have emerged to support this paradigm. By the very nature of Quantum Mechanics principles, there is an enormous change of philosophy when building quantum programs, which operate in a probabilistic space, unlike the deterministic behaviour shown by classical programming languages. These conceptual differences can be overcome by using techniques and tools of Software Engineering. In this paper, we apply Model-Driven Engineering techniques in a systematic way to ease the generation of quantum programs and we apply it to solve the satisfiability problem, very important in many engineering domains like verification of discrete systems and test of integrated circuits. To that aim, we contribute with a metamodel for representing quantum circuits and a model-to-text transformation to generate working IBM Qiskit code. This model-driven infrastructure is employed to automatically generate quantum programs from SAT equations through a model-to-model transformation that embeds Grover’s algorithm. Besides, we provide formulas for calculating the number of required quantum elements from SAT equations, crucial in the current context of limited quantum resources. The interoperability with other tools and the extensibility to target additional quantum platforms is guaranteed thanks to the use of a model-based toolchain. We cover several usage scenarios to validate the approach, providing exemplary SAT equations, the generated Qiskit code and the results of executing this code in IBM Quantum infrastructure.
Quantum computing (QC) represents the future of computing systems, but the tools for reasoning about the quantum model of computation, in which the laws obeyed are those on the quantum mechanical scale, are still a mix of linear algebra and Dirac notation; two subjects more suitable for physicists, rather than computer scientists and software engineers. On this ground, we believe it is possible to provide a more intuitive approach to thinking and writing about quantum computing systems, in order to simplify the design of quantum algorithms and the development of quantum software. In this paper, we move the first step in such direction, introducing a specification language as the tool to represent the operations of a quantum computer via axiomatic definitions, by adopting the same symbolisms and reasoning principles used by formal methods in software engineering. We name this approach formal quantum software engineering (F-QSE). This work assumes familiarity with the basic principles of quantum mechanics (QM), with the use of Zed (Z) which is a formal language of software engineering (SE), and with the notation and techniques of first-order logic (FOL) and functional programming (FP).
It is widely believed that quantum computers (if realized) will be more powerful than today’s computers from the viewpoint of computational complexity . However, it is not obvious how to utilize quantum computers in practical situations. For practical purposes, a Grover search may be one of the most promising quantum algorithms known so far. Thus, in this paper, we propose an efficient framework where we can use Grover search for general programming. Our framework has the following steps. (1) A programmer writes a program by using standard C++ programming language. (2) Some if expressions within for loops in the C++ source code are chosen as candidates to be performed as a Grover search on a quantum computer. (3) The framework automatically generates a corresponding quantum circuit for each Grover search chosen in (2). Unlike the existing quantum circuit design methods, we can treat large problems in our quantum circuit design. (4) By evaluating the number of primitive quantum gates in the quantum circuit generated in (3), the framework determines whether the processing time of the quantum circuit is faster than the processing time of the corresponding if expression on a classical computer. If the framework determines that the quantum circuit is faster, it generates some interface source codes for a classical computer. Thus, in our framework, a programmer can use a Grover search with almost no effort.
This paper's aim is to explore improvements to, and applications of, a fundamental quantum algorithm invented by Grover\cite{grover}. Grover's algorithm is a basic tool that can be applied to a large number of problems in computer science, creating quantum algorithms that are polynomially faster than fastest known and fastest possible classical algorithms that solve the same problems. Our goal in this paper is to make these techniques readily accessible to those without a strong background in quantum physics: we achieve this by providing a set of tools, each of which makes use of Grover's algorithm or similar techniques, which can be used as subroutines in many quantum algorithms.}{The tools we provide are carefully constructed: they are easy to use, and in many cases they are asymptotically faster than the best tools previously available. The tools we build on include algorithms by Boyer, Brassard, Hoyer and Tapp, Buhrman, Cleve, de Witt and Zalka and Durr and Hoyer.}{After creating our tools, we create several new quantum algorithms, each of which is faster than the fastest known deterministic classical algorithm that accomplishes the same aim, and some of which are faster than the fastest possible deterministic classical algorithm. These algorithms solve problems from the fields of graph theory and computational geometry, and some employ dynamic programming techniques. We discuss a breadth-first search that is faster than Θ(edges) (the classical limit) in a dense graph, maximum-points-on-a-line in O(N3/2lgN) (faster than the fastest classical algorithm known), as well as several other algorithms that are similarly illustrative of solutions in some class of problem. Through these new algorithms we illustrate the use of our tools, working to encourage their use and the study of quantum algorithms in general.