# Come faccio ad aggiungere 1 + 1 utilizzando un computer quantistico?

29

Questo può essere visto come il complemento software di Come fa un computer quantistico a fare matematica di base a livello hardware?

La domanda è stata posta da un membro del pubblico della 4a rete della rete spagnola sull'informazione quantistica e le tecnologie quantistiche . Il contesto che la persona ha dato è stato: " Sono uno scienziato dei materiali. Stai introducendo concetti teorici sofisticati avanzati, ma ho difficoltà a immaginare il funzionamento pratico di un computer quantistico per un semplice compito. Se usassi diodi, transistor ecc., Potrei capisco facilmente le operazioni classiche che devo eseguire per aggiungere 1 + 1. Come lo faresti, in dettaglio, su un computer quantistico? ".

Risposte:

21

Secondo la domanda collegata, la soluzione più semplice è solo quella di far eseguire al processore classico tali operazioni, se possibile . Naturalmente, ciò potrebbe non essere possibile, quindi vogliamo creare un sommatore .

Esistono due tipi di sommatore a bit singolo: il mezzo sommatore e il sommatore completo . Il semisommatore prende gli ingressi e ed emette il 'somma' (XOR) e 'riporto' (AND) . Un sommatore ha anche il 'carry in' ingresso e il 'effettuare' uscita , sostituendo . Ciò restituisce $A$$A$$B$$B$$S=A\oplus B$$S = A\oplus B$$C=A\cdot B$$C = A\cdot B$${C}_{in}$$C_{in}$${C}_{out}$$C_{out}$$C$$C$$S=A\oplus B\oplus {C}_{in}$$S=A\oplus B\oplus C_{in}$e .${C}_{out}={C}_{in}\cdot \left(A+B\right)+A\cdot B$$C_{out} = C_{in}\cdot\left(A+B\right) + A\cdot B$

## Versione quantistica del mezzo sommatore

Guardando il gate CNOT sul registro qubit controlla il registro : $A$$A$$B$$B$ che dà subito all'uscita delregistro come. Tuttavia, dobbiamo ancora calcolare il carry e lo stato delregistroè cambiato, quindi dobbiamo anche eseguire l'operazione AND. Questo può essere fatto usando il gate Toffoli a 3 qubit (controllato-CNOT / CCNOT). Questo può essere fatto usando i registriecome registri di controllo e inizializzando il terzo registronello stato

$\begin{array}{rl}{\text{CNOT}}_{A\to B}{|0⟩}_{A}{|0⟩}_{B}& ={|0⟩}_{A}{|0⟩}_{B}\\ {\text{CNOT}}_{A\to B}{|0⟩}_{A}{|1⟩}_{B}& ={|0⟩}_{A}{|1⟩}_{B}\\ {\text{CNOT}}_{A\to B}{|1⟩}_{A}{|0⟩}_{B}& ={|1⟩}_{A}{|1⟩}_{B}\\ {\text{CNOT}}_{A\to B}{|1⟩}_{A}{|1⟩}_{B}& ={|1⟩}_{A}{|0⟩}_{B},\end{array}$
$B$$B$$A\oplus B=S$$A\oplus B = S$$B$$B$$A$$A$$B$$B$$\left(C\right)$$\left(C\right)$$|0⟩$$\left|0\right>$, Dando l'uscita del terzo registro come . L'implementazione di Toffoli sui registri e controllano il registro seguito da CNOT con controlla fornisce l'output del registro come somma e l'output del registro come carry. Uno schema circuitale quantistico del mezzo-sommatore è mostrato nella figura 1.$A\cdot B=C$$A\cdot B = C$$A$$A$$B$$B$$C$$C$$A$$A$$B$$B$$B$$B$$C$$C$

Figura 1: Schema circuitale di un mezzo sommatore, composto da Toffoli seguito da CNOT. Bit di ingresso sono e , dando la somma con carry out .$A$$A$$B$$B$$S$$S$$C$$C$

## Versione quantistica del sommatore completo

Mostrato in figura 2, un modo semplice di fare questo per singoli bit è usando registri qubit, qui etichettati , , e , dove inizia a stato , quindi lo stato iniziale è :$4$$4$$A$$A$$B$$B$${C}_{in}$$C_{in}$$1$$1$$1$$1$$|0⟩$$\left|0\right>$$|A⟩|B⟩|{C}_{in}⟩|0⟩$$\left|A\right>\left|B\right>\left|C_{in}\right>\left|0\right>$

1. Applicare Toffoli usando e per controllare : $A$$A$$B$$B$$1$$1$$|A⟩|B⟩|{C}_{in}⟩|A\cdot B⟩$$\left|A\right>\left|B\right>\left|C_{in}\right>\left|A\cdot B\right>$
2. CNOT con controlla : $A$$A$$B$$B$$|A⟩|A\oplus B⟩|{C}_{in}⟩|A\cdot B⟩$$\left|A\right>\left|A\oplus B\right>\left|C_{in}\right>\left|A\cdot B\right>$
3. Toffoli with $B$$B$ and ${C}_{in}$$C_{in}$ controlling $1$$1$: $|A⟩|A\oplus B⟩|{C}_{in}⟩|A\cdot B\oplus \left(A\oplus B\right)\cdot {C}_{in}={C}_{out}⟩$$\left|A\right>\left|A\oplus B\right>\left|C_{in}\right>\left|A\cdot B\oplus\left(A\oplus B\right)\cdot C_{in} = C_{out}\right>$
4. CNOT with $B$$B$ controlling ${C}_{in}$$C_{in}$: $|A⟩|A\oplus B⟩|A\oplus B\oplus {C}_{in}=S⟩|{C}_{out}⟩$$\left|A\right>\left|A\oplus B\right>\left|A\oplus B\oplus C_{in} = S\right>\left|C_{out}\right>$

