Simon’s Algorithm
Simon’s algorithm finds a hidden XOR period by collecting random linear equations. A coherent query correlates each input with its function value; a Hadamard transform then returns a word orthogonal to the period. Repeating this experiment and solving the equations over recovers the hidden word.
For the promise defined below, including the possibility of an injective function, the fixed-error quantum query complexity is , compared with classical value queries. One query produces a sample, not usually the answer. The comparison counts oracle calls and excludes building the oracle and implementing its gates.
Helpful background. Quantum oracles defines coherent value access. Linear maps explains kernels and rank; here all row operations use arithmetic modulo two. Query complexity distinguishes exact, zero-error and bounded-error query caps.
The hidden XOR-period promise
Section titled “The hidden XOR-period promise”Let
where addition in is bitwise XOR. Define . The oracle is selected from the family of functions satisfying
The biconditional is the promise. It says not merely that is a period but that there are no other collisions. The required search output is the complete word ; the associated decision problem asks whether .
The promise includes two branches. If , then and is injective. If , the fibers are exactly the two-element cosets
so is exactly two-to-one. The mask is unique: the fiber of is , and equality of two promised functions’ collision relations would force their fibers at zero, hence their masks, to agree.
Some textbook presentations promise from the outset. That restricted problem is useful for deriving the sampling pattern, but it omits the injective branch and cannot by itself justify an injective-versus-two-to-one decision claim. This page retains the unified promise throughout.
One coherent value query
Section titled “One coherent value query”The supplied oracle acts on an -qubit address and an -qubit value register:
For every , XOR by is a permutation and its own inverse, so this specifies a unitary on the complete space. A classical query returns the full -bit value .
One sample uses the following steps:
- Prepare and apply to .
- Apply once.
- Apply to , then measure to obtain .
The value register may be measured after the query, or left unmeasured and discarded. Both choices give the same marginal distribution for . It starts in zero, unlike the one-qubit minus-state target used in the preceding Boolean algorithms.
Conditional coset states and the address marginal
Section titled “Conditional coset states and the address marginal”After address preparation and one value query, the joint state is
For , measuring and obtaining the value leaves
in the address register. The probability of each distinct oracle value is , and the representative is irrelevant up to its coset. In the injective branch, measuring leaves a single basis state .
The output measurement is optional. If is ignored, the probability of measuring after the final Hadamards is
Only equal-output pairs survive the partial trace. For a nonzero mask, each contributes the two differences and , giving
This equals when and zero otherwise. For , only survives, so for every . Measuring the value register reveals a convenient conditional coset state; it does not create the period relation or change the address marginal.
Fourier samples orthogonal to the period
Section titled “Fourier samples orthogonal to the period”The -fold Hadamard transform is the Fourier transform over the product group :
Applying it to a nontrivial coset state gives
Character cancellation removes every with . Define the annihilator
Both promise branches are then summarized by
For , has dimension and contains words, each with probability . For , it is all of and each word has probability . Each sample supplies one homogeneous binary equation ; it does not normally determine by itself.
The transform here is not the cyclic circuit used in number-theoretic phase and period estimation. The distinction is structural: has binary characters implemented by independent Hadamards.
A three-bit example with : . Each input pair shares one value. Fourier sampling gives , each with probability ; all satisfy . The zero sample is allowed and adds no equation.
Binary rank and candidate verification
Section titled “Binary rank and candidate verification”Place retained samples into a binary matrix
For a nonzero mask, every row lies in . Once , the nullspace is the two-element set for a unique nonzero word . Under the nonzero branch alone, . Under the unified promise, the injective branch can also happen to produce a rank- matrix, so the candidate must be checked:
The biconditional promise makes this decisive. Equality for nonzero means ; inequality rules out and therefore identifies the injective branch once the sample span has codimension at most one.
If vectors are sampled independently and uniformly from a -dimensional binary space, the probability of spanning it is
For , spanning is impossible; for , the empty product is one. One way to derive the displayed formula is to transpose the samples into a matrix. Its first row must avoid the zero span, its second must avoid a one-dimensional span, and so on. The failure probability obeys
When the current span has rank , a fresh sample increases the rank with probability . Summing the corresponding geometric waiting times gives
These are exact sampling laws. Row reduction must still be performed over , not over the real numbers, and a verifier call remains part of the executable algorithm.
Expected stopping, query caps and exact algorithms
Section titled “Expected stopping, query caps and exact algorithms”Different stopping conventions support different complexity claims.
Expected stopping. Repeatedly sample until the row rank reaches , compute the nonzero null vector, and verify it. In the nonzero branch the expected sample count is below because ; the two verifier calls give an always-correct expected -query procedure. In the injective branch, this rule also reaches rank in finite expected time and the verifier returns zero. It has no deterministic query cap.
Fixed-cap zero error. Take Fourier samples. Return zero immediately at rank ; at rank , verify the unique nonzero null vector; below rank , return ?. For a nonzero mask, the failure bound with is below . For the injective branch, dependence among the first samples has probability at most
so the inconclusive probability is also below . The deterministic cap is value queries.
Fixed-cap bounded error. Take samples, use the same rank and verifier rules, and return zero on an unresolved lower-rank outcome. The injective branch is always correct. In the nonzero branch the failure probability is below
The cap is queries, already below the conventional error threshold.
A separate exact algorithm. The random-rank loop is not an exact fixed-cap algorithm. Brassard and Høyer gave a separate construction that forces a new independent annihilator element, or certifies that none remains, using exact amplification; their formulation includes the trivial subgroup, and their Section 4.3 reduces the total number of function evaluations to . Cai and Qiu later supplied another optimal exact ordinary-oracle construction for the restricted nonzero-mask problem. It must not be applied silently to the branch. Together with the transparent zero-error and bounded-error procedures, the applicable upper bounds are .
For the associated injective-versus-two-to-one decision problem, Koiran, Nesme, and Portier proved, for sufficiently large ,
A full-mask search procedure also solves the decision problem. For zero error, replacing an inconclusive result of probability at most by an independent fair decision bit produces error at most , so the lower bound transfers under the fixed-cap convention. Consequently, for every fixed ,
The equality is asymptotic. The explicit and caps above belong to the transparent verifier-based procedures, not to the cited exact construction’s optimized constants.
Classical collisions and difference covers
Section titled “Classical collisions and difference covers”A classical query returns one complete value . Under a nonzero mask, the first observed collision identifies it:
An exact deterministic schedule follows from a difference cover. Write with and query every address in
Their intersection is . Every nonzero equals , so a hidden mask forces a collision among the queried addresses. No collision proves the injective branch. Hence
Conversely, queried addresses determine at most nonzero pairwise XOR differences. If some nonzero word is missing, an injective transcript can be completed either as an injective oracle or as a two-to-one oracle with that hidden mask, so an exact algorithm cannot distinguish them. Therefore
Random queries give the matched bounded-error upper bound. For a fixed nonzero mask, the domain is partitioned into pairs. Sampling distinct addresses without seeing both members of any pair has probability
The numerator chooses distinct pairs and one endpoint from each. Choosing makes the miss probability a fixed constant below one; a collision returns its XOR difference, while no collision returns zero.
For a lower bound, mix a uniformly random injective oracle with equal probability against an oracle with a uniformly random nonzero mask and random distinct fiber labels. Until a collision, their distinct output transcripts can be coupled. The queried addresses expose at most candidate masks, so any depth- deterministic decision tree has distributional success at most
Yao’s minimax principle then gives randomized query complexity for the associated decision task at every fixed error below . Any full-mask search algorithm decides whether , so the lower bound transfers to search. A randomized fixed-cap procedure at cannot use random coins to evade the exact worst-case difference-cover requirement. Thus, for every fixed ,
Four-bit worked calculations
Section titled “Four-bit worked calculations”Input pairs and the recovered mask
Section titled “Input pairs and the recovered mask”Take , , and, with the most significant bit,
Its kernel is , and exhaustive evaluation gives:
| Inputs | Output |
|---|---|
0000, 1011 |
0000 |
0001, 1010 |
0010 |
0010, 1001 |
0100 |
0011, 1000 |
0110 |
0100, 1111 |
1000 |
0101, 1110 |
1010 |
0110, 1101 |
1100 |
0111, 1100 |
1110 |
The exact Fourier support is
0000 0011 0100 0111 1001 1010 1101 1110with probability on every listed word and zero elsewhere. The independent rows 0011, 0100, and 1001 have nullspace .
How many samples or classical queries?
Section titled “How many samples or classical queries?”For a three-dimensional sample space, exact enumeration of all ordered sequences gives:
| Fraction spanning | ||
|---|---|---|
| 3 | ||
| 4 | ||
| 5 |
The expected spanning time is
For uniformly selected distinct addresses at ,
The six-query collision probability is therefore . Exact recovery needs six queries as well: the pair-count lower bound gives , and
has every nonzero four-bit word among its fifteen pairwise XOR differences. Thus . For , the cover contains the colliding pair 0100 and 1111.
Gate costs and the hidden-subgroup viewpoint
Section titled “Gate costs and the hidden-subgroup viewpoint”Each Fourier sample needs one query, visible qubits, Hadamards and measurement of the address qubits. Registers must be reinitialized before the next sample. With rows, straightforward binary elimination uses bit operations and memory. The verifier adds at most two value queries; oracle workspace and implementation costs remain additional.
The exponential query comparison is a worst-case result over the promised family. The linear function in the worked example has a transparent description: if that description is available, a classical algorithm can inspect its kernel directly. It is not then restricted to learning through unknown function values. Similarly, an ordinary classical API does not automatically supply the coherent oracle required by the quantum algorithm.
The group is , and the hidden subgroup is . Coset sampling followed by Fourier sampling extracts characters trivial on that subgroup. This viewpoint helped motivate later algorithms, including Shor’s algorithm, whose cyclic period finding and number-theoretic reductions need their own analysis. Simon’s oracle lower bound does not become a classical factoring lower bound or prove BQP BPP; see quantum complexity classes.
The ideal sample equations and the verifier rely on the full collision promise. With noisy or off-promise data, a null vector alone does not establish a period. A noise model and a suitable statistical recovery procedure must replace the exact reasoning.
Exercises
Section titled “Exercises”Uniqueness and the two promise branches
Section titled “Uniqueness and the two promise branches”Prove that the mask is unique. Then derive the injective branch for and the exact two-to-one coset structure for .
Solution
The fiber of is
If the same collision relation had masks and , these fibers would obey , hence . When , equality of outputs implies and therefore , so is injective. When , each shares its value exactly with , and the two addresses are distinct. The fibers are therefore the two-element cosets of .
Full-space action and optional measurement
Section titled “Full-space action and optional measurement”Show that is unitary on the whole computational basis. Starting from , derive the address distribution without measuring the value register and compare it with the conditional-coset derivation.
Solution
For each fixed , the map is a permutation and its own inverse. The full basis map is therefore a permutation, so is unitary and .
Tracing out gives
After ,
For , each has equal-output partners and , so . This is on and zero elsewhere, exactly the distribution obtained by first conditioning on any coset state. For , only diagonal pairs remain and .
Character cancellation
Section titled “Character cancellation”Derive the Hadamard transform of and prove that the result is uniform on . Include the branch.
Solution
For ,
There are supported words and every squared amplitude is , so the distribution is normalized and uniform. If , a measured output selects one basis state because is injective. Its Hadamard transform has amplitude magnitude at every , which is the same rule with and .
Recover the four-bit mask
Section titled “Recover the four-bit mask”For the displayed function, reproduce all fibers, the eight-point Fourier support, and the nullspace of rows 0011, 0100, and 1001.
Solution
Evaluating the four output coordinates gives the eight pairs in the worked example, each separated by
The equal-output character sum is
so it is on words orthogonal to 1011 and zero otherwise. Dividing by gives probability on
0000 0011 0100 0111 1001 1010 1101 1110The three chosen equations are independent. Solving them over leaves one free bit and gives precisely or .
Rank probability and expected stopping
Section titled “Rank probability and expected stopping”Derive , its failure bound, and . Evaluate the three probabilities and the expected time for , and explain why the row reduction must use binary arithmetic.
Solution
A binary matrix has full row rank when its ordered rows successively avoid spans of sizes . Out of possible rows at each step,
A union bound over the failed independence steps gives
At rank , the probability of increasing rank is , so
For , the products give , , and at , while
This is the finite-field instance of the kernel, image, rank, and rank–nullity language developed in Mathematical Toolkit Linear Maps. The present exercise specializes that structure to row reduction over .
The birthday comparator
Section titled “The birthday comparator”Derive the exact no-collision probability for distinct random addresses and explain why it gives an bounded-error algorithm.
Solution
For fixed nonzero , the addresses form disjoint pairs. A collision-free -subset chooses of those pairs and one of two endpoints in each, so the number of favorable subsets is . Dividing by all subsets gives
Equivalently,
For , its logarithm is bounded above by
so a sufficiently large constant makes the miss probability at most any fixed error. A collision reveals ; without one the procedure returns zero.
Deterministic lower and upper bounds
Section titled “Deterministic lower and upper bounds”Prove the pairwise-difference lower bound and split-subspace upper bound. Then establish .
Solution
With queried addresses, at most nonzero XOR differences have been exposed. If this is less than , some nonzero is absent, and a collision-free transcript is compatible with both an injective oracle and a promised oracle having mask . Thus
For the upper bound, query
Every is the difference of and , and the union has elements.
At , the lower bound requires , hence . The set
has six elements and fifteen distinct nonzero pairwise XOR differences, so it attains the bound. Therefore .
Why verification needs enough independent equations
Section titled “Why verification needs enough independent equations”In the three-bit example from the figure, suppose the only independent sample is . List the possible null words. If you test and find , may you conclude that the function is injective?
Solution
The equation is , so the nullspace contains . Testing gives , although the true period is . This excludes only the tested candidate. Once the row rank is , there is just one nonzero null word and a failed test excludes every nonzero period allowed by the samples. Below that rank, other candidates remain. Conversely, under the promise, any nonzero with establishes the period immediately, regardless of the sample rank.
References
Section titled “References”- G. Brassard and P. Høyer, “An Exact Quantum Polynomial-Time Algorithm for Simon’s Problem,” Proceedings of the Fifth Israeli Symposium on Theory of Computing and Systems, 12–23 (1997), doi:10.1109/ISTCS.1997.595153.
- G. Cai and D. Qiu, “Optimal Separation in Exact Query Complexities for Simon’s Problem,” Journal of Computer and System Sciences 97, 83–93 (2018), doi:10.1016/j.jcss.2018.05.001.
- A. M. Childs and W. van Dam, “Quantum Algorithms for Algebraic Problems,” Reviews of Modern Physics 82, 1–52 (2010), doi:10.1103/RevModPhys.82.1.
- P. Koiran, V. Nesme, and N. Portier, “A Quantum Lower Bound for the Query Complexity of Simon’s Problem,” Automata, Languages and Programming, LNCS 3580, 1287–1298 (2005), doi:10.1007/11523468_104.
- A. Nayak, “Deterministic Algorithms for the Hidden Subgroup Problem,” Quantum Information and Computation 22, 755–769 (2022), doi:10.26421/QIC22.9-10-3.
- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th Anniversary Edition, Cambridge University Press (2010), doi:10.1017/CBO9780511976667.
- D. R. Simon, “On the Power of Quantum Computation,” Proceedings of the 35th Annual Symposium on Foundations of Computer Science, 116–123 (1994), doi:10.1109/SFCS.1994.365701.
- D. R. Simon, “On the Power of Quantum Computation,” SIAM Journal on Computing 26, 1474–1483 (1997), doi:10.1137/S0097539796298637.