CLASSICAL BOOLEAN GATES ----------------------- +-----+ x --->+ NOT +---> ¬x inverts the input, from 0 to 1, from 1 to 0 +-----+ +-----+ x --->+ | | AND +---> x ∧ y is 1 only if both x and y is 1, else 0 y --->+ | +-----+ +-----+ x --->+ | | OR +---> x ∨ y is 1 only if either x and y is 1, else 0 y --->+ | +-----+ +-----+ x --->+ | | XOR +---> x ⊕ y is 0 if x=y, else 1 y --->+ | +-----+
CIRCUIT COMPUTATION ------------------- +-----+ TRUTH TABLE x ----+ NOT +----+--------------- ¬x in out +-----+ | 00 → 11 | +-----+ 10 → 01 +---+ | 01 → 00 | XOR +----- ¬x ⊕ y 11 → 10 y -------------------+ | +-----+ PYTHON EQUIVALENT ----------------- def circuit(x,y): return f"{int(not x != y)}{int(not x)}" for x in range(2): for y in range(2): print(f"{y}{x}->{circuit(x,y)}") 00->11 10->01 01->00 11->10
THE QUANTUM VERSION OF THE CLASSICAL CIRCUIT -------------------------------------------- The X is the quantum version of NOT. The X with a "handle" is the controlled not, and is essentially and exclusive or of the control with the target, leaving the control unchanged and the target with the result of the exclusive or.
Another model is that a circuit of boolean gates. Each gate takes boolean input and calculates a boolean output. The gates are connected so the output of somegates become the inputs to other gates.
There are four classical gates, that are sufficient to build any boolean function, they are the not, the and the or and the exclusive or.
The not gate complements the input in calculating the output. The and and or perform their respective logical operation the two inputs, giving the result of the calculation as the output.
The exclusive or is a handy gate, that is true if the two inputs are unequal, and false if the two inputs are equal.
Here is an example circuit how gates are wired together. The first wire, x, has the value inverted; and the inverted value determines whether y will appear simply at the output or whether y will be inverted as well. The Truth Table is given, showing the output for all four possible inputs.
Also shown is a Python code, showing that the circuit model can be imbedded into a RAM model.
To some approximation, the RAM model of computation is the combination of a circuit model with a clocked storage area. The storage area presents its contents, or some small portion of its contents, to a circuit. The signals propagate until the output arrives, and the output is captured back into some portions of the storage area.
The circuit, rather than being fixed, as in this example, is configured for each computation cycle by an instruction, that is in turn fetched for another (or the same) storage area.
φ = α∣0❭ + β∣1❭where α and β are complex numbers subject to,
α2 + β2 = 1.
φ1 = α1∣0❭ + β1∣1❭and qubit φ2 is in state,
φ2 = α2∣0❭ + β2∣1❭Then together there are four states,
φ1⊗φ2 = (α1∣0❭+β1∣1❭) ⊗ (α2∣0❭+β2∣1❭) = α1α2∣00❭ + α1β2∣01❭ + β1α2∣10❭ + β1β2∣11❭
This is not necessarily the case. For instance, here is a possible state for two qubits,
B = (1/√2) (∣00❭ + ∣11❭)This is called the Bell state, and it is not possible to create it as the tensor of two qubits. It is said to be entangled because while the first bit is in either 0 or 1, and the second bit is in either 0 and 1, they will agree on what state they are in, when a measurement is made on one, the other, or both.
φ = α∣0❭ + β∣1❭will be measured as 0 with probability ∣α∣2, and as a 1 with probability ∣β∣2. Note that these two probabilities add to 1.
Very little can be learned from a single measurement. If the measurement is 0, then it is learned that α is not exactly 0; if the measurement is 1, then it is learned tha β is not exactly 1. To learn more is frustrated by two important quantum facts,
In the case of our quantum circuits, the circuit can be run repeatedly, on equal inputs, and those outputs repeatedly measured to determine α or β. The run time for the algorithm will have to consider the number of repetitions needed. In this way, an algorithm with an exponential speed up because of superposition might not be overall faster because it will have to be repeated an exponential number of times to collect the output.
Max Born, for whom the rule is named, was a Noble Prize winning physicist and the grandfather of Olivia Newton-John.
X φ = X (α∣0❭ + β∣1❭) = Xα∣0❭ + Xβ∣1❭ = αX∣0❭ + βX∣1❭ = α∣1❭ + β∣0❭
Quantum circuits must be reversible, and in this means that no information is erased, and therefore no energy is consumed in the computation. A general way to make any operation invertible is to create a new qubit for the output, called the ancillary, imprint the calculated value onto the ancillary with an exclusive or operation. Assuming the ancillary is initialized zero, then the final result of the ancillary is the computed value. The inputs to the computation are all passed through directly.
For instance, an and of two inputs becomes are function from 3 qubits to 3 qubits, an ancillary qubit is used:
∧(x,y,w) ⟶ x, y, (x∧y)⊕wNote that this can consume a lot of qubits, one for each operation; but cleverness and reuse can reduce the number of required ancillaries.
CREATING THE BELL STATE -----------------------
TESTING ON CLASSICAL INPUTS ---------------------------
C|yx❭ ⟶ |(y⊕x)x❭With x = x0|0❭ + x1|1❭, and y = y0|0❭ + y1|1❭, write out the output as,
α00 |00❭ + α10 |10❭ + α01 |01❭ + α11 |11❭
Factor this into a form,
(b00|0❭+b10|1❭)a0|0❭ + (b01|0❭+b11|1❭) a1|1❭and explain how this relates clearly to the c-not's operation.
H|0❭ = (1/√2)(|0❭+|1❭) H|1❭ = (1/√2)(|0❭-|1❭)These resulting states are denoted |+❭ and |-❭, respectively.
Multiply out H(H(|0❭)) and verify that it equals |0❭; likewise for |1❭.
Show that HHφ for a general qubit value φ=α|0❭+βl|1❭, also gives φ. (I.e. that HH=identity).
(1/√2)(|00❭+|11❭)Explain; Show argue that this is a state impossible to achieve as a tensor of two independent qubits, as φ⊗φ'.
Discover a circuit that creates another Bell state,
(1/√2)(|01❭+|10❭)
Do this on the quantum composer.
(1/√2)(|01❭+|11❭) = (1/√2)(|0❭+|1❭)|1❭Discover the 4 circuits giving each of these states, and verify on the quantum composer.
CLASSICAL CIRCUIT FOR EXERCISE ? -------------------------------- +-----+ x --+------+ | | | | y ----+----+ XOR +------------+ | | | | | z ------+--+ | | | | | +-----+ | | | | | +-----+ | | | +-----+ +--+ | | | +--+ | +-----+ | AND +----- | +----+ AND +----+ NOT +----+ | +------+ | +-----+ +-----+ +-----+
x⊕y ⟶ y' y'⊕x ⟶ x' x'⊕y' ⟶ y''Proof. The final value of x is,
x' = y'⊕x = (x⊕y)⊕x = yand the final value of y is,
y''= x'⊕y' = (y'⊕x) ⊕ (x⊕y) =y⊕y' = y⊕(x⊕y) = xCreate a quantum circuit that swaps two qubits. Build in the composer and test that it works on classical inputs. No ancillas are needed.
T|wyx❭ = (w⊕(y∧x)yx)Considering w to be an ancilla, in computes the and of x and y.
What does the classical circuit pictured do? Create a quantum version; build in the composer and test on classical inputs (8 possible inputs from |000❭ through |111❭).
H⊗H⊗H |000❭ = (1/√8)(|000❭+|001❭+|010❭+|011❭+|100❭+|101❭+|110❭+|111❭)Run this superposition through the circuit, with the ancilla or ancillas qubits set to zero, and explain the output.
author: burton rosenberg
created: 22 aug 2022
update: 25 aug 2022