QIO-1.2: The Quantum IO Monad is a library for defining quantum computations in Haskell

QIO.QioSyn

Description

This module defines the Syntax of the Quantum IO Monad, which is an embedded language for writing quantum computations.

Synopsis

# Documentation

type RR = DoubleSource

For Real numbers, we simply use the built in Double type

type CC = Complex RRSource

For Complex numbers, we use the built in Complex numbers, over our Real number type (i.e. Double)

amp :: CC -> RRSource

The amplitude of a complex number is the magnitude squared.

newtype Qbit Source

The type of Qubits in QIO are simply integer references.

Constructors

 Qbit Int

Instances

 Enum Qbit Eq Qbit Num Qbit Ord Qbit Show Qbit We can display a qubit reference Heap HeapMap A HeapMap is an instance of the Heap type class, where the Heap functions can make use of the underlying Map functions. Qdata Bool Qbit The lowest-level instance of Qdata is the relation between Booleans and Qubits.

type Rotation = (Bool, Bool) -> CCSource

A rotation is in essence a two-by-two complex valued matrix

data U Source

The underlying data type of a U unitary operation

Constructors

 UReturn Rot Qbit Rotation U Swap Qbit Qbit U Cond Qbit (Bool -> U) U Ulet Bool (Qbit -> U) U

Instances

 Show U We can display a representation of a unitary Monoid U The type U forms a Monoid

data QIO a Source

The underlying data type of a QIO Computation

Constructors

 QReturn a MkQbit Bool (Qbit -> QIO a) ApplyU U (QIO a) Meas Qbit (Bool -> QIO a)

Instances

rot :: Qbit -> Rotation -> USource

Apply the given rotation to the given qubit

swap :: Qbit -> Qbit -> USource

Swap the state of the two given qubits

cond :: Qbit -> (Bool -> U) -> USource

Apply the conditional unitary, depending on the value of the given qubit

ulet :: Bool -> (Qbit -> U) -> USource

Introduce an Ancilla qubit in the given state, for use in the sub-unitary

urev :: U -> USource

Returns the inverse (or reverse) of the given unitary operation

unot :: Qbit -> USource

Apply a not rotation to the given qubit

Apply a hadamard rotation to the given qubit

uphase :: Qbit -> RR -> USource

Apply a phase rotation (of the given angle) to the given qubit

Initialise a qubit in the given state (adding it to the overall quantum state)

Apply the given unitary operation to the current quantum state

Measure the given qubit, and return the measurement outcome (note that this operation may affect the overall quantum state, as a measurement is destructive)

The identity rotation

The not rotation