# How to check states?

I don't know much about physics so maybe the question is stupid, but I wonder how engineers detect that the state function did not collapse due to the environment while a calculation is performed? Theoretically, a measurement will break the system. Related is also the next question, how to detect that a calculation is finished? A measurement should also break the state function and thus break an ongoing calculation.

If one thinks further, how is it even possible to check whether the experimenter produced a certain quantum state? Maybe all the bits have a totally different state right from the start and you just know about that afterwards.

I seem to miss something because if this would be true, quantum computers would be in-practical. Is it like this: The experimenter takes a measurement periodically and hopes that the operation was successful?

• What do you mean by "detect that a calculation is finished"? To me the obvious answer would be "when you finish the last step of your algorithm", but I may miss something. – Nelimee Jun 29 '18 at 12:19
• I think, I don't get the comment. You can initiate a measurement like in a usual computer, but I thought if you have to make a measurement the wave functions breaks. If you measure before an operation finished you have basically nothing. Maybe it is the timescale, which makes this point insignificant. – user2827 Jun 29 '18 at 12:59
• "if you have to make a measurement": why do you need to make a measurement? When asking this question, do you assume that a destructive measurement is the only way to detect an error? – Nelimee Jun 29 '18 at 13:06
• I found a paper. In page 7 the author writes that you assign an indicator bit just for the purpose to measure when the program halted. I just don't get how a quantum system has access to an additional bit which can be measured without perturbing the rest of the system :/ people.eecs.berkeley.edu/~christos/classics/… – user2827 Jun 29 '18 at 13:11

How engineers detect that the state function did not collapse due to the environment while a calculation is performed?

You can detect and correct errors during the calculation by using some Quantum Error Correction code. The idea behind these error correction codes is:

1. You entangle the qubit you want to "protect" against errors with $n$ other qubits.
2. You perform the operation that may introduce an error.
3. You measure a general property of the system.

I recommend you to read Quantum Error Correction for Beginners (Devitt, Nemoto & Munro, 2013) if you want more details on quantum error correction (and detection!).

But you are right, a dumb measurement will break the state function and thus break an ongoing calculation.

How to detect that a calculation is finished?

From the comments you wrote, your question is based on Quantum theory, the Church-Turing principle and the universal quantum computer (page 7). In this paper, David Deutsch tries to formalise the Quantum Turing Machine (QTM).

In the model of the QTM, a user does not have any mean to know if the computation is over or not but the machine does (because there is no more instruction, because the quantum state ended up in a trap state, etc.). In order to let the user know that he can retrieve the result of its calculations, the machine just flips a (classical) bit to 1. This bit and the quantum bits used for the computation are obviously not entangled (classical bits cannot be entangled) and so measuring the bit will not change the quantum system.

In real-world models/implementations, this may be done by other means. For example with IBM's quantum chips, you know that your computation is finished when the results become available and IBM knows that the computation is over because they executed on the quantum chip all the quantum gates you asked them to execute.

How is it even possible to check whether the experimenter produced a certain quantum state?

You can perform 2 different checks:

1. Quantifying the reliability of the initial state: if the experimenter tell you that the initial state is $\left|\phi\right>$ you can run multiple experiments consisting in only a measurement of the initial state and count how many experiments gave wrong outcomes.

This check consists in measurements and so may break the initial state, so you cannot check just before your experiment that the initial state is good. You can only obtain numbers like "the initial state will be good in 90% of the experiments".

2. Checking just before your calculations that the initial state is good. As said in the previous point, this may break the initial state and I don't know any algorithm capable of doing that for an arbitrary initial state.

The 2 points above are not making any assumptions on the initial state. If you are using the quantum circuit model then you expect $\left|0\right>^n$ as initial state and this initial state can be checked and corrected before your calculations:

1. Perform a destructive measurement on the qubits. Depending on the outcome of the measurement, each qubit is either in the state $\left|0\right>$ or $\left|1\right>$.
2. For all the qubits measured in the state $\left|1\right>$, apply an $X$ gate to flip the qubit state to $\left|0\right>$.

I think this is how IBM reset its qubits to the $\left|0\right>$ state (but I don't have any links ensuring it).

how (do) engineers detect that the state function did not collapse due to the environment while a calculation is performed?

In a sense, they don't. There's the possibility that you encode in an error correcting or error detecting code which permits the monitoring of errors. But really, before experimentalists want to run an algorithm, they've already done lots of tests on their system so they know how it works using a procedure called process tomography. They've checked in great detail that each of their gates performs as they expect them to, so they already have a very accurate prediction of how much error there will be.

how to detect that a calculation is finished?

You don't need to detect that it has finished. The computation is made up of a definite set of quantum gates. All you do is apply each gate sequentially. You know when you've finished implementing them, so you know when to look at the answer.

how is it even possible to check whether the experimenter produced a certain quantum state? Maybe all the bits have a totally different state right from the start and you just know about that afterwards.

Well, you can make sure you've got the correct starting state because you can measure it (you always start in a product state that you can easily measure). The final result is just about making sure all the individual steps do exactly what they're supposed to do. Again, if you can't do them perfectly, error correction (and more generally, fault tolerance) can beused to keep you on track. It is true that you can't use measurements to determine the state and copy it many times, as you might think to do with classical computation, but there are still good error correcting techniques. But that's another whole question...