CHAPTER 10
Simon’s algorithm and hidden XOR structure
Learning goals. Follow a two-register oracle calculation, derive the orthogonality constraint, and recover a hidden string by binary linear algebra.
10.1 A stronger oracle separation
Simon’s promise is a nonzero string and a function satisfying
Every output therefore has exactly two preimages. An oracle computes f into a sufficiently large output register. The problem is to determine s. The function’s outputs need not have a useful numerical meaning; their equality structure matters.
With randomly labeled outputs, a classical randomized procedure generally needs on the order of queries to find a collision and hence recover s. The birthday scale arises because k samples contain about pairs. Simon’s quantum procedure obtains useful linear constraints with polynomially many queries [14].
This is an oracle-model result. If an explicit function description exposes s directly, there may be an easier classical method. The laboratory intentionally exposes the small oracle table for education; it does not claim its own visible table is a hidden real-world problem.
10.2 Prepare, query, and condition
Start in , apply Hadamards to the first register, then query:
If the output register is measured and the value is f(z), the input collapses to
We need not actually perform or retain this measurement. Tracing out the output register gives the same input measurement probabilities after later operations. The conditioned description is simply convenient for deriving them.
Apply :
Because , the amplitude factors as
If , the bracket is zero. If , it is two. Thus y is uniformly distributed among the strings orthogonal to s over the binary field. The unknown z affects only signs, not the measured probabilities.
10.3 Binary Gaussian elimination
Each run supplies one equation . Collect independent rows into a matrix Y and solve over , where addition and subtraction are XOR. Once the rank reaches n−1, the nullspace contains exactly and the promised nonzero s.
Worked example. Let n=3 and s=101. The valid measurement strings are 000, 010, 101, 111. Suppose we obtain 010 and 101. The equations are
The free variable gives . Excluding the zero vector forces t=1, giving 101. The row 111 is the XOR of 010 and 101, so it adds no independent information.
After rank r has been collected in the -dimensional valid subspace, the next random sample is independent with probability . The expected sample count to reach full rank is the sum of the reciprocals of these probabilities. It is plus a bounded constant, hence O(n). The zero row and repeated rows are normal, not simulator failures.
10.4 A concrete reversible oracle
For the laboratory, define using the integer order of bit strings. This maps each XOR pair to the same label and has no other collisions. A reversible oracle XORs that label into its output register.
The simulator calculates the exact input marginal by grouping equal output labels and applying the Hadamard transform. It does not simply print the secret as an answer. The recovery display uses only the sampled equations; the known secret is available separately for checking the experiment.
Laboratory L14 — Simon’s hidden mask. Select a nonzero mask, examine oracle pairs, sample valid equations, and inspect row reduction and candidate masks. Reduce the shot count until several candidates remain.
10.5 Failure modes and interpretation
Noise can produce y values with . Naively demanding that every equation be exact may then leave no nonzero solution. Recovering a mask from noisy constraints becomes a statistical inference problem. The noiseless proof does not automatically supply a robust experimental algorithm.
The all-zero mask belongs to a different one-to-one promise case in common formulations. This laboratory restricts to the nonzero two-to-one case and rejects zero. A valid interface should explain a promise violation rather than return a confident but meaningless result.
Simon’s importance is structural: coherent queries convert a hidden symmetry into measurement constraints. Shor’s algorithm later uses a related idea with periodicity under ordinary modular arithmetic, but the transforms and classical reconstruction differ.
10.6 Exercises
10.1. List valid y values for n=3 and s=011.
Show solution / guidance
The constraint is , so y is 000, 011, 100, or 111, each with probability .
10.2. For n=4, do rows 1100, 0110, and 1010 have rank three?
Show solution / guidance
No. The third is the XOR of the first two. Rank is two, so the nullspace has dimension two and four candidates including zero.
10.3. Solve equations from rows 110, 011 in three bits.
Show solution / guidance
and . The nonzero solution is 111.
10.4. Why does measuring the output register not reveal s in one shot?
Show solution / guidance
It reveals one output label, whose two preimages remain unknown. The useful quantum state is a coherent pair of inputs. The subsequent transform turns that pair into an equation on s.
10.5. At rank n−2, what is the probability that the next sample completes the rank?
Show solution / guidance
. A few redundant samples near completion are expected.