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

QIO.QExamples

Description

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

Synopsis

Documentation

Initialise a qubit in the |0> state

Initialise a qubit in the |1> state

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

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

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

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.

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

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.

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.

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

The overall QIO computation that teleports the state of single qubit

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

teleports a qubit in the state |1>

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

teleports a qubit in the state |+>

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.

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.