NLA-lib Explorer

NLAlib.Ops.writes_matrixMul

Library · theorem

A multiplication call writes its word-level routine's exact packed result. Both inputs are read before the output is written, so input/output overlap is allowed.

NLAlib.Ops.writes_matrixMul {K E Op Tst : Type} [Inhabited K] [Ops.Has Ops.MatrixOp Op]
  {I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env} {μ : 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) {ds : List Ops.IExp} {ins outs : List Ops.Operand}
  {l m n : ℕ} {a b c : ℕ × ℕ} {as bs : List K} (hd : Ops.IExp.evalList ρ.idx ds = some [l, m, n])
  (ha : Ops.Operand.evalList ρ ins = some [a, b]) (hb : Ops.Operand.evalList ρ outs = some [c])
  (hl : μ.Live [a, b, c]) (hA : μ.store.readBlock a.1 a.2 (m * l * C.width) = some as)
  (hB : μ.store.readBlock b.1 b.2 (n * m * C.width) = some bs)
  (hC : c.2 + n * l * C.width ≤ μ.store.len c.1) :
  Ops.Writes Ops.Mode.total I τ (Ops.Stmt.call (Ops.Has.inj Ops.MatrixOp.mul) ds ins outs) ρ
    (Ops.Store.inBlock c.1 c.2 (n * l * C.width))
    (fun μ' ↦
      μ'.pos = μ.pos ∧
        μ'.store.readBlock c.1 c.2 (n * l * C.width) =
          some (C.packFinMatrix (mm (C.matrix l m as) (C.matrix m n bs))))
    μ

Full source on GitHub

Import NLAlib.Ops.Logic.Matrix.