The Quipper System

Safe HaskellNone

Quipper.Utils.Stabilizers.Clifford

Contents

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 = Int Source #

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.

Instance details

Defined in Quipper.Utils.Stabilizers.Clifford

next_qubit :: Tableau -> Qubit Source #

Accessor function for the next_qubit field of a Tableau

sign :: Tableau -> Map Qubit Sign Source #

Accessor function for the sign field of a Tableau

tableau :: Tableau -> Map (Qubit, Qubit) Pauli Source #

Accessor function for the tableau field of a Tableau

de_sign :: Tableau -> Map Qubit Sign Source #

Accessor function for the de_sign field of a Tableau

de_tableau :: Tableau -> Map (Qubit, Qubit) Pauli Source #

Accessor function for the de_tableau field of a Tableau

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

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

empty_tableau :: Tableau Source #

An initial (empty) tableau.

add_qubit :: Bool -> Tableau -> Tableau Source #

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

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

from_matrix :: (Floating r, Eq r, Show r) => Matrix1 (Cplx r) -> Unitary Source #

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

apply_unitary :: Unitary -> Qubit -> Tableau -> Tableau Source #

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

apply_unitary_row :: Unitary -> Qubit -> Tableau -> Qubit -> Tableau Source #

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

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

from_matrix2 :: (Floating r, Eq r, Show r) => Matrix2 (Cplx r) -> Unitary2 Source #

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

from_matrix_controlled :: (Floating r, Show r, Eq r) => Matrix1 (Cplx r) -> Unitary2 Source #

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

apply_unitary2 :: Unitary2 -> (Qubit, Qubit) -> Tableau -> Tableau Source #

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

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

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

multiply_de :: Qubit -> Qubit -> Tableau -> Tableau Source #

Multiply row1 of the destabilizer by row2 of the stabilizer.

x :: Unitary Source #

The Pauli X operator is a Clifford group unitary.

x_min :: MinUnitary Source #

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

x' :: Unitary Source #

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

x'' :: Unitary Source #

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

y :: Unitary Source #

The Pauli Y-operator is a Clifford group unitary.

y_min :: MinUnitary Source #

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

y' :: Unitary Source #

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

y'' :: Unitary Source #

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

z :: Unitary Source #

The Pauli Z-operator is a Clifford group unitary.

z_min :: MinUnitary Source #

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

z' :: Unitary Source #

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

z'' :: Unitary Source #

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

h :: Unitary Source #

The Hadamard-gate is a Clifford group unitary.

h_min :: MinUnitary Source #

We can (equivalently) define Hadamard as a MinUnitary.

h' :: Unitary Source #

We can (equivalently) construct Hadamard from a MinUnitary.

h'' :: Unitary Source #

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

s :: Unitary Source #

The phase-gate is a Clifford group unitary.

s_min :: MinUnitary Source #

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

s' :: Unitary Source #

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

s'' :: Unitary Source #

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

e :: Unitary Source #

The phase-gate is a Clifford group unitary.

e_min :: MinUnitary Source #

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

e' :: Unitary Source #

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

e'' :: Unitary Source #

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

cnot :: Unitary2 Source #

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

cnot_min :: MinUnitary2 Source #

We can (equivalently) define CNot as a MinUnitary2.

cnot' :: Unitary2 Source #

We can (equivalently) construct CNot from a MinUnitary2.

cnot'' :: Unitary2 Source #

We can (equivalently) construct CNot from a matrix.

cz :: Unitary2 Source #

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

cz_min :: MinUnitary2 Source #

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

cz' :: Unitary2 Source #

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

cz'' :: Unitary2 Source #

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

type CliffordCirc a = StateT Tableau IO a Source #

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

init_qubit :: Bool -> CliffordCirc Qubit Source #

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

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

Return the evaluated Tableau for the given circuit.

sim :: CliffordCirc a -> IO a Source #

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

A simple, single qubit, teleportation circuit.

test_teleport :: Bool -> CliffordCirc Bool Source #

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

random_bool :: CliffordCirc Bool Source #

Measure an equal superposition.

Orphan instances

Eq Unitary2 # 
Instance details

Eq Unitary # 
Instance details

Methods

(==) :: Unitary -> Unitary -> Bool #

(/=) :: Unitary -> Unitary -> Bool #