NLAlib.Ops.writes_loop_disjoint_prefix_scratch
Library · theorem
Independent output regions may share reusable scratch. The scratch can change every iteration but is disjoint from every retained result region. The body receives the actual prefix frame plus scratch, so future source values can be retained through this same geometry.
NLAlib.Ops.writes_loop_disjoint_prefix_scratch {K Op Tst : Type} {md : Ops.Mode}
{I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env} {m : Ops.Mem K} {n : Ops.IExp} {N : ℕ}
{body : Ops.Stmt Op Tst} {F scratch : Ops.Fp} (region : ℕ → Ops.Fp)
(result : ℕ → Ops.Store K → Prop) (hn : Ops.IExp.eval ρ.idx n = some N)
(hsub : ∀ i < N, region i ≤ F) (hscratch : scratch ≤ F)
(hdisj : ∀ i < N, ∀ j < N, i ≠ j → (region i).Disj (region j))
(hprotect : ∀ i < N, scratch.Disj (region i))
(hread : ∀ i < N, Ops.Store.ReadsOnly (region i) (result i))
(hstep :
∀ i < N,
∀ (m' : Ops.Mem K),
Ops.Store.EqOff (Ops.Fp.loopPrefix region i ⊔ scratch) m.store m'.store →
Ops.Writes md I τ body (ρ.pushIdx i) (region i ⊔ scratch)
(fun m'' ↦ m''.pos = m'.pos ∧ result i m''.store) m') :
Ops.Writes md I τ (Ops.Stmt.loop n body) ρ F
(fun m' ↦ m'.pos = m.pos ∧ ∀ i < N, result i m'.store) mImport NLAlib.Ops.Logic.IndependentLoop.