6
$\begingroup$

Can we use classical XOR gate in a quantum circuit? Or are there any alternatives for XOR gate?

$\endgroup$
1

1 Answer 1

11
$\begingroup$

You can't directly use a classical XOR gate inside a quantum circuit because the usual construction of such a gate is a classical construction - it won't preserve coherence. In other words, it will function just fine if you input a 0 or a 1 as each input, but it won't perform as you'd need it to if you supplied it with a superposition.

Instead, you can build XOR out of quantum circuit elements, so that it behaves in exactly the same way as it would for classical inputs, but it does preserve superposition. Indeed, XOR is simple as a reversible circuit, just use a controlled-not! The target qubit is the output you want enter image description here You can readily verify this just by constructing the truth table.

Indeed, you can construct all classical gates in this way. For example, the AND gate: enter image description here

$\endgroup$
6
  • $\begingroup$ I asked the question because I came across a I-indexed journal article, in which they've used the classical XOR gate. $\endgroup$
    – Govind
    Sep 5, 2018 at 17:13
  • 1
    $\begingroup$ @user4505 I would imagine that they were implicitly recognising that quantum computers can realise classical computations. So it's absolutely fine to talk about classical computations. (It's like if you read about Shor's algorithm, there's a bit about modular exponentiation that people usually just leave out because there's a good classical circuit for doing that part, so you just implement that in your quantum computer.) $\endgroup$
    – DaftWullie
    Sep 6, 2018 at 7:20
  • $\begingroup$ I know there are often several different representations of the same quantum circuit. I've seen that representation of the AND gate in your circuit above. But I've also seen one involving only two qubits. Consider the Hamiltonian in Table 1 of this paper, next to the AND operation, which can be converted to a circuit. It uses only 2 qubits. I assume the corresponding unitary in the table for AND would accomplish the same as your circuit above involving the ancilla @DaftWullie? $\endgroup$
    – makansij
    Feb 18, 2023 at 21:05
  • 1
    $\begingroup$ @makansij The paper you're referring to is something completely different. It is not implementing an AND function by evolution. It's encoding its function in the ground state of a Hamiltonian. There is no corresponding unitary. In fact, this is important. AND is not reversible, so it cannot be embedded within a two-qubit unitary; it must use at least 3 qubits. $\endgroup$
    – DaftWullie
    Feb 21, 2023 at 7:27
  • 1
    $\begingroup$ @makansij That depends on what you mean. An adiabatic evolution is still unitary, so you can never have a 2-qubit adiabatic evolution that starts from values $a,b$ and computes $a$ AND $b$. You can, however, encode a problem into a ground state that contains an AND function, and find that ground state using an adiabatic evolution. $\endgroup$
    – DaftWullie
    Feb 24, 2023 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.