NLA-lib Explorer

NLAlib.Ops.writes_matrixMul_packFinMatrix

Library · theorem

A matrix multiplication call writes the supplied routine's result on the actual stored matrices and preserves every other cell. Complete input blocks are read before writing, so input/output buffers may alias; live handles and sufficient output capacity are explicit.

NLAlib.Ops.writes_matrixMul_packFinMatrix {K E Op Tst : Type} [Inhabited K]
  [Ops.Has Ops.MatrixOp Op] {md : Ops.Mode} {I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env}
  {m : Ops.Mem K} (C : Ops.EntryCodec K E)
  (mm :
    {l m n : ℕ} → Matrix (Fin l) (Fin m) E → Matrix (Fin m) (Fin n) E → Matrix (Fin l) (Fin n) E)
  (hI : Ops.IsMatrixMul C (fun {l m n} ↦ mm) I) {l k n : ℕ} (A : Matrix (Fin l) (Fin k) E)
  (B : Matrix (Fin k) (Fin n) E) {ds : List Ops.IExp} {ins outs : List Ops.Operand} {x y z : ℕ × ℕ}
  (hd : Ops.IExp.evalList ρ.idx ds = some [l, k, n]) (ha : Ops.Operand.evalList ρ ins = some [x, y])
  (hb : Ops.Operand.evalList ρ outs = some [z]) (hl : m.Live [x, y, z])
  (hA : m.store.readBlock x.1 x.2 (k * l * C.width) = some (C.packFinMatrix A))
  (hB : m.store.readBlock y.1 y.2 (n * k * C.width) = some (C.packFinMatrix B))
  (hz : z.2 + n * l * C.width ≤ m.store.len z.1) :
  Ops.Writes md I τ (Ops.Stmt.call (Ops.Has.inj Ops.MatrixOp.mul) ds ins outs) ρ
    (Ops.Store.inBlock z.1 z.2 (n * l * C.width))
    (fun m' ↦
      m'.pos = m.pos ∧
        m'.store.readBlock z.1 z.2 (n * l * C.width) = some (C.packFinMatrix (mm A B)))
    m

Full source on GitHub

Import NLAlib.Ops.Logic.MatrixPacked.