6

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

Sanchayan Dutta
  • 17,945
  • 8
  • 50
  • 112
Govind
  • 123
  • 1
  • 5

1 Answers1

11

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

DaftWullie
  • 62,671
  • 4
  • 55
  • 140