# Can you construct a 3-qubit XOR state?

I'm wondering if it is possible to build a 3-qubit quantum circuit that creates the following pure state: $$\frac{1}{2}\left(|000\rangle+|011\rangle+|101\rangle+|110\rangle\right)=\frac{1}{2}\left[1,0,0,1,0,1,1,0\right]^\intercal$$

This is an interesting state, because if we name the qubits $$q_1$$, $$q_2$$ and $$q_3$$, then this is an equal superposition of all combinations of $$q_1,q_2\in\lbrace 0,1\rbrace$$ and $$q_3=q_1\oplus q_2$$ (logical XOR), which is also the simplest probability distribution that you cannot define in terms of pairwise dependences.

In extension to this question: Does anyone know of a source that lists circuits for constructing all possible equal superpositions of subsets of basis states for $$n$$ qubits, i.e. $$\boldsymbol{\alpha}/\sqrt{\lVert\boldsymbol{\alpha}\rVert_1}$$ for all $$\boldsymbol{\alpha}\in\lbrace 0,1\rbrace^{2^n}$$?

Best regards!

You wish to prepare your state into the uniform superposition of three qubits $$\{q_1,q_2,q_3\}$$ such that $$q_3=q_1\oplus q_2$$, starting from some canonical basis element (which is conventionally the all-zeroes ket).

The following will work to prepare such a state: Generalizing this to more than three qubits, say to prepare the uniform superposition of all $$n$$ qubits such that $$q_n=q_1\oplus q_2\oplus\cdots\oplus q_{n-1}$$, one would initially perform $$n-1$$ Hadamard gates on the first $$n-1$$ qubits, then separately have these perform a controlled-$$X$$ (controlled-NOT) on the $$n$$th qubit.
As to the other question about preparing uniform superpositions for other interesting states or interesting subsets of the $$2^n$$ computational basis elements, there are likely too many such circuits to be formally provided, even for small $$n$$! There are $$2^{2^n}$$ different boolean functions on $$n$$ bits.
One approach you could always do is to prepare the uniform distribution over all $$n$$ qubits, calculate your function or equation of interest into an ancilla qubit, and measure the ancilla and post-select on getting the state of interest (e.g. to $$|0\rangle$$ or $$|1\rangle$$). The probability of successfully post-selecting depends on the properties of your function (e.g. how likely it is to be $$|0\rangle$$ or $$|1\rangle$$).
This would work for the "XOR state" in the original question - a fourth ancilla could store the result of the boolean test of whether $$q_3=q_1\oplus q_2$$, and measuring the ancilla and post-selecting upon getting $$|1\rangle$$ in the ancilla gives you the desired state on the other three qubits. You would get $$|1\rangle$$ 50% of the time. But, such a folk approach probably isn't written down anywhere formally.