NLA-lib Explorer

NLAlib.TriangularSolve.writes_mulSubLoop

Library · theorem

The accumulation loop: for k < N, q := a_k \mathbf{b}_k into the scratch cell w and c := c - q in place at the cell z. The factors are read at cells off z and w, so they do not change during the loop, and the accumulator ends with mulSubWord. The operands are given by their evaluation in each round.

NLAlib.TriangularSolve.writes_mulSubLoop {K Op Tst : Type} [Ops.Has Ops.ScalarOp Op]
  {M : Ops.Machine K} {I : Ops.Interp Op Tst K} (hI : Ops.IsScalar M I) {τ : Ops.Tape K}
  {ρ : Ops.Env} {m : Ops.Mem K} {bound : Ops.IExp} {N : ℕ} (hN : Ops.IExp.eval ρ.idx bound = some N)
  {a b c t : Ops.Operand} {p q : ℕ → ℕ × ℕ} {z w : ℕ × ℕ}
  (ha : ∀ k < N, Ops.Operand.eval (ρ.pushIdx k) a = some (p k))
  (hb : ∀ k < N, Ops.Operand.eval (ρ.pushIdx k) b = some (q k))
  (hc : ∀ k < N, Ops.Operand.eval (ρ.pushIdx k) c = some z)
  (ht : ∀ k < N, Ops.Operand.eval (ρ.pushIdx k) t = some w) {A B : ℕ → K} {v : K}
  (hA : ∀ k < N, m.store.get (p k).1 (p k).2 = some (A k))
  (hB : ∀ k < N, m.store.get (q k).1 (q k).2 = some (B k)) (hv : m.store.get z.1 z.2 = some v)
  (hzw : z.1 ≠ w.1) (hpz : ∀ k < N, p k ≠ z) (hqz : ∀ k < N, q k ≠ z) (hpw : ∀ k < N, (p k).1 ≠ w.1)
  (hqw : ∀ k < N, (q k).1 ≠ w.1) (hw : w.2 < m.store.len w.1) :
  Ops.Writes Ops.Mode.total I τ
    (Ops.Stmt.loop bound
      ((Ops.Stmt.call (Ops.Has.inj Ops.ScalarOp.mul) [] [a, b] [t]).seq
        (Ops.Stmt.call (Ops.Has.inj Ops.ScalarOp.sub) [] [c, t] [c])))
    ρ (Ops.Store.inBlock z.1 z.2 1 ⊔ Ops.Store.inBlock w.1 w.2 1)
    (fun m' ↦ m'.pos = m.pos ∧ m'.store.get z.1 z.2 = some (TriangularSolve.mulSubWord M A B v N)) m

Full source on GitHub

Import NLAlib.Matrix.Factorizations.TriangularSolve.Substitution.