The Quipper System

Safe HaskellNone

Libraries.Stabilizers.Clifford

Description

This module contains an implementation of a quantum simulator that uses the stabilizer states of the Clifford group (i.e. the Pauli group), to provide efficient simulation of quantum circuits constructed from elements of the Clifford group. The module provides an implementation of the Clifford group operators {x,y,z,h,s,controlled-x} which form a generating set for the Clifford group.

Synopsis

Documentation

type Qubit = IntSource

A qubit is defined as an integer reference.

data Tableau Source

The state of the system is a representation of a stabilizer tableau.

Constructors

ST Qubit !(Map Qubit Sign) !(Map (Qubit, Qubit) Pauli) !(Map Qubit Sign) !(Map (Qubit, Qubit) Pauli) 

Instances

Show Tableau

A tableau can be shown, by enumerating over the qubits in scope.

next_qubit :: Tableau -> QubitSource

Accessor function for the next_qubit field of a Tableau

sign :: Tableau -> Map Qubit SignSource

Accessor function for the sign field of a Tableau

tableau :: Tableau -> Map (Qubit, Qubit) PauliSource

Accessor function for the tableau field of a Tableau

de_sign :: Tableau -> Map Qubit SignSource

Accessor function for the de_sign field of a Tableau

de_tableau :: Tableau -> Map (Qubit, Qubit) PauliSource

Accessor function for the de_tableau field of a Tableau

lookup :: (Ord k, Show k, Show v) => k -> Map k v -> vSource

A local Map lookup function that throws an error if the key doesn't exist.

empty_tableau :: TableauSource

An initial (empty) tableau.

add_qubit :: Bool -> Tableau -> TableauSource

A new qubit in the state |0〉 or |1〉 can be added to a tableau.

type Unitary = Pauli -> (Sign, Pauli)Source

A (Clifford) unitary can be defined as a function acting on Pauli operators.

data MinPauli Source

The minimal definition of a unitary requires the actions on X and Z.

Constructors

Xmin 
Zmin 

type MinUnitary = MinPauli -> (Sign, Pauli)Source

The minimal definition of a unitary requires the actions on X and Z.

from_minimal :: MinUnitary -> UnitarySource

The definition of a Unitary can be constructed from a MinimalUnitary.

from_matrix :: (Floating r, Eq r, Show r) => Matrix1 (Cplx r) -> UnitarySource

It is possible to construct a Unitary from a 2×2-matrix.

apply_unitary :: Unitary -> Qubit -> Tableau -> TableauSource

A unitary can be applied to a qubit in a given tableau. By folding through each row

apply_unitary_row :: Unitary -> Qubit -> Tableau -> Qubit -> TableauSource

Apply the unitary to the given column, in the given row.

type Unitary2 = (Pauli, Pauli) -> (Sign, Pauli, Pauli)Source

A two-qubit (Clifford) unitary can be defined as a function acting on a pair of Pauli operators.

data MinPauli2 Source

The minimal definition of a two-qubit unitary requires the actions on IX, XI, IZ, and ZI.

Constructors

IX 
XI 
IZ 
ZI 

type MinUnitary2 = MinPauli2 -> (Sign, Pauli, Pauli)Source

The minimal definition of a two-qubit unitary requires the actions on IX, XI, IZ, and ZI.

from_minimal2 :: MinUnitary2 -> Unitary2Source

The definition of a Unitary2 can be constructed from a MinimalUnitary2.

from_matrix2 :: (Floating r, Eq r, Show r) => Matrix2 (Cplx r) -> Unitary2Source

It is possible to construct a Unitary2 from a 4×4-matrix.

from_matrix_controlled :: (Floating r, Show r, Eq r) => Matrix1 (Cplx r) -> Unitary2Source

It is possible to construct a Unitary2 from controlling a 2×2-matrix.

apply_unitary2 :: Unitary2 -> (Qubit, Qubit) -> Tableau -> TableauSource

A two-qubit unitary can be applied to a pair of qubits in a given tableau.

measure :: Qubit -> Tableau -> IO (Bool, Tableau)Source

A measurement, in the computational basis, can be made of a qubit in the Tableau, returning the measurement result, and the resulting Tableau.

reduce :: Qubit -> Tableau -> TableauSource

This function reduces a tableau so that it contains either plus or minus Zq. Note that it is only called in the case where Zq is generated by the tableau (i.e., during measurement).

multiply :: Qubit -> Qubit -> Tableau -> TableauSource

Multiply the stabilizers for the two given rows, in the given tableau, and update the first row with the result of the multiplication.

x :: UnitarySource

The Pauli X operator is a Clifford group unitary.

x_min :: MinUnitarySource

We can (equivalently) define Pauli-X as a MinUnitary.

x' :: UnitarySource

We can (equivalently) construct Pauli-X from a MinUnitary.

x'' :: UnitarySource

We can (equivalently) construct Pauli-X from a matrix.

y :: UnitarySource

The Pauli Y-operator is a Clifford group unitary.

y_min :: MinUnitarySource

We can (equivalently) define Pauli-Y as a MinUnitary.

y' :: UnitarySource

We can (equivalently) construct Pauli-Y from a MinUnitary.

y'' :: UnitarySource

