Prelude Reference
For simplicity, the types of the following library functions are annotated according to a width global analysis and depth local analysis. Please note that type annotations will likely be different when analysing other metrics.
Qubit handling
qinit0 :: ![1] Qubit{0}
Initialize a qubit in the basis state 0.
qinit1 :: ![1] Qubit{0}
Initialize a qubit in the basis state 1.
qdiscard :: )
Discard a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The qubit to discard. |
meas :: 
Measure a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The qubit to measure. |
Returns: a bit at depth d+1 containing the result of the measurement.
Bit handling
cinit0 :: ![1] Bit{0}
Initialize a bit in the 0 state.
cinit1 :: ![1] Bit{0}
Initialize a bit in the 1 state.
cdiscard :: )
Discard a bit b at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input bit. |
| Argument | Type | Description |
|---|---|---|
b |
Bit{d} |
The bit to discard. |
Single-qubit gates
hadamard :: 
Apply the Hadamard gate to a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The input qubit to Hadamard. |
Returns: a qubit at depth d+1.
qnot :: 
Apply the Pauli-X gate to a qubit q at depth d. This behaves like classical negation on the basis states.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The input qubit to Pauli-X. |
Returns: a qubit at depth d+1.
pauliY :: 
Apply the Pauli-Y gate to a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The input qubit to Pauli-Y. |
Returns: a qubit at depth d+1.
pauliZ :: 
Apply the Pauli-Z gate to a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The input qubit to Pauli-Z. |
Returns: a qubit at depth d+1.
tgate :: 
Apply the T gate to a qubit q at depth d.
| Parameter | Description |
|---|---|
d |
Maximum depth of the input qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The input qubit to the T gate. |
Returns: a qubit at depth d+1.
Controlled gates
cnot ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Apply the controlled-not gate to a control qubit ctrl at depth dctrl and a target qubit trgt at depth dtrgt.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control qubit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Qubit{dctrl} |
The control qubit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control and target qubits, both at depth max(dctrl, dtrgt) + 1.
cz ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Apply the controlled-Z gate to a control qubit ctrl at depth dctrl and a target qubit trgt at depth dtrgt.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control qubit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Qubit{dctrl} |
The control qubit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control and target qubits, both at depth max(dctrl, dtrgt) + 1.
toffoli ::  + 1}, Qubit{max(dctrl1, dctrl2, dtrgt) + 1}, Qubit{max(dctrl1, dctrl2, dtrgt) + 1}))
Apply the Toffoli gate to two control qubits ctrl1 and ctrl2 at depth dctrl1 and dctrl2, respectively, and a target qubit trgt at depth dtrgt.
| Parameter | Description |
|---|---|
dctrl1 |
Maximum depth of the first control qubit. |
dctrl2 |
Maximum depth of the second control qubit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl1 |
Qubit{dctrl1} |
The first control qubit. |
ctrl2 |
Qubit{dctrl2} |
The second control qubit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the two controls and the target qubit, all at depth max(dctrl1, dctrl2, dtrgt) + 1.
ccnot ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Apply the classically-controlled not gate to a control bit ctrl at depth dctrl and a target qubit trgt at depth dtrgt.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control bit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Bit{dctrl} |
The control bit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control bit and the target qubit, both at depth max(dctrl, dtrgt) + 1.
ccz ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Apply the classically-controlled Z gate to a control bit ctrl at depth dctrl and a target qubit trgt at depth dtrgt.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control bit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Bit{dctrl} |
The control bit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control bit and the target qubit, both at depth max(dctrl, dtrgt) + 1.
Parametric gates
rgate :: 
Parametric rotation gate. Apply a rotation of 2π/2^n radians around the Z-axis to a qubit q at depth d.
| Parameter | Description |
|---|---|
n |
Determines the angle of the rotation. |
d |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The qubit to rotate. |
Returns: a qubit at depth d+1.
invrgate :: 
Parametric rotation gate. Inverse of rgate. Apply a rotation of -2π/2^n radians around the Z-axis to a qubit q at depth d.
| Parameter | Description |
|---|---|
n |
Determines the angle of the rotation. |
d |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
q |
Qubit{d} |
The qubit to rotate. |
Returns: a qubit at depth d+1.
cr ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Parametric controlled rotation gate. Apply a rotation of 2π/2^n radians around the Z-axis to a control qubit ctrl at depth dctrl and a target qubit trgt at depth dtrgt. Note that this gate is symmetrical.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control qubit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Qubit{dctrl} |
The control qubit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control bit and the target qubit, both at depth max(dctrl, dtrgt) + 1.
invcr ::  + 1}, Qubit{max(dctrl, dtrgt) + 1}))
Parametric controlled rotation gate. Inverse of cr. Apply a rotation of -2π/2^n radians around the Z-axis to a control qubit ctrl at depth dctrl and a target qubit trgt at depth dtrgt. Note that this gate is symmetrical.
| Parameter | Description |
|---|---|
dctrl |
Maximum depth of the control qubit. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrl |
Qubit{dctrl} |
The control qubit. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Returns: the control bit and the target qubit, both at depth max(dctrl, dtrgt) + 1.
mcnot ::  + 1}, Qubit{max(dctrls, dtrgt) + 1}))
Multi-controlled not gate. Apply a controlled-not operation to a list ctrls of n control qubits at depth dctrls and a target qubit trgt at depth dtrgt.
Note: although each gate in this family counts as a single elementary gate, a physical implementation is not guaranteed to exist. Take this into account when reading the results of the tool, especially during gate count analysis.
| Parameter | Description |
|---|---|
n |
Number of control qubits. |
dctrls |
Maximum depth of the control qubits. |
dtrgt |
Maximum depth of the target qubit. |
| Argument | Type | Description |
|---|---|---|
ctrls |
List[i<n] Qubit{dctrls} |
The list of control qubits. |
trgt |
Qubit{dtrgt} |
The target qubit. |
Other
range :: )
Generate a list of unit values for iteration purposes.
| Parameter | Description |
|---|---|
n |
The desired length of the list. |
Returns: a list containing exactly n unit values.