Safe Haskell | None |
---|
Algorithms.BWT.Template
Contents
Description
The BWT Oracle, written in a classical, functional manner and automatically transformed to a quantum circuit using Quipper's "build_circuit" mechanism.
- boollist_xor :: [Bool] -> [Bool] -> [Bool]
- bit_adder :: Bool -> (Bool, Bool, Bool) -> (Bool, Bool)
- parent :: Node -> Node
- childintree :: Node -> Bool -> Node
- doweld1 :: Boollist -> Bool -> [Bool] -> [Bool]
- doweld0 :: Boollist -> [Bool] -> [Bool]
- weld :: Boollist -> Boollist -> Node -> Bool -> Node
- child :: Boollist -> Boollist -> Node -> Bool -> Node
- level_parity :: [Bool] -> Bool
- is_zero :: [Bool] -> Bool
- is_root :: [Bool] -> Bool
- v_function :: BoolParam -> BoolParam -> Boollist -> Boollist -> Node -> (Bool, Node)
- 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.CircLifting). Therefore, circuits are
automatically generated; for example, the circuit corresponding to
the function bwt_oracle
is automatically built and given the name
template_bwt_oracle
.
General operations on booleans
boollist_xor :: [Bool] -> [Bool] -> [Bool]Source
Exclusive or operation on bit vectors.
Encoding the BWT oracle on booleans and lists of booleans
Input a node a and return the parent of a. We assume that a is not a root or invalid.
childintree :: Node -> Bool -> NodeSource
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).
level_parity :: [Bool] -> BoolSource
is_root :: [Bool] -> BoolSource
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.
Arguments
:: 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 vc(a), 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.
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
Arguments
:: 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.
Arguments
:: 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_optimSource
Arguments
:: 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.
oracle_template :: [Bool] -> [Bool] -> OracleSource
The template oracle, packaged into the Oracle
abstraction. Note
that this circuit is automatically generated from the classical
functions above, but is completely unoptimized. This oracle has two
parameters, namely the welding vectors f and g.
oracle_template_optim :: [Bool] -> [Bool] -> OracleSource
The template oracle, optimized.