NLA-lib Explorer

NLAlib.SpectralBisection.measureReal_not_accepts_countedSpecification_le

Library · theorem

Headline of spectral-bisection-operation-count-accuracy Random tape

Spectral bisection on a random tape: operation count and accuracy on one event. Let \mathbf{A} \in \mathbb{C}^{n \times n} be Hermitian with \|\mathbf{A}\|_2 \le R, stored as n^2 pairs of words, with a tolerance 0 < \varepsilon \le 2^{-15}, a parameter \beta > 0, a recursion depth L \ge \lceil \log_2 \varepsilon^{-1} \rceil + 5 and an iteration cap c for the Newton–Schulz sign iteration, at least newtonSchulzSteps. The program is the randomized spectral bisection: at each node it shifts by a random point, computes a matrix sign by Newton–Schulz iteration, extracts the two invariant subspaces by a randomized rank-revealing QR, and recurses; it calls matrix multiplication and QR as 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), with u small relative to \theta \beta and \beta (hypotheses hSign, hStop, hDeflate), and the tape holds independent uniform and standard Gaussian draws, rounded to machine words.

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 span are at most (L + 1)\, c\, (362 n^{3} + 146 n^{2} + 222 n) + L\, (1587 n^{3} + 760 n^{2} + 2429 n + 305) + 1599 n^{3} + 818 n^{2} + 2509 n + 680 + (L + 1)(2 c + 11)\, T(n), its scratch and memory are within the polynomial bounds of the specification, and it leaves in memory a matrix \mathbf{U} and a real vector \mathbf{d} with \|\mathbf{A} - \mathbf{U} \operatorname{diag}(\mathbf{d}) \mathbf{U}^{\mathsf{H}}\|_2 \le 2 \varepsilon R, \qquad (1 - \varepsilon/3)^{2} \mathbf{I} \preceq \mathbf{U}^{\mathsf{H}} \mathbf{U} \preceq (1 + \varepsilon/3)^{2} \mathbf{I}.

The success, the resource bounds and the stored output equal to the reference computation hold on every tape; only the accuracy of that output is probabilistic. The first four terms of the work count the instructions that are not matrix operations and overestimate the scalar overhead of a level, whose blocks are charged at full order; the last term is the matrix work. The accuracy is that of [Shah2024, Theorem 4.2] for the rounded reference computation. Result: spectral-bisection-operation-count-accuracy

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

Import NLAlib.Eigensolvers.SpectralBisection.RunTheorem.