Safe Haskell | Safe-Infered |
---|

This module defines the functions that can be used to simulate the running of QIO computations.

- type Pure = VecEqL CC HeapMap
- updateP :: Pure -> Qbit -> Bool -> Pure
- newtype Unitary = U {}
- unitaryRot :: Rotation -> Bool
- uMatrix :: Qbit -> (CC, CC, CC, CC) -> Unitary
- uRot :: Qbit -> Rotation -> Unitary
- uSwap :: Qbit -> Qbit -> Unitary
- uCond :: Qbit -> (Bool -> Unitary) -> Unitary
- uLet :: Bool -> (Qbit -> Unitary) -> Unitary
- runU :: U -> Unitary
- data StateQ = StateQ {}
- initialStateQ :: StateQ
- pa :: Pure -> RR
- data Split = Split {}
- split :: Pure -> Qbit -> Split
- class Monad m => PMonad m where
- data Prob a = Prob {}
- evalWith :: PMonad m => QIO a -> State StateQ (m a)
- eval :: PMonad m => QIO a -> m a
- run :: QIO a -> IO a
- sim :: QIO a -> Prob a

# Documentation

type Pure = VecEqL CC HeapMapSource

A Pure state can be thought of as a vector of classical basis states, stored as Heaps, along with complex amplitudes.

updateP :: Pure -> Qbit -> Bool -> PureSource

The state of a qubit can be updated in a Pure state, by mapping the update operation over each Heap.

A Unitary can be thought of as an operation on a HeapMap that may produce a Pure state.

unitaryRot :: Rotation -> BoolSource

A function that checks if a given Rotation is in face unitary. Note that this is currently a dummy stub function, and states that any rotation is unitary. (This is only o.k. at the moment as all the rotations defined in the QIO library are unitary, but won't catch un-unitary user-defined Rotations)

uMatrix :: Qbit -> (CC, CC, CC, CC) -> UnitarySource

Given the four complex numbers that make up a 2-by-2 matrix, we can create a Unitary that applies the rotation to the given qubit.

uCond :: Qbit -> (Bool -> Unitary) -> UnitarySource

A conditional operation can be defined as a Unitary

A quantum state is a defined as the next free qubit reference, along with the Pure state that represents the overall quantum state

The initial `StateQ`

A Split, is defined as a probability, along with the two Pure states.

split :: Pure -> Qbit -> SplitSource

Given a Pure state, we can create a Split, by essentially splitting the state into the part where the qubit is True, and the part where the qubit is False. This is how measurements are implemented in QIO.

class Monad m => PMonad m whereSource

We can extend a Monad into a PMonad if it defines a way of probabilistically merging two computations, based on a given probability.

The type Prob is defined as a wrapper around Vectors with Real probabilities.

evalWith :: PMonad m => QIO a -> State StateQ (m a)Source

Given a PMonad, a QIO Computation can be converted into a Stateful computation
over a quantum state (of type `StateQ`

).