NLA-lib Explorer

NLAlib.Sign.test_writes

Library · theorem

The complete stopping-test program computes the actual square and a zero/one word for the existing matrix stopping predicate. All seven supplied word regions are pairwise disjoint, including scalar endpoints that may share one buffer; no output initialization is required. A fragment of NLAlib.Sign.signRoutine.

NLAlib.Sign.test_writes {K Op Tst Su Sg : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op]
  [Ops.Has Ops.MatrixOp 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) {τ : Ops.Tape K} {n : ℕ}
  (A : Matrix (Fin n) (Fin n) (K × K)) (η : K) {x one lo hi w v z : ℕ × ℕ} {m : Ops.Mem K}
  (hl : m.Live [x, one, lo, hi, w, v, z])
  (hAP : Ops.Fp.Apart [x, one, lo, hi, w, v, z] [2 * (n * n), 1, 1, 1, 2 * (n * n), 2 * (n * n), 1])
  (hX : m.store.readBlock x.1 x.2 (2 * (n * n)) = some ((Ops.EntryCodec.pair K).packFinMatrix A))
  (hOne : m.store.get one.1 one.2 = some (M.lit 1)) (hLo : m.store.get lo.1 lo.2 = some (M.neg η))
  (hHi : m.store.get hi.1 hi.2 = some η) (hW : w.2 + 2 * (n * n) ≤ m.store.len w.1)
  (hV : v.2 + 2 * (n * n) ≤ m.store.len v.1) (hz : z.2 < m.store.len z.1) :
  Ops.Writes Ops.Mode.total I τ (Sign.test (Ops.Has.inj Ops.MatrixOp.mul))
    (Ops.Env.frame [n] [x, one, lo, hi, w, v, z])
    (Ops.Store.inBlock w.1 w.2 (2 * (n * n)) ⊔ Ops.Store.inBlock v.1 v.2 (2 * (n * n)) ⊔
      Ops.Store.inBlock z.1 z.2 1)
    (fun μ ↦
      μ.pos = m.pos ∧
        μ.store.readBlock w.1 w.2 (2 * (n * n)) =
            some ((Ops.EntryCodec.pair K).packFinMatrix (mm A A)) ∧
          μ.store.get z.1 z.2 =
            some
              (if
                  newtonSchulzTest
                      (M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal) η A =
                    true then
                M.lit 0
              else M.lit 1))
    m

Full source on GitHub

Import NLAlib.Eigensolvers.Sign.Test.