NLA-lib Explorer

NLAlib.Ops.StoredOperator.writes_matvec

Library · theorem

Explicit-data matrix-vector application writes its mathematical vector after reading both inputs. Output separation is the explicit local operation-model admission.

NLAlib.Ops.StoredOperator.writes_matvec {K Op Tst : Type} [Semiring K]
  [Ops.Has Ops.StoredOperatorOp Op] {I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env}
  {m : Ops.Mem K} {dataLength : ℕ → ℕ → ℕ} {matrix : (m n : ℕ) → List K → Matrix (Fin m) (Fin n) K}
  (hI : Ops.StoredOperator.IsExact dataLength matrix I) {ds : List Ops.IExp}
  {ins outs : List Ops.Operand} {rows cols : ℕ} {data x y : ℕ × ℕ} {as xs : List K}
  (hd : Ops.IExp.evalList ρ.idx ds = some [rows, cols])
  (ha : Ops.Operand.evalList ρ ins = some [data, x]) (hb : Ops.Operand.evalList ρ outs = some [y])
  (hl : m.Live [data, x, y]) (hA : m.store.readBlock data.1 data.2 (dataLength rows cols) = some as)
  (hX : m.store.readBlock x.1 x.2 cols = some xs)
  (hYA :
    Ops.Fp.Disj (Ops.Store.inBlock y.1 y.2 rows)
      (Ops.Store.inBlock data.1 data.2 (dataLength rows cols)))
  (hYX : Ops.Fp.Disj (Ops.Store.inBlock y.1 y.2 rows) (Ops.Store.inBlock x.1 x.2 cols))
  (hY : y.2 + rows ≤ m.store.len y.1) :
  Ops.Writes Ops.Mode.total I τ
    (Ops.Stmt.call (Ops.Has.inj Ops.StoredOperatorOp.matvec) ds ins outs) ρ
    (Ops.Store.inBlock y.1 y.2 rows)
    (fun m' ↦
      m'.pos = m.pos ∧
        m'.store.readBlock y.1 y.2 rows =
          some (List.ofFn fun i ↦ ∑ j, matrix rows cols as i j * xs.getD (↑j) 0))
    m

Full source on GitHub

Import NLAlib.Ops.Logic.StoredOperator.