NLA-lib Explorer

NLAlib.Ops.writes_matrixQR_packFinMatrix

Library · theorem

A QR call writes both factors of the supplied routine on its actual stored matrix and preserves every other cell. The two output blocks are disjoint; either may alias the input because the complete input is read before the outputs are written.

NLAlib.Ops.writes_matrixQR_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)
  (qr : {m n : ℕ} → Matrix (Fin m) (Fin n) E → Matrix (Fin m) (Fin m) E × Matrix (Fin m) (Fin n) E)
  (hI : Ops.IsMatrixQR C (fun {m n} ↦ qr) I) {r c : ℕ} (A : Matrix (Fin r) (Fin c) E)
  {ds : List Ops.IExp} {ins outs : List Ops.Operand} {x q z : ℕ × ℕ}
  (hd : Ops.IExp.evalList ρ.idx ds = some [r, c]) (ha : Ops.Operand.evalList ρ ins = some [x])
  (hb : Ops.Operand.evalList ρ outs = some [q, z]) (hl : m.Live [x, q, z])
  (hA : m.store.readBlock x.1 x.2 (c * r * C.width) = some (C.packFinMatrix A))
  (hap :
    Ops.Fp.Disj (Ops.Store.inBlock q.1 q.2 (r * r * C.width))
      (Ops.Store.inBlock z.1 z.2 (c * r * C.width)))
  (hq : q.2 + r * r * C.width ≤ m.store.len q.1) (hz : z.2 + c * r * C.width ≤ m.store.len z.1) :
  Ops.Writes md I τ (Ops.Stmt.call (Ops.Has.inj Ops.MatrixOp.qr) ds ins outs) ρ
    (Ops.Store.inBlock q.1 q.2 (r * r * C.width) ⊔ Ops.Store.inBlock z.1 z.2 (c * r * C.width))
    (fun m' ↦
      m'.pos = m.pos ∧
        m'.store.readBlock q.1 q.2 (r * r * C.width) = some (C.packFinMatrix (qr A).1) ∧
          m'.store.readBlock z.1 z.2 (c * r * C.width) = some (C.packFinMatrix (qr A).2))
    m

Full source on GitHub

Import NLAlib.Ops.Logic.MatrixPacked.