Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.16.0"Import the minimal module
import Formalizations.Reusable.AnalysisIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable Real Set open scoped Matrix Matrix.Norms.L2Operator open NormedSpace QSL.Qudit open QSL.TwoQubit (act) open MeasureTheory ProbabilityTheory in /-- R0085: `gate_time_ge_eigenphase_gap` turns a certified eigenphase gap into a lower bound on total gate time when the width Ω is positive. -/ example {n : Type*} [Fintype n] [DecidableEq n] (Ω : ℝ) (hΩpos : 0 < Ω) (steps : List (ℝ × ℝ × Matrix n n ℂ)) (hτ : ∀ s ∈ steps, 0 ≤ s.1) (hH : ∀ s ∈ steps, s.2.2.IsHermitian) (hΩ : ∀ s ∈ steps, ‖s.2.2 - (s.2.1 : ℂ) • (1 : Matrix n n ℂ)‖ ≤ Ω / 2) (ω : ℂ) (G : Matrix n n ℂ) (hUG : (steps.map fun s => exp ((-(s.1 : ℂ) * Complex.I) • s.2.2)).prod = ω • G) (ej ek : EuclideanSpace ℂ n) (hj : ‖ej‖ = 1) (hk : ‖ek‖ = 1) (hjk : inner ℂ ej ek = 0) (φj φk : ℝ) (hGj : act G ej = Complex.exp (φj * Complex.I) • ej) (hGk : act G ek = Complex.exp (φk * Complex.I) • ek) (hgap : |φj - φk| ≤ Real.pi) : |φj - φk| / Ω ≤ (steps.map Prod.fst).sum := by apply (div_le_iff₀ hΩpos).2 simpa only [mul_comm] using gate_time_ge_eigenphase_gap Ω steps hτ hH hΩ ω G hUG ej ek hj hk hjk φj φk hGj hGk hgapSteps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableAnalysisExample.leanat v0.16.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
For a product of nonnegative-time Hermitian evolutions with spectral width bounded by Ω, implementing a gate up to global phase, the gap of two orthonormal eigenvectors with eigenphases differing by at most π is at most Ω times total time.
Lean statement
theorem gate_time_ge_eigenphase_gap {n : Type*} [Fintype n] [DecidableEq n]
(Ω : ℝ) (steps : List (ℝ × ℝ × Matrix n n ℂ))
(hτ : ∀ s ∈ steps, 0 ≤ s.1) (hH : ∀ s ∈ steps, s.2.2.IsHermitian)
(hΩ : ∀ s ∈ steps, ‖s.2.2 - (s.2.1 : ℂ) • (1 : Matrix n n ℂ)‖ ≤ Ω / 2)
(ω : ℂ) (G : Matrix n n ℂ)
(hUG : (steps.map fun s => exp ((-(s.1 : ℂ) * Complex.I) • s.2.2)).prod = ω • G)
(ej ek : EuclideanSpace ℂ n) (hj : ‖ej‖ = 1) (hk : ‖ek‖ = 1)
(hjk : inner ℂ ej ek = 0) (φj φk : ℝ)
(hGj : act G ej = Complex.exp (φj * Complex.I) • ej)
(hGk : act G ek = Complex.exp (φk * Complex.I) • ek)
(hgap : |φj - φk| ≤ Real.pi) :
|φj - φk| ≤ Ω * (steps.map Prod.fst).sumLinks
Lean docstring
Time bound from a gate's eigenphase gap. A sequence of nonnegative-time Hermitian evolutions, each with spectral width at most Ω, needs total time at least |φj - φk| / Ω to implement a gate with two orthogonal eigenvectors whose phase gap is at most π. The formal inequality avoids division by Ω and includes a possible global phase ω.
- Archive:
QSL.Gate.gate_time_ge_eigenphase_gap(Formalizations.Physics.QuantumMechanics.SpeedLimit.GateEigenphases). - Classical reference: Mandelstam–Tamm type bound; the archive cites Nelson–Barnes, arXiv:2604.23031, equation (3), for this gate setting.
- Example: apply the bound to an explicit two-eigenvector certificate.
Upstream
Uses the archive's gate action and Hilbert-space setup; Mathlib has no matching gate-time statement.
Depends on, in this repository
Formalizations.Physics.QuantumMechanics.SpeedLimit.GateEigenphases