NLAlib.Ops.writes_allocsAs_preserving_post
Library · theorem
Scoped scratch can be removed once the postcondition depends only on surviving storage. The body proves its ordinary postcondition; a single transport under agreement below the caller's original handle count accounts for every allocation's cleanup.
NLAlib.Ops.writes_allocsAs_preserving_post {K Op Tst : Type} {md : Ops.Mode}
{I : Ops.Interp Op Tst K} {τ : Ops.Tape K} {ρ : Ops.Env} {m : Ops.Mem K}
{allocations : List (Ops.StorageFormat × Ops.IExp)} {body : Ops.Stmt Op Tst} {ns : List ℕ}
{F : Ops.Fp} {P : Ops.Mem K → Prop}
(hn : Ops.IExp.evalList ρ.idx (List.map Prod.snd allocations) = some ns)
(hkeep :
∀ {s s' : Ops.Store K} {p : ℕ},
Ops.Store.Below (List.length m.store) s s' →
P { store := s, pos := p } → P { store := s', pos := p })
(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) }
(F ⊔ Ops.Fp.above (List.length m.store)) P { store := s₁, pos := m.pos }) :
Ops.Writes md I τ (Ops.Stmt.allocsAs allocations body) ρ F P mImport NLAlib.Ops.Logic.Allocation.