NLA-lib Explorer

NLAlib.Krylov.Lanczos.Reorth.advance_writes

Library · theorem

Exact arithmetic Oracle: matrix–vector product

A full round executes for every initialized output column, including exact breakdown. The output records the raw residual, both classical passes, and the final normalization.

A fragment of NLAlib.Krylov.Lanczos.Reorth.solveRoutine: one round of its loop, on the scratch the solver allocates and the columns of V and C at the round index.

NLAlib.Krylov.Lanczos.Reorth.advance_writes {K Op Tst : Type} [Inhabited K]
  [Ops.Has Ops.ScalarOp Op] [Ops.Has Ops.Blas1Op Op] [Ops.Has Ops.OperatorOp Op]
  [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine K} {dec : K → ℝ} {n cap j L B V C bo vo co : ℕ}
  {A : Matrix (Fin n) (Fin n) ℝ} {I : Ops.Interp Op Tst K} {ok : ℕ → Prop} (hS : Ops.IsScalar M I)
  (hM : Ops.ExactModel dec M) (hB : Ops.IsExactBlas1 dec ok I) (hok : ok n)
  (hA : Ops.IsExactMatvec dec A I) (hCmp : Ops.IsCmp dec I) {τ : Ops.Tape K} {μ : Ops.Mem K}
  {ps qs basis next : List K} {β β₀ ν₀ : K} (hj : j < cap) (hVL : V < L) (hCL : C < L) (hVC : V ≠ C)
  (hlen : List.length μ.store = L + 3) (hw : μ.store.len (L + 1) = n) (hp : μ.store.len L = n)
  (ht : μ.store.len (L + 2) = 2) (hroom : co + 3 * cap + 2 ≤ μ.store.len C)
  (hps : μ.store.readBlock L 0 n = some ps) (hqs : μ.store.readBlock V (vo + j * n) n = some qs)
  (hbasis : μ.store.readBlock V vo ((j + 1) * n) = some basis)
  (hnext : μ.store.readBlock V (vo + (j + 1) * n) n = some next)
  (hnroom : vo + (j + 1) * n + n ≤ μ.store.len V) (hβ : μ.store.get C (co + cap + j) = some β)
  (hβ₀ : μ.store.get C (co + cap + j + 1) = some β₀)
  (hν₀ : μ.store.get C (co + 2 * cap + 2 + j) = some ν₀) (hnextzero : Ops.decv dec n next = 0)
  (hβzero : dec β₀ = 0) (hνzero : dec ν₀ = 0) :
  Ops.Writes Ops.Mode.total I τ Krylov.Lanczos.Reorth.advance
    { idx := [n, cap, bo, vo, co, j], buf := [B, V, C, L, L + 1, L + 2] }
    (Ops.Fp.blocks
      [(L, 0), (L + 1, 0), (L + 2, 0), (C, co + j), (C, co + cap + j + 1),
        (C, co + 2 * cap + 2 + j), (V, vo + (j + 1) * n)]
      [n, n, 2, 1, 1, 1, n])
    (fun μ' ↦
      μ'.pos = μ.pos ∧
        ∃ raw reduced ys α ν β',
          μ'.store.readBlock L 0 n = some qs ∧
            μ'.store.readBlock (L + 1) 0 n = some reduced ∧
              μ'.store.readBlock V (vo + (j + 1) * n) n = some ys ∧
                μ'.store.get C (co + j) = some α ∧
                  μ'.store.get C (co + 2 * cap + 2 + j) = some ν ∧
                    μ'.store.get C (co + cap + j + 1) = some β' ∧
                      dec α =
                          lanczosAlpha A
                            { prev := Ops.decv dec n ps, cur := Ops.decv dec n qs, beta := dec β } ∧
                        Ops.decv dec n raw =
                            A *ᵥ Ops.decv dec n qs - dec β • Ops.decv dec n ps -
                              dec α • Ops.decv dec n qs ∧
                          dec ν = ‖WithLp.toLp 2 (Ops.decv dec n raw)‖ ∧
                            Krylov.Lanczos.Reorth.TwoPassOut dec 0 0 n (j + 1) basis raw reduced ∧
                              Ops.decv dec n ys =
                                  ‖WithLp.toLp 2 (Ops.decv dec n reduced)‖⁻¹ •
                                    Ops.decv dec n reduced ∧
                                dec β' = ‖WithLp.toLp 2 (Ops.decv dec n reduced)‖ ∧
                                  ∃ σ,
                                    μ'.store.get (L + 2) 0 = some σ ∧
                                      dec σ = Ops.decv dec n reduced ⬝ᵥ Ops.decv dec n reduced)
    μ

Full source on GitHub

Import NLAlib.Krylov.Lanczos.Reorth.Advance.