We can (equivalently) construct Pauli-Y from a matrix.

z :: UnitarySource

The Pauli Z-operator is a Clifford group unitary.

z_min :: MinUnitarySource

We can (equivalently) define Pauli-Z as a MinUnitary.

z' :: UnitarySource

We can (equivalently) construct Pauli-Z from a MinUnitary.

z'' :: UnitarySource

We can (equivalently) construct Pauli-Z from a matrix.

h :: UnitarySource

The Hadamard-gate is a Clifford group unitary.

h_min :: MinUnitarySource

We can (equivalently) define Hadamard as a MinUnitary.

h' :: UnitarySource

We can (equivalently) construct Hadamard from a MinUnitary.

h'' :: UnitarySource

We can (equivalently) construct Hadamard from a matrix. Although rounding errors break this!!!

s :: UnitarySource

The phase-gate is a Clifford group unitary.

s_min :: MinUnitarySource

We can (equivalently) define phase gate as a MinUnitary.

s' :: UnitarySource

We can (equivalently) construct phase gate from a MinUnitary.

s'' :: UnitarySource

We can (equivalently) construct phase gate from a matrix.

e :: UnitarySource

The phase-gate is a Clifford group unitary.

e_min :: MinUnitarySource

We can (equivalently) define phase gate as a MinUnitary.

e' :: UnitarySource

We can (equivalently) construct phase gate from a MinUnitary.

e'' :: UnitarySource

We can (equivalently) construct phase gate from a matrix.

cnot :: Unitary2Source

The controlled-not is a Clifford group 2-qubit unitary.

cnot_min :: MinUnitary2Source

We can (equivalently) define CNot as a MinUnitary2.

cnot' :: Unitary2Source

We can (equivalently) construct CNot from a MinUnitary2.

cnot'' :: Unitary2Source

We can (equivalently) construct CNot from a matrix.

cz :: Unitary2Source

The controlled-Z is a Clifford group 2-qubit unitary.

cz_min :: MinUnitary2Source

We can (equivalently) define controlled-Z as a MinUnitary2.

cz' :: Unitary2Source

We can (equivalently) construct controlled-Z from a MinUnitary2.

cz'' :: Unitary2Source

We can (equivalently) construct controlled-Z from a matrix.

type CliffordCirc a = StateT Tableau IO aSource

A Clifford group circuit is implicitly simulated using a state monad over a Tableau.

init_qubit :: Bool -> CliffordCirc QubitSource

Initialize a new qubit.

init_qubits :: [Bool] -> CliffordCirc [Qubit]Source

Initialize multiple qubits.

gate_X :: Qubit -> CliffordCirc ()Source

Apply a Pauli-X gate to the given qubit.

gate_Y :: Qubit -> CliffordCirc ()Source

Apply a Pauli-Y gate to the given qubit.

gate_Z :: Qubit -> CliffordCirc ()Source

Apply a Pauli-Z gate to the given qubit.

gate_H :: Qubit -> CliffordCirc ()Source

Apply a Hadamard gate to the given qubit.

gate_S :: Qubit -> CliffordCirc ()Source

Apply a phase gate to the given qubit.

gate_Unitary :: Unitary -> Qubit -> CliffordCirc ()Source

Apply a given Unitary to the given qubit.

controlled_X :: Qubit -> Qubit -> CliffordCirc ()Source

Apply a controlled-X gate to the given qubits.

controlled_Z :: Qubit -> Qubit -> CliffordCirc ()Source

Apply a controlled-Z gate to the given qubits.

gate_Unitary2 :: Unitary2 -> Qubit -> Qubit -> CliffordCirc ()Source

Apply a given Unitary2 to the given qubits

measure_qubit :: Qubit -> CliffordCirc BoolSource

Measure the given qubit in the computational basis.

measure_qubits :: [Qubit] -> CliffordCirc [Bool]Source

Measure the given list of qubits.

show_tableau :: CliffordCirc ()Source

For testing purposes, we can show the tableau during a simulation.

eval :: CliffordCirc a -> IO TableauSource

Return the evaluated Tableau for the given circuit.

sim :: CliffordCirc a -> IO aSource

Return the result of simulating the given circuit.

swap :: Qubit -> Qubit -> CliffordCirc ()Source

A swap gate can be defined in terms of three controlled-not gates.

controlled_Z' :: Qubit -> Qubit -> CliffordCirc ()Source

A controlled-Z gate can (equivalently) be defined in terms of Hadamard and controlled-X.

bell :: (Bool, Bool) -> CliffordCirc (Qubit, Qubit)Source

Each of the four Bell states can be generated, indexed by a pair of boolean values.

measure_bell00 :: CliffordCirc (Bool, Bool)Source

Create a Bell state, and measure it.

controlled_if :: Bool -> (Qubit -> CliffordCirc ()) -> Qubit -> CliffordCirc ()Source

A single-qubit operation can be controlled by a classical boolean value.

teleport :: Qubit -> CliffordCirc QubitSource

A simple, single qubit, teleportation circuit.

test_teleport :: Bool -> CliffordCirc BoolSource

A wrapper around the teleportation circuit that initializes a qubit in the given boolean state, and measures the teleported qubit.

random_bool :: CliffordCirc BoolSource

Measure an equal superposition.