Compiling a functional quantum programming language www.cs.nott.ac.uk/ � jjg/qml Jonathan Grattage with Thorsten Altenkirch School of Computer Science & IT, University of Nottingham Compiling a functional quantum programming language – p.1/15
Motivation � � � The “ Quantum Software Crisis ” Quantum algorithms are usually presented using the circuit � model Nielsen and Chuang, p.7, ‘ Coming up with good quantum � algorithms is hard ’ Richard Josza, QPL 2004: “ We need to develop quantum thinking! ” Our Solution: A high-level quantum programming language with a structure familiar to functional programmers, which supports reasoning and and algorithm design Compiling a functional quantum programming language – p.2/15
Quantum Languages � � � P . Zuliani, PhD 2001, Quantum Programming (qGCL) P . Selinger, MSCS 2003, Towards a Quantum Programming � Language (QPL) � A. van Tonder, SIAM 2003, A Lambda Calculus for Quantum Computation � : : : A. Sabry, Haskell 2003, Modeling quantum computing in Haskell � P . Selinger and B. Valiron, TLCA 2005, A lambda calculus for quantum computation with classical control All based on “ Quantum data, Classical control” Compiling a functional quantum programming language – p.3/15
QML � � � A first-order functional language for quantum computations on � finite types � = 1 j � � � j � � � “Quantum Data and Control” Based on strict linear logic - controlled, explicit, weakening � ~ y Types: t = x j let x = t in u j x j () j let ( x ; y ) = t in u j ( t ; u ) 0 j if t then u else u Æ Terms: 0 j if t then u else u j f ( � ) qfalse j ( � ) qtrue g � , � 2 C Compiling a functional quantum programming language – p.4/15
deuts h : 2 ( 2 ( Q 2 Deutsch algorithm deuts h a b = Æ let ( x ; y ) = if f qfalse j qtrue g then (qtrue ; if a then f qfalse j ( � 1) qtrue g else f ( � 1) qfalse j qtrue g else (qfalse ; if b then f ( � 1) qfalse j qtrue g else f qfalse j ( � 1) qtrue g in H x Compiling a functional quantum programming language – p.5/15
� Control of Decoherence � 2 2 � 2 (2 ; 2) ! 2 1 2 � ( x ; y ) = x 1 � � Projection Function 1 � Æ 2 2 ! (2 ; 2) � x : 2 x : 2 Æ x = ( x ; x ) 0 : 2 � x : 2 Diagonal Function ���� ���� Compiling a functional quantum programming language – p.6/15
� Control of Decoherence � � :Æ : 2 ! 2 1 � x : 2 x : 2 0 : 2 � � � � Æ 1 � 2 2 ���� ���� � 1 1 p p f j 0 i + j 1 ig (equal superposition) 2 2 Classical Case: 1 1 fj 0 ig + fj 1 ig (probability distribution) 2 2 Quantum Case: Input = Output = Decoherence! Not the identity function Compiling a functional quantum programming language – p.7/15
More Decoherence � for get mentions x for get : 2 ( 2 for get x = if x then qtrue else qtrue � � � if always measures the conditional, returning only one branch but doesn’t use it. Hence, it has to measure it! Compiling a functional quantum programming language – p.8/15
Æ if � 0 for get : 2 ( 2 Æ 0 for get x = if x then qtrue else qtrue � qtrue 6? qtrue . � qnot : 2 ( 2 Æ qnot x = if x then qfalse else qtrue This program has a type error, because � qfalse ? qtrue . This program typechecks, because Compiling a functional quantum programming language – p.9/15
� � Compiler Design � � F QC (Finite Quantum Computation) objects � a b Takes in QML expressions � Compiled into g h � � = quantum circuit � � � : : : or a real quantum computer Circuit represented as simple combinators Can be directly simulated, or passed to any standard simulator Compiling a functional quantum programming language – p.10/15
Quantum Machine Code � a 2 N , defined inductively � Sequential Composition ( � Æ ) a � Quantum circuits of size � Parallel Composition ( � � ) a � b � a b a b Permutations (rewiring) � � � � � � Compiling a functional quantum programming language – p.11/15
Quantum Machine Code � Conditional Application ( � j ) � � Q X X 2 a � � Rotation ( rot u , where u 2 2 ! 2 ! C is a unitary matrix) Q r ot u 2 Compiling a functional quantum programming language – p.12/15
� � � � � Compiling the let-rule � ` t : � � ; x : � ` u : � let � � � ` let x = t in u : � � � � � � � C � � � � u � t � � � � � � � � � � � � � � � � � � � � � � � � � � Compiling a functional quantum programming language – p.13/15
Summary � Æ ) ( if � QML is a first-order functional language for quantum � computations on finite types, with quantum control structures � Compiler into quantum circuits gives the operational semantics � Denotational semantics is given as ‘density matrices’ and ‘super operators’ � Future work: Define equational theory, and show this conicides with � : : : denotational sematics Only small programs currently; we need bigger and better examples Compiling a functional quantum programming language – p.14/15
Thanks � � www.cs.nott.ac.uk/ � jjg/qml Papers on QML can be found at: � Jonathan Grattage (jjg@cs.nott.ac.uk) Compiling a functional quantum programming language – p.15/15
Recommend
More recommend