You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: qualtran/bloqs/basic_gates/toffoli.ipynb
+99-3Lines changed: 99 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -141,13 +141,109 @@
141
141
"show_counts_sigma(toffoli_sigma)"
142
142
]
143
143
},
144
+
{
145
+
"cell_type": "markdown",
146
+
"id": "dc13c6f1-86b7-4a0b-9b4a-e7f3ed67e3a6",
147
+
"metadata": {},
148
+
"source": [
149
+
"## Controlled\n",
150
+
"\n",
151
+
"We use `Toffoli` for specifically two control bits of the `XGate`. Requesting `Toffoli().controlled(ctrl_spec)` will give an instance of the generic `ControlledViaAnd(XGate(), ...)` bloq, which will control the `XGate` on an arbitrary boolean function supported by `CtrlSpec`. The set of control registers present on the resulting bloq will 1) the control registers needed for the provided `ctrl_spec` and 2) one additional `QBit()[2]` register for the original Toffoli control bits."
"The `Toffoli().controlled()` method (and in general, the `.controlled()` method for any bloq object) returns a bloq that implements a controlled version of the original gate. The returned bloq can structure its signature however it chooses. You can see that `Toffoli.controlled()` returns a `ControlledViaAnd(XGate(), ...)` which names its control registers `ctrl{n}` with the final one corresponding to the original Toffoli control bits. \n",
208
+
"\n",
209
+
"When writing meta-bloqs that need to support adding arbitrarily-controlled versions of Toffoli to a decomposition, you should not rely on any particular signature. `Bloq.get_ctrl_system()` is the method for automatically `bb.add`-ing controlled versions of arbitrary bloqs. We demonstrate that below."
0 commit comments