Functions to decompose circuits into various gate bases.
- type Precision = Double
- bits :: Precision
- digits :: Precision
- type KeepPhase = Bool
- data GateBase
- gatebase_enum :: [(String, GateBase)]
- decompose_generic :: (QCData qa, QCData qb, QCurry qfun qa qb) => GateBase -> qfun -> qfun
A type to measure precision. Precision is expressed as a number b of bits, i.e., binary digits, so that ε = 2−b.
Binary digits, as a unit of precision. For example, the following specifies a precision of 20 binary digits:
prec = 20 * bits
Decimal digits, as a unit of precision. For example, the following specifies a precision of 30 decimal digits:
prec = 30 * digits
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.
Use all logical gates, i.e., leave the circuit unchanged.
Decompose into binary gates.
Decompose into Toffoli and binary gates.
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 KeepPhase 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†.
|Standard Precision RandomSource|
Decompose into the standard gate set, which we define to be X, Y, Z, H, S, S†, T, T†, and CNOT. Suppresses global phases.
|Strict Precision RandomSource|
Decompose into H, S, T, CNOT gates only. Suppresses global phases.
|Approximate KeepPhase Precision RandomSource|
Decompose rotation and phase gates into Clifford+T, using an approximate synthesis algorithm. Other gates are unchanged.
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.
Eliminate excess controls from gates.
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.
Decompose a circuit into gates from the given
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.