# How to measure whether register contains a specific state?

In a proof that I am reading through there exists a register $$M$$ in which a state is initialized. We want to measure whether $$M$$ contains a specific state $$c_1$$. In the proof, they measure with a projector $$|c_1\rangle\langle c_1|$$. I am interested in how this is mathematically defined.

I have been researching projective measurements and found that one can measure with a decomposition of orthogonal projectors such that $$I=\sum P_i$$ where $$P_i$$ are orthogonal projectors. Can we just say that we measure with the decomposition $$I=P_1+P_2$$ with $$P_1=|c_1\rangle\langle c_1|$$ and $$P_2=I-P_1$$? Or how does this projective measurement of a single state work?

Sorry if things are unclear or incorrect jargon is used, I am new in quantum computing and asking this question because I could not find a consise answer anywhere. If anything is unclear, please ask for clarification in the comments.

You can realize a measure with a set of projector in theory. Here you projector $$P_1$$ is $$|c_1 \rangle \langle c_1|$$ and identity on the other subpart of the system, i.e. $$|c_1 \rangle \langle c_1| \otimes I$$. If $$c_1$$ is measured, the system will collapse to the state $$|c_1 \rangle \otimes |other\ subsytem\ unchanged \rangle$$

The other projectors orthogonal to $$P_1$$ stand for the other basis elements available for this register, idk $$c_2,c_3,\ldots,c_n$$ and would be like $$P_2 = |c_2 \rangle \langle c_2| \otimes I$$,$$P_3 = |c_3 \rangle \langle c_3| \otimes I$$...

If you want only two projectors like in your example, you can build the projector $$P_2 = (\sum_{k=2}^n |c_k \rangle \langle c_k|) \otimes I$$ which you can check is still orthogonal to $$P_1$$ and project on any state but $$c_1$$.

In experimental scheme however it is sometimes hard to realize projective measurement that does not destroy the state. Here you should look at the concept of POVM that generalize measurement. In POVM you have a set of operators $$M_1,M_2,\ldots,M_n$$ such that $$\sum_k M_k = I$$. One will often define the last operator as $$M_n = I - M_1 - M_2 - \ldots - M_{n-1}$$ and define this result as "we are not sure of the result of the measurement". This is a really practical approach of measurements in quantum mechanics.

You are right in saying that $$\left\{\left|c_1\middle\rangle\!\middle\langle c_1\right|,I-\left|c_1\middle\rangle\!\middle\langle c_1\right|\right\}$$ is a valid projective measurement.

Let's stick to the computational basis for now. In order to realize this measurement, you can use an ancilla qubit. Let's say that we have some state $$|\psi\rangle$$: $$|\psi\rangle=\sum_i\alpha_i\left|i\right\rangle.$$ We want to know whether $$|k\rangle$$ is in this superposition. Let us add a register initialized in the state $$|0\rangle$$: $$\sum_i\alpha_i\left|i,0\right\rangle.$$ Now, we will perform a controlled-NOT, controlled off the first register being in state $$|k\rangle$$ (that is, we flip the last qubit if the first register is in state $$|k\rangle$$, which is a perfectly valid quantum operation): $$\alpha_k|k, 1\rangle + \sum_{i\neq k}\alpha_i\left|i,0\right\rangle.$$ We now measure the second qubit. The probability of measuring $$|1\rangle$$ is equal to $$\left|\alpha_k\right|^2$$. If we measure $$|1\rangle$$, then we have applied the $$\left|c_1\middle\rangle\!\middle\langle c_1\right|$$ (normalized) projector to $$|\psi\rangle$$. Otherwise, we have applied the $$I-\left|c_1\middle\rangle\!\middle\langle c_1\right|$$ (normalized) projector to it.

Note that the leftover state has collapsed: either you're left with $$|k, 1\rangle$$ or you're left with the (normalized) right-hand part. You can convince yourself that if you do the exact same procedure with this collapsed state, you will always get the same outcome as you did the first time.

Thus, by using this technique, if you measure $$|1\rangle$$, you know for a fact that $$|k\rangle$$ was indeed in this superposition. If you don't, you'd have to prepare another copy of $$|\psi\rangle$$ and repeat the experiment until you're convinced that it isn't.

Now, in order to test implement this measure for an arbitrary state $$|\varphi\rangle$$, you simply have to apply the same procedure to $$U^\dagger|\psi\rangle$$, with $$U$$ being such that $$U|k\rangle=|\varphi\rangle$$ for a $$k$$ of your choice.