We model all instructions (gates) as
Name | Interpret | F |
---|---|---|
I | Add 0 to Ans | F() = 0 |
Not, X | Add 1 to Ans | F() = 1 |
Controlled-Not, CNOT, XNOT | Add x_1 to Ans | F(x_1) = x_1 |
C_0NOT | Add NOT x_1 to Ans | F(x_1) = \lnot x_1 |
Controlled-CNot CCNOT, Toffoli | Add x_1 \land x_2 to Ans | F(x_1, x_2) = x_1 \land x_2 |
N/A | Add x_1 \lor x_2 to Ans | F(x_1, x_2) = x_1 \lor x_2 |
Swap | Swap A with B | L/R Shift on 2 bits |
Any truth table can be built by circuit
with n \cdot m \cdot 2^n gates (by brute force: use NOT to make input all 0s, combine them using OR, if target is 1, then use another NOT, else do nothing)
or with m \cdot 2^n/n gates (C. Shannon)
Any circuit can be converted to reversible manner, except for creating zero-ed input.
Theorem: \forall F: \{0, 1\}^n \to \{0, 1\}^m if it is computable with G classical gates, then you can convert to reversible quantum gates with n+m+G qubits and G+n gates, assuming all extra G bits are initialized to 0, left in a garbage state.
Theorem: reduction from turing machine to gates is only polynomial slowdown.
DeMorgan's Law: you only need NOT
and one of AND
or OR
gate to perform all deterministic binary operation (Note that TM-complete also requires random access infinite memory)
one should be able to construct a NAND
gate, so you can then build a XOR
gate. With XOR
and AND
you can build a half-adder. Combine half-adders to build a full-adder.
Any NAND
-based circuit can be rebuilt using NOR
s exclusively and vice versa.
CCNOT(X,Y,Z)
: "Add (X AND Y) To Z", equivalent of AND
gate in quantum, but if we allow Z
to be 1, it is NAND
gate (because we are adding, instead of setting like classical computer).
inverse is itself
it is an AND
gate when Z
is 0
it is an NAND
gate when Z
is 1
it is a COPY Y Z
when X
is 1 and Z
is 0
Why get rid of trash?
wasting spacetime to keep temporary variables from last computation, since they can only be used once set to zero
garbage prevents cancelation of amplitudes in joined quantum state
Example: say we have a qubit a along with some other qubits q_0, ..., q_n
When all q_0, ..., q_n are deterministic, then we might have the following state: (result of H(0))
\begin{align*} \text{Amplitude}(0, 0...0)=&\sqrt{1/2}\\ \text{Amplitude}(1, 0...0)=&\sqrt{1/2}\\ \end{align*}Then we do a H gate, we have: (result of H(H(0)) = 0)
\begin{align*} \text{Amplitude}(0, 0...0)=&\frac{1}{2}+\frac{1}{2}=1\\ \text{Amplitude}(1, 0...0)=&\frac{1}{2}-\frac{1}{2}=0\\ \text{Probability}(0, 0...0)=&1^2=1\\ \text{Probability}(1, 0...0)=&0^2=0\\ \end{align*}which is all good.
However, if at least one of q_0, ..., q_n are non-deterministic garbage, then the amplitude will perhaps look like: (where the first and last bit of trash is entangled with the qubit we care about)
\begin{align*} \text{Amplitude}(0, 1...0)=&\sqrt{1/2}\\ \text{Amplitude}(1, 0...1)=&\sqrt{1/2}\\ \end{align*}Then we do a H gate, we have
\begin{align*} \text{Amplitude}(0, 1...0)=&\frac{1}{2}\\ \text{Amplitude}(1, 0...1)=&\frac{1}{2}\\ \text{Amplitude}(0, 0...0)=&\frac{1}{2}\\ \text{Amplitude}(1, 0...0)=&-\frac{1}{2}\\ \text{Probability}(0, 1...0)=&\left(\frac{1}{2}\right)^2=\frac{1}{4}\\ \text{Probability}(1, 0...1)=&\left(\frac{1}{2}\right)^2=\frac{1}{4}\\ \text{Probability}(0, 0...0)=&\left(\frac{1}{2}\right)^2=\frac{1}{4}\\ \text{Probability}(1, 0...0)=&\left(-\frac{1}{2}\right)^2=\frac{1}{4}\\ \end{align*}Note that none of the states above can be merged, therefore we observe 0 and 1 half of the time.
Easy. We just reverse (inverse) all the instruction except for the last where we add the answer.
Precondition: all tmp
variables initialized to zero
Intermediate: answer is good, but tmp
variables are garbage
Postcondition: answer is good, all tmp
variables set to zero
We can always transform classical circuit with G gates to deterministic, reversible, garbage-free gates with \leq 2 \cdot G gates.
When we measure, we use one particle, say |m\rangle, to interact with another partical |v\rangle we want to measure. If we don't keep track of |m\rangle, it will look like we have measured |v\rangle. But what it really does is |m\rangle becomes entangled with |v\rangle, and since we lost track of |m\rangle, it becomes garbage. In math, you can write:
Say you have a qubit you want to measure:
Then you collide |v\rangle with |m\rangle, and it produces some maximally entangled particle, say:
Let us have a measurement device that measure only qubit |v\rangle in |Rot_{45^\circ}\rangle, |Rot_{135^\circ}\rangle, then we have
So we subsitute above into |vm\rangle:
Now, see we have 50\% chance to measure to |Rot_{45^\circ}\rangle or |Rot_{135^\circ}\rangle. But clearly, if we just measure unentangled |v\rangle, we get 100\% chance to |Rot_{45^\circ}\rangle
Takeaway: the "measurement" happen because you don't have access to |m\rangle while trying to understand |v\rangle. (inspired by this video)
Table of Content