Simon's Algorithm
Simon's algorithm is the moment the case for quantum computing stopped being a curiosity and became an argument. Deutsch–Jozsa and Bernstein–Vazirani had already beaten deterministic classical machines, but a coin-flipping classical machine solves both in a handful of queries — so the separation evaporates the instant you allow randomness. Daniel Simon's 1994 construction closed that loophole. It hands you a black box that hides a secret string , and finds with about quantum queries while any classical strategy — deterministic or randomized, with any allowed error — provably needs on the order of . That is not a polynomial saving; it is an exponential wall, and the first time anyone drew it cleanly. The promise is deliberately spare. The oracle computes with the guarantee that exactly when is either the all-zeros string or the hidden mask . So is two-to-one, and every colliding pair differs by the same . Classically you learn nothing until you stumble on a collision, which the birthday bound puts roughly queries away. The quantum machine instead manufactures a collision on demand: one oracle call in superposition, a measurement of the output register, and the input register is left holding both preimages at once. A second layer of Hadamards turns that hidden symmetry into a visible constraint — each run donates one random linear equation over the two-element field, and independent equations pin down . Structurally this is the abelian hidden subgroup problem, the same skeleton Shor would wrap around factoring within months.
- Simon's problem: given a black box promised to be two-to-one with , find the hidden mask .
- The quantum algorithm uses oracle queries; every classical algorithm needs — the first clean, provable exponential quantum–classical query separation.
- One run: Hadamard the input register, call the oracle once, measure the output register, Hadamard again, and read a string that is guaranteed to satisfy .
- Collect linearly independent samples and solve the resulting linear system over by Gaussian elimination to recover ; a batch of samples is independent with probability at least .
- The Hadamard layer is the quantum Fourier transform over , and the whole procedure is the abelian hidden subgroup recipe that Shor's factoring algorithm inherits.
- Key idea: measuring the output register collapses the input register onto the two-element coset ; a Hadamard transform of that -periodic state has amplitude only on strings orthogonal to , so each measurement returns a uniformly random vector in the hyperplane , and of them determine .
Measuring the output register leaves the input register in the coset state ; the Hadamard transform of this -periodic state is supported only on strings with , so each run samples a uniformly random vector from the hyperplane , and independent samples fix by linear algebra over .
Where this lives today
Simon's algorithm is small enough to be a favourite hardware demonstration: two- and three-bit instances have run on ion-trap, superconducting, and photonic processors and on IBM's public devices, precisely because a working run shows entanglement, oracle queries, and Fourier sampling in one compact circuit. But its living importance is conceptual and cryptographic. Conceptually, it is the template for the abelian hidden subgroup problem — prepare a coset state, Fourier-sample its dual, recover the subgroup — which unifies Simon's problem, order-finding, period-finding, and the discrete logarithm under one algorithm, and whose non-abelian generalizations (graph isomorphism, unique shortest vector) remain among the most-studied open problems in quantum algorithms. Cryptographically, Simon's period-finding drives a family of quantum attacks: Kuwakado and Morii (2010–2012) showed the three-round Feistel construction and the Even–Mansour cipher expose a Simon-type hidden period to an adversary with superposition query access, and Kaplan and co-authors (2016) extended this to break many message-authentication codes and modes of operation in polynomial time. These attacks are why post-quantum symmetric-key design now explicitly asks whether a construction hides an XOR period — a present-day consequence of a 1994 black-box result.
The physical picture
Classically, learning means catching a collision — two distinct inputs with the same output — with no way to steer toward one; you throw queries at the box and wait for a coincidence. The quantum trick is to stop searching and start manufacturing. Put the input register into a uniform superposition over all strings, fire the oracle once, and every input sits entangled with its own image. Now measure only the output register. You land on some value , and because the promise makes exactly two-to-one, that value has precisely two preimages, and . The measurement cannot tell you which, so it leaves the input register holding both — coherently, at equal amplitude. You have conjured a collision pair for free, but as a superposition you cannot read directly.
The second Hadamard layer is where the hidden symmetry surfaces. The coset state is invariant under the shift — a periodic state, with period , on the Boolean cube. Fourier analysis has one iron law: transforming a periodic function concentrates its weight on the dual of that period. Here the transform is exactly the quantum Fourier transform over , and the dual of is the annihilator . Constructive interference survives only where the phases and agree; everywhere else they cancel exactly. So the measured is forced, uniformly, into the hyperplane orthogonal to . Each run is thus a single coin flip handing you one random linear equation over . One equation cannot reveal — it only rules out half the candidates. Recovering is a coupon-collector problem in linear algebra: sample vectors from the -dimensional space until of them are independent, then the orthogonal complement is one line and its unique nonzero member is . The cost of collecting enough is linear in , setting the whole quantum query budget against the exponential classical wall drawn below.
The core equations
The promise is the whole problem. It is a structural guarantee on — not a property you can read off any single value, but a symmetry that ties every pair of colliding inputs to the same hidden offset .
where: — the hidden mask in to determine; — bitwise XOR, i.e. addition in ; — the all-zeros string. Reading: if the function is one-to-one; if it is exactly two-to-one, and the two preimages of every output differ by . The oracle is reversible, so it cannot simply overwrite the answer register — it XORs the result in. Initialized with the answer register at , one call writes while leaving the input untouched.
where: — the -qubit input register; — the -qubit answer register, set to ; — XOR, which keeps unitary. Reading: is its own inverse, and one query costs one application regardless of superposition on . The Hadamard layer is not incidental — it is the Fourier transform for this group. Its matrix elements are the characters of , the sign patterns .
where: — the inner product; — the character indexed by . Reading: this is a genuine quantum Fourier transform, which is why "apply Hadamards" and "Fourier-sample the hidden subgroup" are the same instruction. After the output-register measurement, the input register is left in a two-element coset — the algorithm's engine. It is an -periodic state: shifting every label by maps it to itself.
where: — one preimage of the measured output ; — the other preimage, guaranteed by the promise. Reading: the measurement outcome is discarded; all that matters is that the input register now carries the hidden symmetry. Transforming that coset state and squaring the amplitudes gives the sampling law — the single most important line in the article. The probability is flat on and exactly zero off it.
where: — the linear constraint harvested each run. Reading: every measurement is a uniformly random draw from the strings orthogonal to ; the outcome carries exactly one bit of information about (or zero bits when ). Stacking independent samples as rows of a matrix gives a homogeneous linear system whose one-dimensional solution space is spanned by .
where: — the -th sampled row; — the number of independent constraints that pin to a line. Reading: Gaussian elimination over solves this in classical operations, which never touches the oracle and so is irrelevant to the query count. The headline is the gap between the two query costs — the first provable exponential separation in the black-box model.
where: — oracle queries needed to identify with bounded error. Reading: one call per run and runs on the quantum side; the birthday bound on the classical side. The ratio grows without limit — at it is already about .
The goal is to follow both registers through a single run — start, superposition, query, output measurement, second Hadamard — and prove that the interference makes every allowed outcome satisfy with equal probability . This is the core mechanism, and every later claim about query counts rests on the flat sampling law derived here, so we track amplitudes explicitly rather than gesturing at "interference".
Step 1. Begin in and apply to the input register, giving the uniform superposition . Why: a single Hadamard layer spreads amplitude equally over all inputs, so one oracle call can act on the entire domain of at once.
Step 2. Apply to reach . Why: the reversible XOR oracle entangles each input with its own image, correlating the two registers without collapsing the input superposition.
Step 3. Measure the output register and observe some value . By the promise, exactly two inputs map to — call them and — so the input register collapses to . Why: the two-to-one structure guarantees precisely two preimages, so the measurement manufactures the -periodic coset state that the rest of the algorithm exploits.
Step 4. Apply to the surviving input register: . Why: this is the Fourier transform over applied to a periodic state, the step that converts a hidden symmetry into an observable constraint.
Step 5. Factor the common phase: the amplitude of is , which equals when and is exactly when . Squaring gives on and elsewhere. Why: the two preimages differ by , so their characters agree precisely on the annihilator — constructive interference there, total cancellation off it.
Go deeper · Derivation B · 1 minWhy order n runs recover the hidden string
Go deeper · Derivation C · 1 minThe classical birthday lower bound
The goal is to establish the other half of the separation — that no classical algorithm, even a randomized one allowed to err, finds with fewer than order queries. The argument is information-theoretic: a classical machine learns about only when it witnesses a collision, and collisions are exponentially rare until the number of queried inputs nears the square root of the domain size — the birthday phenomenon.
Step 1. Suppose the algorithm has queried distinct inputs and seen no collision. Every output observed so far is distinct, and the transcript is consistent with being injective () or with a huge number of possible masks — one for each way of pairing up the unqueried, as-yet-unseen inputs. Why: without a repeated output the data has not distinguished any candidate mask from any other, so no information about has been extracted.
Step 2. For a fixed pair of queried inputs , the chance they collide is the chance , which for an unknown is about . Across queries there are pairs, so the expected number of collisions is roughly . Why: collisions accumulate with the number of pairs, not the number of queries, which is the source of the square-root behaviour.
Step 3. To expect even one collision — the minimum needed to learn anything — requires , i.e. . Why: below this threshold the expected collision count is exponentially small, so with high probability the machine sees only distinct outputs and outputs a guess no better than chance.
Step 4. Randomization does not help: the argument bounds the probability of any collision appearing, so a coin-flipping machine also fails with high probability below queries, giving the bounded-error lower bound . Why: the obstruction is the absence of collisions in the transcript, which no internal randomness can conjure, so the exponential wall stands against all classical strategies. *At the birthday threshold gives classical queries.*
Limiting cases
Behaviour at the edges of the promise and the resource counts:
| Case | Result | Meaning |
|---|---|---|
| Trivial mask | injective for all | Every is sampled uniformly, so the constraints span all of and force the unique solution — the algorithm correctly reports "no nontrivial period". |
| All-zeros outcome | for every | An uninformative constraint occurring with probability ; discard it and re-run. Its rarity is why occasional wasted rounds do not spoil the scaling. |
| Independent samples | Each nonzero draw is uniform in ; a batch is fully independent with probability at least the constant , so batches — queries — succeed with overwhelming probability. | |
| Classical lower bound | A randomized classical machine gains information only on seeing a collision; the birthday bound forces queries, establishing the exponential separation. | |
| Quantum query count | One oracle call per run, runs. The Gaussian elimination is classical post-processing and does not enter the query separation. |
Worked examples
1 · Recovering a hidden mask by hand (n = 3, fully worked)
Take with hidden mask . The oracle pairs inputs that differ by : , , , , assigning each pair a distinct output. Run the subroutine, collect samples, and solve for .
Step 1. Identify the target hyperplane. A string satisfies when , i.e. . So — exactly strings, matching the count in equation (5), and each is sampled with probability .
Step 2. Run the subroutine once. Suppose the output-register measurement lands on the value shared by and , leaving the input register in . The final Hadamard yields a ; say we read . This is one equation: .
Step 3. Run again. Say we now read , the equation , i.e. . A third run returning or a repeat of is discarded as dependent. Two independent constraints suffice for .
Step 4. Solve the system. From and , the nonzero solutions collapse to , giving — the hidden mask, recovered from just two informative measurements. Had every draw been we would simply have re-run; the expected number of runs to get here is a small constant above .
2 · Sizing the exponential gap (n = 40)
A hidden-mask problem has . Estimate the quantum and classical query costs and the speedup factor, using and .
Step 1. Quantum cost. One oracle call per run and roughly runs to gather independent constraints (plus a small constant for repeats) gives queries. Even generously padding for failed batches leaves it well under .
Step 2. Classical cost. The birthday bound gives queries — over a million evaluations of the black box just to expect a single collision.
Step 3. Speedup. The ratio is at alone. Double to and the classical cost squares to while the quantum cost merely doubles to — the gap is exponential, not a fixed constant, which is the entire point of Simon's result. At n = 40: about 40 quantum queries versus 1.05×10⁶ classical, a factor of ~2.6×10⁴.
Physics of the portrait
Simon's algorithm is a piece of theoretical computer science, but it earned its place in every physics-flavoured quantum course because it was the first proof that the quantum advantage is real and exponential in a setting where you can prove a matching classical lower bound — no hand-waving, no reliance on unproven complexity assumptions.
Origins · 1 minDaniel Simon and how this was discovered
Daniel R. Simon devised his algorithm in 1993–1994, and its reception is part of the lore: the paper was initially rejected before appearing at the 1994 IEEE Symposium on Foundations of Computer Science. Its influence was immediate and specific. Peter Shor has repeatedly credited Simon's construction as the direct spark for his factoring algorithm: Simon showed how to reduce a hidden-period problem to Fourier sampling over an abelian group, and Shor recognized that order-finding modulo is the same maneuver transplanted from to , with the quantum Fourier transform over replacing the Hadamard layer and continued fractions replacing Gaussian elimination. Within months of Simon's talk, Shor had factoring and discrete logarithm. The algorithm now anchors two lineages: the pedagogical ladder Deutsch–Jozsa → Bernstein–Vazirani → Simon → Shor, and the general theory of the hidden subgroup problem, where Simon's problem is the cleanest nontrivial abelian instance. Its afterlife includes a modern twist — Simon's period-finding is the engine of quantum attacks on symmetric cryptographic constructions with a hidden XOR structure, so a 1994 toy problem now shapes how "quantum-safe" ciphers are designed.
Going further
Texts. Nielsen & Chuang, Quantum Computation and Quantum Information (10th anniversary ed.), §1.4.4 and the Simon's-problem exercises · Preskill, Lecture Notes for Physics 219, Chapter 6 (Quantum Algorithms) · Watrous, The Theory of Quantum Information and his complexity lecture notes on Simon's problem · Kitaev, Shen, Vyalyi, Classical and Quantum Computation · Mermin, Quantum Computer Science, Chapter 2 · Kaye, Laflamme, Mosca, An Introduction to Quantum Computing, §6.4 · D. R. Simon, On the Power of Quantum Computation, SIAM J. Comput. 26(5):1474–1483 (1997). The sampling law (5) and the coset-state evolution follow directly from , , and the promise. The independence constant is the Euler function . The query bounds are versus . The identity "Hadamard = QFT over " follows by tensoring single-qubit Hadamards. For the worked , example, ; at the classical cost is queries.
Prerequisites. Quantum Parallelism and the Oracle Model · Bernstein–Vazirani Algorithm · Deutsch–Jozsa Algorithm. Leads to. Order Finding and Period Finding · Shor's Factoring Algorithm · Hidden Subgroup Problem · Quantum Fourier Transform.
Ask the tutor: Ask me to run the , example end to end — coset state, Hadamard, and the Gaussian elimination that pins down — or to show exactly how Simon's circuit morphs into Shor's order-finding.
Is Simon's algorithm the same kind of speedup as Deutsch–Jozsa or Bernstein–Vazirani?
No, and the difference is the whole point. Deutsch–Jozsa and Bernstein–Vazirani beat only deterministic classical algorithms; a randomized classical machine solves both with a couple of queries and bounded error, so their separation vanishes once you allow coin flips. Simon's problem is engineered to defeat randomized machines too: no classical strategy, however randomized, finds with fewer than about queries. That is why Simon's is billed as the first exponential quantum–classical separation, while the earlier two are exponential only against the weaker deterministic model.
If each run only gives one equation, how can the total cost be O(n)?
Each run costs a single oracle query and yields one random constraint . You need independent constraints, and a fresh sample is independent of the previous ones with high probability as long as they have not yet spanned . The linear-algebra argument shows a batch of samples is fully independent with probability at least , a constant that does not shrink with , so a constant number of batches — hence runs and queries — recovers with overwhelming probability. The exponential-looking part (a space of size ) is tamed because you only need a basis, and vectors suffice.
Why does measuring the output register help, when Deutsch–Jozsa never measures it?
Because that measurement is what creates the periodic state. In Deutsch–Jozsa the output register only supplies a phase kickback and is discarded unmeasured. In Simon's algorithm the output measurement projects the input register onto exactly the two-element coset — a state invariant under the shift by . Without that projection the input register would still carry the full image structure of , and the subsequent Hadamard would not concentrate amplitude on . The collapse manufactures the -periodicity that the Fourier transform then reads out. It is the one design choice that distinguishes Simon's circuit from its phase-kickback predecessors.
What is the role of the all-zeros outcome y = 0?
It is a wasted run. The constraint holds for every , so it rules out nothing and contributes no row to your system; you discard it and sample again. It occurs with probability , so for any reasonable it is negligible, and a few such outcomes only add a small constant to the expected number of runs. It never threatens the scaling — it just means the number of runs is a random variable slightly larger than .
How exactly does Simon's algorithm foreshadow Shor's?
They share one skeleton: hide a period in a function, query it in superposition, measure the output register to obtain a periodic coset state, Fourier-transform to sample the dual of the period, and post-process classically. Simon works over with period ; the transform is and the post-processing is Gaussian elimination over . Shor's order-finding works over with period ; the transform is the quantum Fourier transform over and the post-processing is the continued-fraction algorithm. Recognizing that "find the hidden XOR mask" and "find the hidden multiplicative period" are the same abelian-group problem is the cleanest route into Shor's logic — Simon is the training-wheels version whose only simplification is that the group is a Boolean cube.
Does Simon's exponential speedup mean quantum computers beat classical ones in practice?
Not by itself. Simon's separation is relative to an oracle — it proves there exists a black box relative to which the quantum class BQP contains a problem outside BPP. That is a statement about query complexity, not about a concrete function you can download. When you replace the oracle with actual code, the separation can survive (Shor's factoring, contingent on factoring being classically hard) or evaporate (if the hidden structure is efficiently computable classically). So Simon's result is best read as an existence proof and a template: it shows exponential quantum advantage is possible and reveals the mechanism that delivers it, which is why it mattered historically even though the oracle itself is artificial.