Safe Haskell | None |
---|
This module provides some operations for low-level manipulation of classical circuits. It is built directly on top of Quipper.Internal.Circuit.
Synopsis
- cgate_to_cnot_transformer :: Transformer Circ Qubit Bit
- translate_cgate :: String -> Bit -> [Bit] -> Circ ()
- classical_to_cnot :: (QCData qa, QCData qb, QCurry qfun qa qb) => qfun -> qfun
- trivial_endpoint :: B_Endpoint Qubit Qubit -> Qubit
- classical_to_quantum_transformer :: Transformer Circ Qubit Qubit
- classical_to_quantum_unary :: (QCData qa, QCData qb) => (qa -> Circ qb) -> QType qa -> Circ (QType qb)
- classical_to_quantum :: (QCData qa, QCData qb, QCurry qfun qa qb, QCurry qfun' (QType qa) (QType qb)) => qfun -> qfun'
- classical_to_reversible :: (QCData qa, QCData qb) => (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb)
Manipulation of classical circuits
Eliminating CGate
cgate_to_cnot_transformer :: Transformer Circ Qubit Bit Source #
A Transformer
to eliminate all CGate
style gates, such as "and", "or", "not", "xor", "eq", and
"if-then-else" gates, and replace them by equivalent
CInit
and
CNot
gates.
translate_cgate :: String -> Bit -> [Bit] -> Circ () Source #
Auxiliary function: compute the reversible circuit corresponding
to a CGate
of the given name, using only
controlled-not gates.
classical_to_cnot :: (QCData qa, QCData qb, QCurry qfun qa qb) => qfun -> qfun Source #
Translate all classical gates in a circuit into equivalent controlled-not gates.
The type of this overloaded function is difficult to read. In more readable form, it has all of the following types:
classical_to_cnot :: (QCData qa) => Circ qa -> Circ qa classical_to_cnot :: (QCData qa, QCData qb) => (qa -> Circ qb) -> (qa -> Circ qb) classical_to_cnot :: (QCData qa, QCData qb, QCData qc) => (qa -> qb -> Circ qc) -> (qa -> qb -> Circ qc)
and so forth.
Classical to quantum
trivial_endpoint :: B_Endpoint Qubit Qubit -> Qubit Source #
Map an endpoint to the underlying Qubit
in the trivial
case. Auxiliary function.
classical_to_quantum_transformer :: Transformer Circ Qubit Qubit Source #
A Transformer
to replace all classical gates in a circuit by
equivalent quantum gates.
classical_to_quantum_unary :: (QCData qa, QCData qb) => (qa -> Circ qb) -> QType qa -> Circ (QType qb) Source #
Replace all classical gates in a circuit by equivalent quantum gates.
classical_to_quantum :: (QCData qa, QCData qb, QCurry qfun qa qb, QCurry qfun' (QType qa) (QType qb)) => qfun -> qfun' Source #
Replace all classical gates in a circuit by equivalent quantum gates.
The type of this overloaded function is difficult to read. In more readable form, it has all of the following types:
classical_to_quantum :: (QCData qa) => Circ qa -> Circ (QType qa) classical_to_quantum :: (QCData qa, QCData qb) => (qa -> Circ qb) -> (QType qa -> Circ (QType qb)) classical_to_quantum :: (QCData qa, QCData qb, QCData qc) => (qa -> qb -> Circ qc) -> (QType qa -> QType qb -> Circ (QType qc))
and so forth.
Classical to reversible
classical_to_reversible :: (QCData qa, QCData qb) => (qa -> Circ qb) -> (qa, qb) -> Circ (qa, qb) Source #
Generic function for turning a classical (or pseudo-classical)
circuit into a reversible circuit. The input is a classical boolean
function x ↦ f(x), given as a not necessarily reversible
circuit (however, the circuit should be one-to-one, i.e., no
"garbage" should be explicitly erased). The output is the
corresponding reversible function (x,y) ↦ (x,y ⊕
f(x)). qa and qb can be any quantum data types. The
function classical_to_reversible
does not itself change
classical bits to qubits; use classical_to_quantum
for that.