$A$$A$$B$$B$$A$$A$$B$$B$

$|{\psi }_{out}⟩=|A⟩|B⟩|S⟩|{C}_{out}⟩$

This gives the output of register ${C}_{in}$$C_{in}$ as the sum and the output of register $2$$2$ as carry out.

Figure 2: Circuit diagram of a full adder. Input bits are $A$$A$ and $B$$B$ along with a carry in ${C}_{in}$$C_{in}$, giving the sum $S$$S$ with carry out ${C}_{out}$$C_{out}$.

## Quantum version of the ripple carry adder

A simple extension of the full adder is a ripple carry adder, named as it 'ripples' the carry out to become the carry in of the next adder in a series of adders, allowing for arbitrarily-sized (if slow) sums. A quantum version of such an adder can be found e.g. here

## Actual implementation of a half-adder

For many systems, implementing a Toffoli gate is far from as simple as implementing a single qubit (or even two qubit) gate. This answer gives a way of decomposing Toffoli into multiple smaller gates. However, in real systems, such as IBMQX, there can also be issues on which qubits can be used as targets. As such, a real life implementation on IBMQX2 looks like this:

Figure 3: Implementation of a half-adder on IBMQX2. In addition to decomposing the Toffoli gate into multiple smaller gates, additional gates are required as not all qubit registers can be used as targets. Registers q[0] and q[1] are added to get the sum in q[1] and the carry in q[2]. In this case, the result q[2]q[1] should be 10. Running this on the processor gave the correct result with a probability of 42.8% (although it was still the most likely outcome).

John Duffield

@JohnDuffield I'm not sure whether you mean approximate quantum (state) adders (exact state adders are apparently forbidden) or implementations of 'classical' adders on a quantum computer - I haven't tried this particular code out though - or something different?
Mithrandir24601

How are the numbers represented? Is it in Binary?
user3483902

@user3483902 In this case, single bits $0$$0$ and $1$$1$ using the states $|0⟩$$\left|0\right>$ and $|1⟩$$\left|1\right>$ - that is, the 'number' $A$$A$ can be either $0$$0$ or $1$$1$, as can the 'number' $B$$B$ etc.
Mithrandir24601

@Mithrandir24601 : does it matter? Isn't the answer no in either case? I've actually built a parallel adder myself. I have a Cmputer Science degree.
John Duffield

6

If I was using diodes, transistors etc I could easily figure out myself the classical operations I need to run to add 1+1. How would you do that, in detail, on a quantum computer?''

Impressive! I suspect that most people cannot easily figure out themselves how to combine diodes and transistors to implement a classical two-bit adde (though I do not doubt this material scientist can probably do it). ;)

Theoretically, the way you implement a classical adder is pretty similar in a classical and quantum computer: you can do that in both cases by implementing a Toffoli gate! (See @Mithrandir24601's answer.)

But the material scientist probably wants to understand how to implement such an gate (or an equivalence sequence of other quantum gates) on a physical device. There are probably an infinite ways to do that using different quantum technologies, but here are two direct realizations of this gate using trapped ions and superconducting qubits:

1. Realization of the Quantum Toffoli Gate with Trapped Ions, T. Monz, K. Kim, W. Hänsel, M. Riebe, A. S. Villar, P. Schindler, M. Chwalla, M. Hennrich, and R. Blatt, Phys. Rev. Lett. 102, 040501, arXiv:0804.0082.
2. Implementation of a Toffoli gate with superconducting circuits A. Fedorov, L. Steffen, M. Baur, M. P. da Silva & A. Wallraff Nature 481, 170–172, arXiv:1108.3966.

You can also decompose the Toffoli gate as a sequence of single-qubit and CNOT gates. https://media.nature.com/lw926/nature-assets/srep/2016/160802/srep30600/images/srep30600-f5.jpg You can read about how to implement these with photonics, cavity-QED and trapped ions in Nielsen and Chuang.

For disclosure, I was not that materials scientist, but rather, since the neverending discussion was still unsatisfactory and in abstract terms, I was the person that understood what he was asking for, googled for it and showed him a minimal but satisfactory answer (a half-adder on quantiki) in of quantum gates terms.
agaitaarino

5

A new method for computing sums on a quantum computer is introduced. This technique uses the quantum Fourier transform and reduces the number of qubits necessary for addition by removing the need for temporary carry bits.

PDF link for 'addition on a quantum computer', written by Thomas G. Draper, written September 1, 1998, revised: June 15, 2000.

To summarize the above link, addition is performed according to the following circuit diagram (taken from page 6):

To quote the paper (again, page 6):

The quantum addition is performed using a sequence of conditional rotations which are mutually commutative. The structure is very similar to the quantum Fourier transform, but the rotations are conditioned on $n$$n$ external bits.

1

Parallel computation of the sum of two qubits

I thought an initial $$ππ\pi$$ phase (created in the 1st of 3 Hadamard gates) represented a negative digit, but it just represents a positive digit with a -1 phase factor.