Let's suppose that we have the following $\text{GHZ}$-state

$$|\psi\rangle = \frac{1}{\sqrt{2}}|a_1a_2a_3a_4\rangle + \frac{1}{\sqrt{2}}|b_1b_2b_3b_4\rangle$$

By using quantum gates, can we evaluate $a_i\oplus b_i$, $a_{i}\oplus a_{j}$, or $b_{i}\oplus b_j$ while maintaining the superposition? Where $1\leq i, j\leq 4$.

  • 1
    $\begingroup$ I would consider taking a look at Controlled gates $\endgroup$
    – Rammus
    Sep 6 at 20:35
  • $\begingroup$ You can sort of do the first one with a Hadamard gate, but that destroys superposition. And you can do the last two with a controlled gate on an ancilla, and keep superposition! But this is very far from the question you asked originally, and which I had given two answers. I’d consider asking another question if I were you, such as “why can we XOR two separate qubits in superposition and how is that different from a Hadamard gate on a single qubit?” $\endgroup$ Sep 9 at 0:35

2 Answers 2


Initially I wouldn't call your state a $W$ state, as that is a little different from what you have. You have a basis state on the first (leftmost) and fourth qubits, tensored with some version of a GHZ state on the second, third, and fifth (rightmost) qubit. Using wildcards, I would rewrite what you have as:

$$|\psi\rangle=|1.. 0.\rangle\otimes\frac{1}{\sqrt 2}\big(|.00.1\rangle+|.11.0\rangle\big)$$

Also if you perform a projective measurement on your qubits then you are left with classical information (e.g., 10001 or 11100), from which you can do what you wish.

But perhaps you wish to maintain coherence of your qubits. Here is a Quirk circuit which you might want to play with - this prepares your state. Note the endianness used here is such that the bottom qubit in the circuit is your leftmost qubit.

Five-qubit circuit

In particular, you can follow @Rammus's suggestion and add as many controlled gates as you'd like to your circuit. Indeed, calling your gate the SG (SuperGravity) gate, you can have some more fun with Quirk, adding random controlled NOT and controlled SWAP gates, as follows:

SG gate with random controlled gates

  • $\begingroup$ Rather than performing a projective measurement, thereby losing the superposition of the qubit, can we compare $|10001\rangle$ and $|11100\rangle$ without disturbing the state? $\endgroup$
    – user26446
    Sep 7 at 8:13
  • $\begingroup$ I don’t know what in particular you are asking for. Do you want to compare a given state to one of the two basis states? You can certainly do a SWAP test. What is your ultimate goal, @Supergravity? $\endgroup$ Sep 7 at 10:43
  • $\begingroup$ I want to know, for instance, without performing projective measurement whether qubit bases $|10001\rangle$ and $|11100\rangle$ both contain $1$ in their first qubit basis. My ultimate goal is to acquire information about $0$ and $1$'s in pairwise positions in each qubit basis, while also preserving the superposition of the qubit. $\endgroup$
    – user26446
    Sep 7 at 10:59
  • $\begingroup$ First = rightmost? $\endgroup$ Sep 7 at 11:02
  • $\begingroup$ If I understand where you are going I don’t think you can quickly do what you want, without violating the collision lower bound. Your basis states could be the two inputs that hash onto a particular output and you could learn at most one bit of information by doing a sequence of Hadamard gates. That gives you a string orthogonal to the XOR of the two basis states. That might be close to what you want. But, it’s a destructive test. $\endgroup$ Sep 7 at 11:17

Based on your comments in another answer, I think I see where you are going. Let your state be:

$$|\psi\rangle=\frac{1}{\sqrt 2}(|a_1a_2a_3a_4a_5\rangle+|b_1b_2b_3b_4b_5\rangle).$$

You do not wish for a circuit to prepare $|\psi\rangle$, nor do you wish to calculate the XOR of or do other controlled operations on two different qubits in your state; rather, you wish to calculate $a_i\oplus b_i$ for different $i$, while maintaining superposition. In general I don't think you can easily calculate the XOR of an individual qubit in the manner you are proposing, without violating the collision lower bound or other known lower bounds. For example, if you had an efficient way to know whether each of $a_i\oplus b_i=0$ for all qubits $i$, then you can determine that there is no such collision, as $a=b$, and hence $|\psi\rangle$ is not in a superposition of two or more states; this is what is ruled out by the collision lower bound.

But, you can find a string $d$ orthogonal to $a\oplus b$ with a quantum computer. This string might not be found easily with a classical computer. For example, let $|\psi\rangle$ be the state reached upon calculating some cryptographic 2-1 hash function of your five qubits into a second register, and measuring this second register to obtain a string $y$. Then, $a$ and $b$ are the two claws that collide at $y$. You can either (1) measure $|\psi\rangle$ to obtain the pair $(a,y)$ or $(b,y)$ but not both, or (2) perform a Hadamard transform on each of the qubits in $|\psi\rangle$ to obtain a random string $d$ such that $d\cdot (a\oplus b)=0$. This string $d$ is used in various recent proposals for proofs of quantumness, and is an interesting object in its own right.

Quantum computers are so odd and magical. They don't let you do anything you want, but they do let you do some other wonderful things.

  • $\begingroup$ Admittedly, I am somewhat confused about this answer. Are both ways leading us to a destructive measurement of $|\psi\rangle$? $\endgroup$
    – user26446
    Sep 7 at 13:49
  • $\begingroup$ Yes, upon measurement of $|\psi\rangle$ in either the standard basis (to get $a$ or $b$) or the Hadamard basis (to get $d$), you destroy the coherence of $|\psi\rangle$. $\endgroup$ Sep 7 at 15:25
  • $\begingroup$ Let's suppose that we obtained a state through projective measurement of an entangled state, such as the one we've been discussing. Does the manipulation of the obtained state through quantum gates still offer more efficiency or speed compared to classical manipulations? Of course, we wish to maintain the superposition of $|\psi\rangle$, but I am curious if we're still losing inherent quantumness in the case we can't. $\endgroup$
    – user26446
    Sep 7 at 15:31
  • $\begingroup$ (1) Please lock your question and don't edit further, as there is now a disconnect between my answers and your question. (2) Upon measuring all of the qubits of $|\psi\rangle$ in either basis, you lose quantumness, and $|\psi\rangle$ is no longer in superposition. For your particular example, though, if you were only to measure the first qubit then the remaining four qubits could still be entangled. (3) You are free to ask other questions! I recommend you refine your thinking and ask more, because we have exhausted our opportunity to talk in the comments section. $\endgroup$ Sep 7 at 18:11

Your Answer

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