Safe Haskell | None |
---|
The BWT Oracle, written in a classical, functional manner and automatically transformed to a quantum circuit using Quipper's "build_circuit" mechanism.
Synopsis
- boollist_xor :: [Bool] -> [Bool] -> [Bool]
- template_boollist_xor :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- bit_adder :: Bool -> (Bool, Bool, Bool) -> (Bool, Bool)
- template_bit_adder :: Circ (Qubit -> Circ ((Qubit, Qubit, Qubit) -> Circ (Qubit, Qubit)))
- parent :: Node -> Node
- template_parent :: Circ ((a, [Qubit]) -> Circ (a, [Qubit]))
- childintree :: Node -> Bool -> Node
- template_childintree :: Circ ((a1, [a2]) -> Circ (a2 -> Circ (a1, [a2])))
- doweld1 :: Boollist -> Bool -> [Bool] -> [Bool]
- template_doweld1 :: Circ ([Qubit] -> Circ (Qubit -> Circ ([Qubit] -> Circ [Qubit])))
- doweld0 :: Boollist -> [Bool] -> [Bool]
- template_doweld0 :: Circ ([Qubit] -> Circ ([Qubit] -> Circ [Qubit]))
- weld :: Boollist -> Boollist -> Node -> Bool -> Node
- template_weld :: Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit -> Circ (Qubit, [Qubit])))))
- child :: Boollist -> Boollist -> Node -> Bool -> Node
- template_child :: Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit -> Circ (Qubit, [Qubit])))))
- level_parity :: [Bool] -> Bool
- template_level_parity :: Circ ([Qubit] -> Circ Qubit)
- is_zero :: [Bool] -> Bool
- template_is_zero :: Circ ([Qubit] -> Circ Qubit)
- is_root :: [Bool] -> Bool
- template_is_root :: Circ ([Qubit] -> Circ Qubit)
- v_function :: BoolParam -> BoolParam -> Boollist -> Boollist -> Node -> (Bool, Node)
- template_v_function :: Circ (BoolParam -> Circ (BoolParam -> Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit, (Qubit, [Qubit])))))))
- type Color = Int
- colorToBoolParam :: Color -> (BoolParam, BoolParam)
- classical_BWT_oracle :: Color -> ([Qubit], [Qubit], QNode) -> Circ (Qubit, QNode)
- reversible_BWT_oracle :: Color -> (([Qubit], [Qubit], QNode), (Qubit, QNode)) -> Circ (([Qubit], [Qubit], QNode), (Qubit, QNode))
- reversible_BWT_oracle_optim :: Color -> (([Qubit], [Qubit], QNode), (Qubit, QNode)) -> Circ (([Qubit], [Qubit], QNode), (Qubit, QNode))
- oracle_template :: [Bool] -> [Bool] -> Oracle
- oracle_template_optim :: [Bool] -> [Bool] -> Oracle
Circuit building functions
This section contains an implementation of the oracle as a
collection of ordinary functional programs. Each function in this
section is decorated with the build_circuit
keyword (see
Quipper.Internal.CircLifting). Therefore, circuits are
automatically generated; for example, the circuit corresponding to
the function v_function
is automatically built and given the name
template_v_function
.
General operations on booleans
Encoding the BWT oracle on booleans and lists of booleans
parent :: Node -> Node Source #
Input a node a and return the parent of a. We assume that a is not a root or invalid.
doweld1 :: Boollist -> Bool -> [Bool] -> [Bool] Source #
Input an n+1-bit leaf node a:aa (without the tree bit; a
is the highest bit and aa is the remaining n bits) and a sign
s (where True
= negative, False
= positive). Return
a:(aa + s * f). The first input is the n-bit welding
vector f (a parameter to the oracle). Note that f is a
parameter and s, aa are inputs.
doweld0 :: Boollist -> [Bool] -> [Bool] Source #
Input an n+1-bit leaf node a:aa (without the tree bit), and return a:(aa ⊕ g). The first input is the n-bit welding vector g (a parameter to the oracle).
template_weld :: Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit -> Circ (Qubit, [Qubit]))))) Source #
template_child :: Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit -> Circ (Qubit, [Qubit]))))) Source #
level_parity :: [Bool] -> Bool Source #
is_root :: [Bool] -> Bool Source #
Input a node address (without the tree bit) and return True
iff
the node is a root or invalid. In other words, check whether all
digits but the last are 0's.
:: BoolParam | First color bit. |
-> BoolParam | Second color bit. |
-> Boollist | Vector f from Equation (26). |
-> Boollist | Vector g from Equation (27). |
-> Node | Entry node a. |
-> (Bool, Node) |
: returns vsub /c/, the label of the
node connected to a by an edge of color c, or v_function
f g c aNothing
if
there is no such node. The parameters f and g encode the
welding functions, and are lists of length n. c is a color in
the range 0..3, and a is an (n+2)-bit node label.
template_v_function :: Circ (BoolParam -> Circ (BoolParam -> Circ ([Qubit] -> Circ ([Qubit] -> Circ ((Qubit, [Qubit]) -> Circ (Qubit, (Qubit, [Qubit]))))))) Source #
Wrapping it into the Oracle data type
The following functions package the circuit generated by
v_function
into a data structure of type Oracle
.
Colors
colorToBoolParam :: Color -> (BoolParam, BoolParam) Source #
Convert an integer representation of a color into the two-bit representation.
Functions for using the generated oracle
:: Color | The color. |
-> ([Qubit], [Qubit], QNode) | The two welding vectors and a node a. |
-> Circ (Qubit, QNode) | Output (r,b). |
This is the irreversible classical circuit generated from
v_function
. This is basically the same as template_v_function
,
except that excessive uses of Circ
are removed from the type, and
the inputs and outputs have been reorganized.
reversible_BWT_oracle Source #
:: Color | Color. |
-> (([Qubit], [Qubit], QNode), (Qubit, QNode)) | (f, g, a, r, b). |
-> Circ (([Qubit], [Qubit], QNode), (Qubit, QNode)) | Output (f, g, a, r, b). |
This is the reversible circuit automatically generated from classical_BWT_oracle
.
reversible_BWT_oracle_optim Source #
:: Color | Color. |
-> (([Qubit], [Qubit], QNode), (Qubit, QNode)) | (f, g, a, r, b). |
-> Circ (([Qubit], [Qubit], QNode), (Qubit, QNode)) | Output (f, g, a, r, b). |
This is the reversible circuit automatically generated from classical_BWT_oracle
, and optimized with peep-hole optimization.