Grover diffusion operator
DefinitiondiffusionThe Grover diffusion operator: the reflection 2|s><s| - I about the uniform superposition |s>, also called inversion about the mean.
import Mathlib
import Definitions.Def_uniformSuperposition
namespace Grover
/-- The Grover diffusion operator: the reflection `2|s⟩⟨s| - I` about the uniform superposition
`|s⟩`, also called "inversion about the mean". -/
noncomputable def diffusion (N : ℕ) :
EuclideanSpace ℂ (Fin N) →L[ℂ] EuclideanSpace ℂ (Fin N) :=
(2 : ℂ) • InnerProductSpace.rankOne ℂ (uniformSuperposition N) (uniformSuperposition N) -
ContinuousLinearMap.id ℂ _
end Grover
Read-back
What the Lean code literally says, in plain math · claude-sonnet-5
For a natural number (explicit argument), diffusion N is defined as the continuous -linear map on given by times the rank-one operator built from the vector uniformSuperposition N (used as both arguments of the rank-one construction) minus the identity map. Concretely, the rank-one operator sends , so for every , diffusion N sends , where (each being real, so it equals its own conjugate), again using the junk-value convention , . In the degenerate case this makes the (unique, trivial) vector of and the formula reduces to on that zero-dimensional space, i.e. negation of the identity map.
Confirmed by the mission captain (proposal self-audit).