Theorem (Execution agrees with the word algorithm). Under the primitive contracts, readable inputs, sufficient separated output capacity, and exact bounded dimension literals, the solver terminates and stores exactly the basis and values returned by the mathematical word algorithm with the same arithmetic and random tape. It consumes exactly
(L+1)(n+4n^2)
random words and releases its scoped scratch storage. This correspondence does not require a numerical-success assumption.
Lean statement and details
NLAlib.SpectralBisection.bisectionRoutine_meets {K Op Tst : Type} [Inhabited K]
[Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.IndexOp Op] [Ops.Has Ops.SampleOp Op]
[Ops.Has Ops.MatrixOp Op] [Ops.Has Ops.CmpTst Tst] [Ops.Has Ops.IdxTst Tst] (M : Ops.Machine K)
(dec : K → ℝ) (mm : MatMulMap (K × K)) (qr : QRMap (K × K)) (R0 eps beta : K) {n : ℕ}
(A : Matrix (Fin n) (Fin n) (K × K)) {I : Ops.Interp Op Tst K} (hS : Ops.IsScalar M I)
(hL : Ops.IsIndexLit M I) (hC : Ops.IsCmp dec I)
(hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I)
(hQR : Ops.IsMatrixQR (Ops.EntryCodec.pair K) (fun {m n} ↦ qr) I) (hQ : Ops.IsToNat dec I)
(hSample : Ops.IsSample I) :
SpectralBisection.bisectionRoutine.Meets I
(SpectralBisection.bisectionSpec M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) R0 eps beta A)
Full source on GitHub
Copy link
Theorem (Precision in bits). Let \mathbf{A}\in\mathbb{C}^{n\times n} be Hermitian, with n\ge1 and \|\mathbf{A}\|_2\le R_0, where R_0>0. Given an accuracy target 0<\varepsilon\le2^{-15} and failure probability 0<\theta\le1, write
\Lambda=\log_2\frac1\varepsilon+\log_2\frac1\theta+\log_2 n.
For arithmetic with unit roundoff u=2^{-p}, the numerical reference has the accuracy guarantee below if
p\ge\log_2\frac1\varepsilon+\frac32\log_2\frac1\theta+\frac72\log_2 n+4\log_2\Lambda+24.
Use depth L=\lceil\log_2(1/\varepsilon)\rceil+5, sign-iteration cap c\ge\lceil4\Lambda\rceil, and a stored parameter satisfying
\frac{\varepsilon\sqrt\theta}{2048(n\Lambda)^{3/2}}\le\beta\le\frac{\varepsilon\sqrt\theta}{1024(n\Lambda)^{3/2}}.
The arithmetic must meet the primitive accuracy contracts with \mu_{\mathrm{MM}}(d)=\mu_{\mathrm{QR}}(d)=2d and c_{\mathrm{N}}=\sqrt2. Its absolute-error floor \tau\ge0 and range \Omega must satisfy
300n^3\tau\le\varepsilon\theta\min(R_0,1),\qquad64(R_0+n+\Lambda)\le\Omega.
With independent node samples having the prescribed uniform/Gaussian law and the theorem's sampler measurability assumptions, the reference output satisfies
\|\mathbf{A}-\mathbf{U}\operatorname{diag}(\mathbf{d})\mathbf{U}^{\mathsf{H}}\|_2\le2\varepsilon R_0,
(1-\varepsilon/3)^2\mathbf{I}\preceq\mathbf{U}^{\mathsf{H}}\mathbf{U}\preceq(1+\varepsilon/3)^2\mathbf{I}
with probability at least 1-\theta. Thus sufficient precision grows logarithmically with dimension, inverse tolerance, and inverse failure probability. For example, n=1000, \varepsilon=2^{-15} and \theta=1/100 require 104 bits by this bound, giving a success probability of at least 99\% under the stated assumptions.
Lean statement and details
NLAlib.FloatMachine.IsAccurate.measureReal_not_isApproxDiagonalization_eigh_bisectionDepth_le_of_logb_le_of_hasLaw_eighSampleLaw.{u_1,
u_2}
{F : Type u_1} {M : FloatMachine F ℝ ℂ} {dec : F → ℝ} {u τ Ω : ℝ}
(hM : M.IsAccurate dec u τ Ω (fun d ↦ 2 * ↑d) (fun d ↦ 2 * ↑d) √2)
(hunifm : ∀ (c z : F), MeasurableSet (M.unif c ⁻¹' {z}))
(hunifc : ∀ (c : F), (Set.range (M.unif c)).Countable)
(hnormalm : ∀ (z : F × F), MeasurableSet (M.normal ⁻¹' {z}))
(hnormalc : (Set.range M.normal).Countable) {n : ℕ} (hn : 1 ≤ n)
{A : Matrix (Fin n) (Fin n) (F × F)} (hA : (decodeMatrix dec A).IsHermitian) {R₀ ε β : F} {θ : ℝ}
(hR₀ : specNorm (decodeMatrix dec A) ≤ dec R₀) (hR₀pos : 0 < dec R₀) (hε : 0 < dec ε)
(hε₁ : dec ε ≤ 2⁻¹ ^ 15) (hθ : 0 < θ) (hθ₁ : θ ≤ 1) {Λ : ℝ}
(hΛ : Λ = Real.logb 2 (dec ε)⁻¹ + Real.logb 2 θ⁻¹ + Real.logb 2 ↑n)
(hβ : dec ε * √θ / (2048 * (↑n * Λ) * √(↑n * Λ)) ≤ dec β)
(hβ' : dec β ≤ dec ε * √θ / (1024 * (↑n * Λ) * √(↑n * Λ)))
(hbits :
Real.logb 2 (dec ε)⁻¹ + 3 / 2 * Real.logb 2 θ⁻¹ + 7 / 2 * Real.logb 2 ↑n + 4 * Real.logb 2 Λ +
24 ≤
Real.logb 2 u⁻¹)
{signFuel : ℕ} (hfuel : 4 * Λ ≤ ↑signFuel) (hτ₀ : 0 ≤ τ)
(hτ : 300 * ↑n ^ 3 * τ ≤ dec ε * θ * min (dec R₀) 1) (hΩ : 64 * (dec R₀ + ↑n + Λ) ≤ Ω)
{Ω' : Type u_2} {mΩ' : MeasurableSpace Ω'} {μ : Measure Ω'}
{ζ : List Bool → Ω' → EighSample ℝ ℂ n} (hind : iIndepFun ζ μ)
(hlaw : ∀ (a : List Bool), HasLaw (ζ a) (eighSampleLaw n) μ) :
μ.real
{ω |
¬IsApproxDiagonalization (decodeMatrix dec A)
(decodeMatrix dec (eigh M signFuel (bisectionDepth (dec ε)) A R₀ ε β fun a ↦ ζ a ω).1)
(fun i ↦ dec ((eigh M signFuel (bisectionDepth (dec ε)) A R₀ ε β fun a ↦ ζ a ω).2 i))
(2 * dec ε * dec R₀) (dec ε / 3)} ≤
θ
Full source on GitHub
Copy link
The precision theorem concerns the numerical reference. The next theorem transfers a reference guarantee to the stored-word execution when its arithmetic and random tape realize those assumptions.
Theorem (Accuracy transfers to the stored output). Suppose the numerical reference returns an approximate diagonalization with error parameters \eta=2\varepsilon R_0 and \kappa=\varepsilon/3, except on a tape event of probability at most \theta. For a probability tape law, the certified execution satisfies its functional and resource specification and stores \mathbf{U},\mathbf{d} with
\|\mathbf{A}-\mathbf{U}\operatorname{diag}(\mathbf{d})\mathbf{U}^{\mathsf{H}}\|_2\le 2\varepsilon R_0,
(1-\varepsilon/3)^2\mathbf{I}\preceq\mathbf{U}^{\mathsf{H}}\mathbf{U}\preceq(1+\varepsilon/3)^2\mathbf{I},
with probability at least 1-\theta. Here the matrices and parameters denote decoded stored words.
The failure event includes execution failure, any resource-bound violation, and incorrect numerical output. Establishing the reference premise separately requires Hermitian input, a valid radius bound, sufficient precision, depth and sign-iteration cap, and the stated sampler and tape-law assumptions. This transfer theorem does not by itself establish those numerical hypotheses.
Lean statement and details
NLAlib.SpectralBisection.measureReal_not_accepts_le_of_wordSpecification {K : Type} [Inhabited K]
(M : Ops.Machine K) (dec : K → ℝ) (mm : MatMulMap (K × K)) (qr : QRMap (K × K))
{domain : (Fin 3 → ℕ) → Prop} {admitted : ∃ d, domain d}
(budget : (Fin 3 → ℕ) → Ops.Count (Ops.DenseOp ⊕ Ops.Bookkeeping) (Ops.CmpTst ⊕ Ops.IdxTst))
(scratch work span memory : (Fin 3 → ℕ) → ℕ)
{model :
Ops.AccessModel Ops.DenseOp (Ops.CmpTst ⊕ Ops.IdxTst)
(SpectralBisection.problem domain admitted)}
(algorithm :
Ops.Algorithm model
(SpectralBisection.wordSpecification M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) domain admitted
budget scratch work span memory))
{d : Fin 3 → ℕ} (hd : domain d) (x : (SpectralBisection.problem domain admitted).Input d)
(I : Ops.Interp Ops.DenseOp (Ops.CmpTst ⊕ Ops.IdxTst) K) (hI : model.contracts d x I)
{Omega : Type} [MeasurableSpace Omega] (P : Measure Omega) [IsFiniteMeasure P]
(tape : Omega → Ops.Tape K) {theta : ℝ}
(hReference :
P.real
{omega |
¬IsApproxDiagonalization (decodeMatrix dec (SpectralBisection.inputMatrix d x))
(decodeMatrix dec
(SpectralBisection.inputResult M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) d x
(tape omega)).1)
(fun i ↦
dec
((SpectralBisection.inputResult M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) d x
(tape omega)).2
i))
(2 * dec ((↑x).1.2 1) * dec ((↑x).1.2 0)) (dec ((↑x).1.2 1) / 3)} ≤
theta) :
P.real
{omega |
¬(SpectralBisection.wordSpecification M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) domain
admitted budget scratch work span memory).Accepts
algorithm.program I model.resources (tape omega) d x fun c m ↦
(SpectralBisection.wordSpecification M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) domain
admitted budget scratch work span memory).good
d x (tape omega) c m ∧
SpectralBisection.StoresApproxDiagonalization dec (SpectralBisection.inputMatrix d x)
(2 * dec ((↑x).1.2 1) * dec ((↑x).1.2 0)) (dec ((↑x).1.2 1) / 3) (2, 0) (3, 0) m} ≤
theta
Full source on GitHub
Copy link
The last theorem states the work as an explicit polynomial and combines it with the accuracy guarantee, with the precision hypotheses stated for the machine itself.
Theorem (Operation count and accuracy on one event). Let \mathbf{A}\in\mathbb{C}^{n\times n}, n\ge2, be Hermitian with \|\mathbf{A}\|_2\le R, stored as n^2 pairs of words, with a tolerance 0<\varepsilon\le2^{-15}, a parameter \beta>0, a depth L\ge\lceil\log_2\varepsilon^{-1}\rceil+5 and a sign-iteration cap c of at least newtonSchulzSteps. Matrix multiplication and QR are primitives whose declared cost at order j is at most T(j), with T monotone and superadditive. Arithmetic is a floating-point machine accurate with unit roundoff u (FloatMachine.IsAccurate), natural literals up to \max(n,4) are exact, and the tape holds independent uniform and standard Gaussian draws, rounded to machine words. Let 0<\theta\le1. The Lean statement gives the conditions that make u small relative to \theta\beta and \beta, and those on \beta, the absolute-error floor and the range.
Then, for every interpretation of the primitives that meets the model, with probability at least 1-\theta over the tape the run succeeds, its work and its span are at most
(L+1)\,c\,(362n^3+146n^2+222n)+L\,(1587n^3+760n^2+2429n+305)+1599n^3+818n^2+2509n+680+(L+1)(2c+11)\,T(n),
its scratch and memory are within the bounds of its specification, and it stores \mathbf{U} and a real vector \mathbf{d} with
\|\mathbf{A}-\mathbf{U}\operatorname{diag}(\mathbf{d})\mathbf{U}^{\mathsf{H}}\|_2\le2\varepsilon R,\qquad(1-\varepsilon/3)^2\mathbf{I}\preceq\mathbf{U}^{\mathsf{H}}\mathbf{U}\preceq(1+\varepsilon/3)^2\mathbf{I}.
The last term of the work is the matrix work; the others count the instructions that are not matrix operations. The success of the run and its resource bounds hold on every tape; only the accuracy of the output is probabilistic.
Lean statement and details
Random tape
NLAlib.SpectralBisection.measureReal_not_accepts_countedSpecification_le {K : Type} [Inhabited K]
[MeasurableSpace K] [MeasurableSingletonClass K] {domain : (Fin 3 → ℕ) → Prop}
{admitted : ∃ d, domain d} (M : Ops.Machine K) (dec : K → ℝ) (mm : MatMulMap (K × K))
(qr : QRMap (K × K)) (matrixWork matrixWorkspace : Ops.MatrixOp → List ℕ → ℕ) (T : ℕ → ℕ)
(hLit : ∀ (d : Fin 3 → ℕ), domain d → Ops.IsExactNatLit dec M (max (d 0) 4))
(hN : ∀ (d : Fin 3 → ℕ), domain d → 2 ≤ d 0) (hT : Monotone T)
(hadd : ∀ (i j : ℕ), T i + T j ≤ T (i + j))
(hMatrix : ∀ (o : Ops.MatrixOp) (ds : List ℕ), matrixWork o ds ≤ T (List.foldr max 0 ds))
(roundUnif roundGaussian : ℝ → K) {u floor bound cN : ℝ} {muM muQ : ℕ → ℝ}
(hAcc :
(M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) (M.uniformSample roundUnif)
(M.normalSample roundGaussian)).IsAccurate
dec u floor bound muM muQ cN)
(hUnif : Measurable roundUnif) (hGaussian : Measurable roundGaussian)
(hUnifRange : (Set.range roundUnif).Countable)
(hGaussianRange : (Set.range roundGaussian).Countable) (hMuM : Monotone muM) (hMuQ : Monotone muQ)
(hMuM0 : 0 ≤ muM 0) (hMuQ0 : 0 ≤ muQ 0) (hCN : 0 ≤ cN) {d : Fin 3 → ℕ} (hd : domain d)
(x : (SpectralBisection.problem domain admitted).Input d)
(hA : (decodeMatrix dec (SpectralBisection.inputMatrix d x)).IsHermitian) {theta : ℝ}
(hRadius :
specNorm (decodeMatrix dec (SpectralBisection.inputMatrix d x)) ≤
SpectralBisection.inputRadius dec x)
(hRadiusPos : 0 < SpectralBisection.inputRadius dec x)
(hEps : 0 < SpectralBisection.inputTolerance dec x)
(hEpsMax : SpectralBisection.inputTolerance dec x ≤ 2⁻¹ ^ 15) (hTheta : 0 < theta)
(hThetaMax : theta ≤ 1) (hDepth : bisectionDepth (SpectralBisection.inputTolerance dec x) ≤ d 1)
(hBeta : 0 < SpectralBisection.inputBeta dec x)
(hBetaMax :
SpectralBisection.inputBeta dec x ≤
(↑(d 1) - 1) ^ 2 * SpectralBisection.inputTolerance dec x * √theta /
(52 * ↑(d 1) ^ 2 * (2 * ↑(d 1) - 1) *
√(↑(d 0) * min (↑(d 0)) (↑(d 1) + 1) * min (↑(d 0)) (rexp 1)) *
(2 * √2 * √↑(d 0) + √(Real.log (96 * ↑(d 0) * min (↑(d 0)) (↑(d 1) + 1) / theta)))))
{steps : ℝ}
(hSteps :
steps =
newtonSchulzSteps (theta / (12 * ↑(d 0) * ↑(d 1) * (↑(d 1) + 1)))
(SpectralBisection.inputBeta dec x / (16 * ↑(d 0))))
(hSign :
146 * ↑(d 0) * ↑(d 1) * (↑(d 1) + 1) * (4 * muM (d 0) + 10 + 10 * √↑(d 0)) * u ≤
theta * SpectralBisection.inputBeta dec x)
(hStop :
2048 * (↑(d 0) + steps + 1) * (4 * muM (d 0) + 10 + 10 * √↑(d 0)) * u ≤
SpectralBisection.inputBeta dec x)
(hDeflate :
16 * (4 * muQ (d 0) + 4 * √↑(d 0) * (cN + 1) + 2 * muM (d 0) + 1) * u ≤
SpectralBisection.inputBeta dec x)
(hFuel : steps ≤ ↑(d 2)) (hFloorNonneg : 0 ≤ floor)
(hFloor :
floor * (100 * ↑(d 0) * √↑(d 0)) ≤
min (√(theta / (8 * ↑(d 0) * min (↑(d 0)) (↑(d 1) + 1))))
(SpectralBisection.inputTolerance dec x * min (SpectralBisection.inputRadius dec x) 1))
(hBound :
16 *
(2 * SpectralBisection.inputRadius dec x + ↑(d 0) + 2 * ↑(d 1) + 2 * √2 * √↑(d 0) +
√(Real.log (96 * ↑(d 0) * min (↑(d 0)) (↑(d 1) + 1) / theta))) ≤
bound)
(I : Ops.Interp Ops.DenseOp (Ops.CmpTst ⊕ Ops.IdxTst) K)
(hI :
(Ops.Dense.functionalModel (SpectralBisection.problem domain admitted) M dec
(Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) (fun {m n} ↦ qr)
(Ops.Dense.resources matrixWork matrixWorkspace)).contracts
d x I)
{Omega : Type} [MeasurableSpace Omega] {P : Measure Omega} [IsFiniteMeasure P]
{law : ℕ → Measure ℝ} {ideal : Omega → Ops.Tape ℝ} (hTape : Ops.IsTapeLaw law P ideal)
(hStream :
∀ (dist : Computation.Dist), law (SpectralBisection.distributionStream dist) = dist.law) :
P.real
{omega |
¬(SpectralBisection.countedSpecification M dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) domain
admitted matrixWorkspace T).Accepts
SpectralBisection.bisectionProgram I (Ops.Dense.resources matrixWork matrixWorkspace)
(SpectralBisection.roundTape roundUnif roundGaussian (ideal omega)) d x fun x_1 m ↦
SpectralBisection.StoresApproxDiagonalization dec (SpectralBisection.inputMatrix d x)
(2 * SpectralBisection.inputTolerance dec x * SpectralBisection.inputRadius dec x)
(SpectralBisection.inputTolerance dec x / 3) (2, 0) (3, 0) m} ≤
theta
Full source on GitHub
Copy link