Expand description
Simon’s algorithm.
Given a two-to-one (or one-to-one) Boolean function f : {0,1}^n → {0,1}^n
with the promise f(x) = f(y) ⇔ y = x ⊕ s for some hidden period
s ∈ {0,1}^n, Simon’s algorithm recovers s with O(n) quantum queries —
an exponential speed-up over the Θ(2^{n/2}) classical lower bound. It is
the historical precursor to Shor’s algorithm: a single run of the quantum
circuit returns a uniformly random bit-string y satisfying y · s = 0 (mod 2), and after collecting n − 1 linearly independent such constraints
the hidden string is fixed (up to the trivial all-zero solution when
s = 0).
§Circuit (on 2n qubits)
The first n qubits form the query register, the second n the output
register (this crate is little-endian, so query bit i ↦ qubit i and
output bit j ↦ qubit n + j):
- Prepare
H^{⊗n}on the query register. - Apply the oracle
U_f|x⟩|0⟩ = |x⟩|f(x)⟩. - Apply
H^{⊗n}on the query register again. - Measure the query register — the outcome
yis orthogonal tos.
§Classical post-processing
The sampled constraints are assembled into a binary matrix and reduced to
row-echelon form over GF(2); the unique non-trivial vector in the kernel is
the period s. recover_period_from_constraints exposes this solver
independently of the quantum sampler.
Structs§
- Simon
Result - Outcome of
simon.
Functions§
- recover_
period_ from_ constraints - Recover the hidden period
sfrom a set of constraint vectorsy(each satisfyingy · s = 0 (mod 2)) overnbits. - simon
- Run Simon’s algorithm to recover the hidden period of a two-to-one oracle.