NLA-lib Explorer

NLAlib.Ops.writes_allocs_readBlock

Library · theorem

A scratch-allocation chain preserves its declared output block and tape position. The body may write its scratch buffers and the output region; no scratch content is an assumption at entry, and every scratch allocation is removed before returning.

NLAlib.Ops.writes_allocs_readBlock {K Op Tst : Type} {md : Ops.Mode} {I : Ops.Interp Op Tst K}
  {τ : Ops.Tape K} {ρ : Ops.Env} {m : Ops.Mem K} {lens : List Ops.IExp} {body : Ops.Stmt Op Tst}
  {ns : List ℕ} {z : ℕ × ℕ} {n : ℕ} {ys : List K} (hn : Ops.IExp.evalList ρ.idx lens = some ns)
  (hz : z.1 < List.length m.store)
  (h :
    ∀ (s₁ : Ops.Store K),
      List.length s₁ = List.length m.store + ns.length →
        (∀ (i : ℕ) (hi : i < ns.length), s₁.len (List.length m.store + i) = ns[i]) →
          Ops.Store.Below (List.length m.store) m.store s₁ →
            Ops.Writes md I τ body
              { idx := ρ.idx,
                buf := ρ.buf ++ List.map (fun x ↦ List.length m.store + x) (List.range ns.length) }
              (Ops.Store.inBlock z.1 z.2 n ⊔ Ops.Fp.above (List.length m.store))
              (fun m' ↦ m'.pos = m.pos ∧ m'.store.readBlock z.1 z.2 n = some ys)
              { store := s₁, pos := m.pos }) :
  Ops.Writes md I τ (Ops.Stmt.allocs lens body) ρ (Ops.Store.inBlock z.1 z.2 n)
    (fun m' ↦ m'.pos = m.pos ∧ m'.store.readBlock z.1 z.2 n = some ys) m

Full source on GitHub

Import NLAlib.Ops.Logic.Allocation.