NLAlib.Ops.evalCounted_allocsAs_inv
Library · theorem
A successful formatted allocation chain exposes its actual inner counted run and fresh store geometry. Allocation and cleanup preserve counts. No relation between the inner and outer scratch peaks is asserted by this decomposition.
NLAlib.Ops.evalCounted_allocsAs_inv {K Op Tst : Type} {I : Ops.Interp Op Tst K} {τ : Ops.Tape K}
{ρ : Ops.Env} {W : Op → List ℕ → ℕ} {allocations : List (Ops.StorageFormat × Ops.IExp)}
{body : Ops.Stmt Op Tst} {ns : List ℕ} {a b : Ops.St Op Tst K}
(hn : Ops.IExp.evalList ρ.idx (List.map Prod.snd allocations) = some ns)
(hr : Ops.evalCounted I W τ (Ops.Stmt.allocsAs allocations body) ρ a = some b) :
∃ inner final,
Ops.evalCounted I W τ body
{ idx := ρ.idx,
buf := ρ.buf ++ List.map (fun x ↦ List.length a.mem.store + x) (List.range ns.length) }
inner =
some final ∧
List.length inner.mem.store = List.length a.mem.store + ns.length ∧
(∀ (i : ℕ) (hi : i < ns.length),
inner.mem.store.len (List.length a.mem.store + i) = ns[i]) ∧
Ops.Store.Below (List.length a.mem.store) a.mem.store inner.mem.store ∧
inner.mem.pos = a.mem.pos ∧ inner.cost = a.cost ∧ final.cost = b.costImport NLAlib.Ops.Logic.Allocation.