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

Safe HaskellNone
LanguageHaskell2010

QIO.QExamples

Description

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

Synopsis

Documentation

q0 :: QIO Qbit Source #

Initialise a qubit in the |0> state

q1 :: QIO Qbit Source #

Initialise a qubit in the |1> state

qPlus :: QIO Qbit Source #

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

qMinus :: QIO Qbit Source #

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

randBit :: QIO Bool Source #

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

share :: Qbit -> QIO Qbit Source #

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 Bool Source #

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 Bool Source #

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 -> U Source #

A definition of the Pauli-Z gate.

bobsU :: (Bool, Bool) -> Qbit -> U Source #

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

bob :: Qbit -> (Bool, Bool) -> QIO Qbit Source #

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

teleportation :: Qbit -> QIO Qbit Source #

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 Qbit Source #

teleports a qubit in the state |1>

teleport_true :: QIO Bool Source #

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

teleport_random' :: QIO Qbit Source #

teleports a qubit in the state |+>

teleport_random :: QIO Bool Source #

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

u :: (Bool -> Bool) -> Qbit -> Qbit -> U Source #

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

deutsch :: (Bool -> Bool) -> QIO Bool Source #

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

problem :: QIO Bool Source #

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.