The Quipper System

Safe HaskellNone

QuipperLib.Decompose

Contents

Description

Functions to decompose circuits into various gate bases.

Synopsis

Gate bases

data GateBase Source

An enumeration type for gate bases. More cases can be added in the future, for example for using gates from a particular physical machine description.

Some gate bases carry additional parameters; for example, in the case of decomposition into a discrete gate base, one may specify a precision ε, a random seed, or other flags.

If a Precision parameter is present, it specifies the desired precision per gate. If a RandomSource parameter is present, it specifies a source of randomness.

Constructors

Logical

Use all logical gates, i.e., leave the circuit unchanged.

Binary

Decompose into binary gates.

Toffoli

Decompose into Toffoli and binary gates.

CliffordT_old

Decompose into Clifford+T. This is a legacy transformer that does not handle all gates correctly. For example, it does not handle W-gates, rotations, or phase gates. Use CliffordT instead.

CliffordT Precision RandomSource

Decompose into Clifford+T, specifically: single-qubit Clifford gates, the controlled-not gate (with positive or negative controls), and the gates T and T.

Strict Precision RandomSource

Decompose into H, S, T, CNOT gates only. Suppresses global phases.

Approximate Precision RandomSource

Decompose rotation and phase gates into Clifford+T, using an approximate synthesis algorithm. Other gates are unchanged.

Exact

Decompose gates that can be exactly represented in the Clifford+T base into that base, specifically: single-qubit Clifford gates, the controlled-not gate (with positive or negative controls), and the gates T and T. Leave rotation and phase gates unchanged.

TrimControls

Eliminate excess controls from gates.

Instances

gatebase_enum :: [(String, GateBase)]Source

An assignment of gate bases to names. Names are given as lower-case strings.

This can be useful, e.g., in the definition of command line options.

In the future, the syntax should be extended so that users can specify parameters (e.g., the precision, random seed) on the command line as well. For now, we just use the default precision.

Generic decomposition

decompose_generic :: (QCData qa, QCData qb, QCurry qfun qa qb) => GateBase -> qfun -> qfunSource

Decompose a circuit into gates from the given GateBase. This can be applied to a circuit-generating function in curried form with n arguments, for any n ≥ 0.

The type of this heavily overloaded function is difficult to read. In more readable form, it has all of the following types:

 decompose_generic :: (QCData qa) => GateBase -> Circ qa -> Circ qa
 decompose_generic :: (QCData qa, QCData qb) => GateBase -> (qa -> Circ qb) -> (qa -> Circ qb)
 decompose_generic :: (QCData qa, QCData qb, QCData qc) => GateBase -> (qa -> qb -> Circ qc) -> (qa -> qb -> Circ qc)

and so forth.