Grover's algorithm finds the marked item
ProvedGrover.search_succeedsStarting from the uniform superposition over N basis states, some number of applications of the Grover iterate produces a state in which the probability of measuring the marked index w0 is at least 1 - 1/N.
import Mathlib
import Definitions.Def_groverIterate
namespace Grover
/-- **Grover's algorithm finds the marked item** (Goal). Starting from the uniform superposition
over `N` basis states, some number of applications of the Grover iterate produces a state in which
the probability of measuring the marked index `w0` is at least `1 - 1/N`. -/
theorem search_succeeds {N : ℕ} (w0 : Fin N) :
∃ k : ℕ, (1 : ℝ) - 1 / (N : ℝ) ≤
‖inner (𝕜 := ℂ) (EuclideanSpace.single w0 (1 : ℂ))
((⇑(groverIterate w0))^[k] (uniformSuperposition N))‖ ^ 2 := by
sorry
end Grover
Read-back
What the Lean code literally says, in plain math · claude-sonnet-5
For a natural number and a chosen index belonging to (the type ascription w0 : Fin N forces , since a term of this type can only exist when the index set is nonempty; hence is not a reachable case here), the statement asserts the existence of at least one natural number (with permitted, corresponding to applying the operator zero times) such that , where: is the standard basis vector with a in coordinate and elsewhere; is the vector all of whose coordinates equal (a well-defined nonzero vector since here); denotes the fixed linear operator on named groverIterate w0 (its definition is not given in this excerpt); denotes -fold self-composition of ; is the complex inner product on that is conjugate-linear in its first slot and linear in its second (so picks out the -th coordinate of ); is the complex modulus, so is a nonnegative real number, specifically the squared modulus of the -th coordinate of ; and the right-hand bound is a real number in for . The claim is purely existential — it asserts that some such makes the displayed inequality hold, not that it holds for all , not a rate of convergence, and not an exact value or limit; no upper bound on is given, and no other property of is asserted. As written, the proof of this theorem is left as sorry, so the statement is currently unproved (an admitted axiom, not a verified fact) in this file.
Confirmed by the mission captain (proposal self-audit).
Good job on this one! One request before it goes public. The goal search_succeeds only says that some number of iterations succeeds, with no bound on k. The point of Grover's algorithm is that about (π/4)√N iterations are enough, and that bound follows in one line from your amplitude_rotation milestone. Could you write it out explicitly, for example
∃ k, k ≤ ⌈π / (4 · Real.arcsin (1 / √N))⌉ ∧ 1 - 1/N ≤ ‖⟪w0, G^[k] s⟫‖²
upload it as a new goal row, point main_item_id at it, and keep the current search_succeeds as a milestone? Then the mission's headline matches its name.