Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Grover search

Also known as Grover's algorithm, Amplitude amplification

quantum quantum-planning

Grover search finds a marked candidate among N = 2^n basis states with about √N oracle queries, where a classical scan needs about N. It prepares the even superposition and repeats a Grover iteration: a phase oracle flips the sign of every state whose candidate passes the validity check, and the diffusion H, X, MCZ, X, H reflects the state about the even superposition. With M marked states and sin²θ = M/N, search_known runs k = ⌊π/(4θ)⌋ iterations (none when M = 0 or M ≥ N), measures once and checks the measured candidate classically, so it returns only a valid index and returns nothing with probability at most M/N. Each oracle application and each check counts as one query, so a run costs k + 1; the simulator's work per basis state does not count, and it holds at most 24 qubits, with qubit 0 as the least significant bit of the index. Use it when you know how many solutions exist and want to compare query counts with a classical scan; for an unknown count, use BBHT.

Pseudocode

algorithm Grover-Search(oracle, n, M)input: phase oracle over N = 2ⁿ basis states, n ≤ 24 qubits, qubit 0 the lowest index bitinput: the number M of marked statesoutput: a marked index, or nilif M = 0 or M ≥ N thenk ← 0                                         ▷ iterations cannot helpelseθ ← arcsin √(M / N)k ← ⌊π / (4θ)⌋                                ▷ success probability sin²((2k + 1)θ)amplify(oracle, k)i ← sample(measure all qubits)if check(oracle, i) then                        ▷ one classical queryreturn ireturn nil                                      ▷ probability at most M / N; run againprocedure amplify(oracle, k)ψ ← H on every qubit of |0…0⟩                   ▷ the even superpositionfor t in 1, …, k donegate every basis state that oracle marks    ▷ one quantum queryapply H, X, MCZ, X, H to all qubits           ▷ diffusion, up to a global phase of −1

In the crates

  • quantum-planning

    Amplitude amplification with a phase oracle built from a validity check, run on the state-vector simulator for a known number of solutions, counting oracle queries.

    search_knownamplify

Lineage

Comes from

Nothing on this site.

Led to

BBHT exponential search builds on it

Papers

  1. A fast quantum mechanical algorithm for database search Lov K. Grover · 1996· Proceedings of the 28th Annual ACM Symposium on Theory of Computing (STOC 1996) introduces doi 10.1145/237814.237866 arXiv quant-ph/9605043
  2. Tight Bounds on Quantum Searching Michel Boyer, Gilles Brassard, Peter Høyer, Alain Tapp · 1998· Fortschritte der Physik analyses doi 10.1002/(SICI)1521-3978(199806)46:4/5<493::AID-PROP493>3.0.CO;2-P arXiv quant-ph/9605034