NLA-lib Explorer

NLAlib.Sign.initialized_writes

Library · theorem

The explicit initializer and capped loop compute the mathematical sign algorithm on the actual stored input and parameters: a fragment of NLAlib.Sign.signRoutine, run on the workspace that the routine allocates. The written blocks are pairwise apart and apart from the matrix and the parameters, which may overlap each other. Workspace needs capacity, not initial contents. The theorem is total and does not assume numerical convergence or successful execution.

NLAlib.Sign.initialized_writes {K Op Tst Su Sg : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.MatrixOp Op] [Ops.Has Ops.IndexOp Op] [Ops.Has Ops.CmpTst Tst] {M : Ops.Machine K}
  {dec : K → ℝ} {mm : MatMulMap (K × K)} {qr : QRMap (K × K)} {unif : K → Su → K}
  {normal : Sg → K × K} {I : Ops.Interp Op Tst K} (hS : Ops.IsScalar M I) (hC : Ops.IsCmp dec I)
  (hMM : Ops.IsMatrixMul (Ops.EntryCodec.pair K) (fun {l m n} ↦ mm) I) (hIndex : Ops.IsIndexLit M I)
  {τ : Ops.Tape K} {n cap : ℕ} (A : Matrix (Fin n) (Fin n) (K × K)) (eps b : K)
  {a par x w v t : ℕ × ℕ} {m : Ops.Mem K} (h01 : dec (M.lit 0) ≠ dec (M.lit 1))
  (hl : m.Live [a, par, x, w, v, t])
  (hAP : Ops.Fp.Apart [x, w, v, t] [2 * (n * n), 2 * (n * n), 2 * (n * n), 5])
  (hsrc :
    (Ops.Store.inBlock a.1 a.2 (2 * (n * n)) ⊔ Ops.Store.inBlock par.1 par.2 2).Disj
      (Ops.Store.inBlock x.1 x.2 (2 * (n * n)) ⊔ Ops.Store.inBlock w.1 w.2 (2 * (n * n)) ⊔
          Ops.Store.inBlock v.1 v.2 (2 * (n * n)) ⊔
        Ops.Store.inBlock t.1 t.2 5))
  (hA : m.store.readBlock a.1 a.2 (2 * (n * n)) = some ((Ops.EntryCodec.pair K).packFinMatrix A))
  (hPar : m.store.readBlock par.1 par.2 2 = some [eps, b])
  (hx : x.2 + 2 * (n * n) ≤ m.store.len x.1) (hw : w.2 + 2 * (n * n) ≤ m.store.len w.1)
  (hv : v.2 + 2 * (n * n) ≤ m.store.len v.1) (ht : t.2 + 5 ≤ m.store.len t.1) :
  Ops.Writes Ops.Mode.total I τ (Sign.initialized (Ops.Has.inj Ops.MatrixOp.mul))
    (Ops.Env.frame [n, cap] [a, par, x, w, v, t, x, w, v, t])
    (Ops.Store.inBlock x.1 x.2 (2 * (n * n)) ⊔ Ops.Store.inBlock w.1 w.2 (2 * (n * n)) ⊔
        Ops.Store.inBlock v.1 v.2 (2 * (n * n)) ⊔
      Ops.Store.inBlock t.1 t.2 5)
    (fun μ ↦
      μ.pos = m.pos ∧
        μ.store.readBlock x.1 x.2 (2 * (n * n)) =
          some
            ((Ops.EntryCodec.pair K).packFinMatrix
              (newtonSchulzSign
                (M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal) eps b cap
                A)))
    m

Full source on GitHub

Import NLAlib.Eigensolvers.Sign.Initialized.