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

Safe HaskellSafe-Infered

QIO.QExamples

Description

This module contains some simple examples of quantum computations written using the Quantum IO Monad.

Synopsis

Documentation

q0 :: QIO QbitSource

Initialise a qubit in the |0> state

q1 :: QIO QbitSource

Initialise a qubit in the |1> state

qPlus :: QIO QbitSource

Initialise a qubit in the |+> state. This is done by applying a Hadamard gate to the |0> state.

qMinus :: QIO QbitSource

Initialise a qubit in the |-> state. This is done by applying a Hadamard gate to the |1> state.

randBit :: QIO BoolSource

Create a random Boolean value, by measuring the state |+>

share :: Qbit -> QIO QbitSource

This function can be used to share the state of one qubit, with another newly initialised qubit. This is not the same as cloning, as the two qubits will be in an entangled state. sharing is achieved by simply initialising a new qubit in state |0>, and then applying a controlled-not to that qubit, depending on the state of the given qubit.

bell :: QIO (Qbit, Qbit)Source

A Bell state can be created by sharing the |+> state

test_bell :: QIO (Bool, Bool)Source

This function creates a Bell state, and then measures it. The resulting pair of Booleans will always be in the same state as one another.

hadTwice :: Bool -> QIO BoolSource

This function initiaslised a qubit in the state corresponding to the given Boolean value. The Hadamard transform (which is self-inverse) is applied to the qubit twice, and then the qubit is measured. This should correspond to the identity function on the given Boolean value.

hadTwice' :: Bool -> QIO BoolSource

A different implementation of hadTwice where QIO is used to apply two unitaries, each of which is a single Hadamard gate, as opposed to a single unitary, which is two Hadamard gates.

alice :: Qbit -> Qbit -> QIO (Bool, Bool)Source

The operations that Alice must perform in the classic quantum teleportation example.

uZZ :: Qbit -> USource

A definition of the Pauli-Z gate.

bobsU :: (Bool, Bool) -> Qbit -> USource

The unitary operations that Bob must perform in the classic quantum teleportation example.

bob :: Qbit -> (Bool, Bool) -> QIO QbitSource

The overall operations that Bob must perform in the classic quantum teleportation example

teleportation :: Qbit -> QIO QbitSource

The overall QIO computation that teleports the state of single qubit

test_teleport :: QIO (Bool, Bool)Source

A small test function of quantum teleportation, which teleports a bell state, and then measures it.

teleport_true' :: QIO QbitSource

teleports a qubit in the state |1>

teleport_true :: QIO BoolSource

teleports a qubit in the state |1>, and then measures it

teleport_random' :: QIO QbitSource

teleports a qubit in the state |+>

teleport_random :: QIO BoolSource

teleports a qubit in the state |+>, and then measures it.

u :: (Bool -> Bool) -> Qbit -> Qbit -> USource

The implementation of Deutsch's algorithm requires a unitary to represent the oracle function.

deutsch :: (Bool -> Bool) -> QIO BoolSource

Deutsch's algorithm takes an oracle function, and returns a Boolean that states whether the given function is balanced, or consant.

problem :: QIO BoolSource

A test QIO computation that is infinite in one measurement path. This is a problem if we try to calculate the probability distribution of possible results, as the infinite path will be followed.