NLA-lib Explorer

NLAlib.Ops.Hermitian.negate_writes_packed

Library · theorem

Scalar negation of a packed matrix returns exactly the existing mathematical negation. Input and output may coincide exactly or occupy spatially disjoint blocks of the same buffer. The theorem is total under readable input, writable output and the scalar functional contract. Shared by the trees of NLAlib.Ops.Hermitian.shift, NLAlib.Ops.Hermitian.shiftNegate.

NLAlib.Ops.Hermitian.negate_writes_packed {K Su Sg : Type} {M : Ops.Machine K} {dec : K → ℝ}
  {mm : MatMulMap (K × K)} {qr : QRMap (K × K)} {unif : K → Su → K} {normal : Sg → K × K}
  {Op Tst : Type} [Inhabited K] [Ops.Has Ops.ScalarOp Op] {I : Ops.Interp Op Tst K}
  (hI : Ops.IsScalar M I) {τ : Ops.Tape K} {r c : ℕ} (A : Matrix (Fin r) (Fin c) (K × K))
  {x y : ℕ × ℕ} {μ : Ops.Mem K}
  (hxy :
    Ops.Fp.Disj (Ops.Store.inBlock x.1 x.2 (2 * (r * c)))
        (Ops.Store.inBlock y.1 y.2 (2 * (r * c))) ∨
      x = y)
  (hX : μ.store.readBlock x.1 x.2 (2 * (r * c)) = some ((Ops.EntryCodec.pair K).packFinMatrix A))
  (hY : y.2 + 2 * (r * c) ≤ μ.store.len y.1) (hl : μ.Live [x, y]) :
  Ops.Writes Ops.Mode.total I τ Ops.Hermitian.negate (Ops.Env.frame [r, c] [x, y])
    (Ops.Store.inBlock y.1 y.2 (2 * (r * c)))
    (fun μ' ↦
      μ'.pos = μ.pos ∧
        μ'.store.readBlock y.1 y.2 (2 * (r * c)) =
          some
            ((Ops.EntryCodec.pair K).packFinMatrix
              ((M.toFloatMachine dec (fun {l m n} ↦ mm) (fun {m n} ↦ qr) unif normal).negMat A)))
    μ

Full source on GitHub

Import NLAlib.Matrix.FinitePrecision.OpsHermitian.