NLA-lib Explorer

NLAlib.Ops.writes_fillRel

Library · theorem

The loop that fills a vector with values known only by a relation (the outputs of relational calls): round i writes some x with R i x in the cell o + i; at the end the block holds a vector all of whose entries satisfy R. The fill pattern of gemm, of the coefficients of Gram–Schmidt, of a loop of dot products.

NLAlib.Ops.writes_fillRel {Op Tst K : Type} {md : Ops.Mode} {I : Ops.Interp Op Tst K}
  {τ : Ops.Tape K} {ρ : Ops.Env} {m : Ops.Mem K} [Nonempty K] {n : Ops.IExp}
  {body : Ops.Stmt Op Tst} {N b o : ℕ} (hn : Ops.IExp.eval ρ.idx n = some N) (R : ℕ → K → Prop)
  (pos : ℕ → ℕ) (hpos : m.pos = pos 0)
  (hstep :
    ∀ i < N,
      ∀ (m' : Ops.Mem K),
        Ops.Store.EqOff (Ops.Store.inBlock b o i) m.store m'.store →
          (∃ v, m'.store.HoldsVec b o i v ∧ ∀ i' < i, R i' (v i')) →
            m'.pos = pos i →
              Ops.Writes md I τ body (ρ.pushIdx i) (Ops.Store.inBlock b (o + i) 1)
                (fun m'' ↦ (∃ x, m''.store.get b (o + i) = some x ∧ R i x) ∧ m''.pos = pos (i + 1))
                m') :
  Ops.Writes md I τ (Ops.Stmt.loop n body) ρ (Ops.Store.inBlock b o N)
    (fun m' ↦ (∃ v, m'.store.HoldsVec b o N v ∧ ∀ i < N, R i (v i)) ∧ m'.pos = pos N) m

Full source on GitHub

Import NLAlib.Ops.Logic.Loop.