why we have sum over all $x$ here?
The difference here is notational. We use the + operator not to mean 'addition with some group operation', but instead that the state can be represented by a combination of orthogonal base states.
For example, if we have a state where we have two base vectors |0>
and |1>
, and they are of equal amplitude, we can represent the state as |0> + |1>
.
Now, if we have $n$ such orthogonal base vectors, we can use the $\sum$ notation to mean |0> + |1> + ... + |n-1>
in the obvious manner.
Now, when they write |+>
(not to be confused with the + notation above), what they mean can be represented as $\sum_x$ |x>, however that misses a fine point. |+>
can be generated (and this is what the proof means by preparing) by taking the |0>
state and applying the Hadamard (H) operator; in the 'computational basis' (which is the basis used in the representation $\sum_x$ |x>) every bit pattern has an equal amplitude. However, there exists an alternative basis where the only nonzero amplitude is on a specific basis vector (denoted as +). The reason this is important is if take this state, and apply the Hadamard operator to it again, it'll move it back to the |0>
state; this does not apply to an arbitrary state, even if that state has equal amplitude with respect to all computational basis vectors (that is, performing a measurement on that state will generate all possible values with equal probability).
I.e. the first register remains unchanged.
Welcome to Oz (that is, Quantum Mechanics), where this is not true (!). In classical computation, reading a value has no effect on that value. However, in Quantum Computation, it does. This is not a trivial point; if you don't understand it, their proof will not make any sense.
The effect of taking |x>|0>
and converting that into |x>|f(x)>
is that the components become entangled, and in particular, if the |x>
side was initially a pure |+>
state, it no longer is.
What they do is they the |x>|f(x)>
state (which they get from their encryption oracle) and change that into |x>|f(x) ⊕ x>
. This again affects the left side; if f(x) was $x \oplus s$ (for some secret constant $s$), then the state is |x>|s>
; that is, the two sides are no longer entangled, and so the left side goes back to a pure |+>
state. If f(x) is something else, the two sides are sides are still entangled, and so the left side is something other than a pure |+>
state.
They then use a Hadamard operator (and a measurement) to test the left hand side to see if it was a pure |+>
state.
Yes, Quantum Mechanics is weird. It is not irrational; it is just highly counterintuitive to anyone who hasn't worked with it a lot...