NLA-lib Explorer

NLAlib.Ops.eval_allocs

Library · theorem

The run of an allocation chain: the body runs on the store with the buffers pushed, at the handles L, L + 1, … above the L buffers of the memory, and they are popped after it.

NLAlib.Ops.eval_allocs {K Op Tst : Type} {I : Ops.Interp Op Tst K} {τ : Ops.Tape K}
  {lens : List Ops.IExp} {body : Ops.Stmt Op Tst} {ρ : Ops.Env} {m : Ops.Mem K} {ns : List ℕ} :
  Ops.IExp.evalList ρ.idx lens = some ns →
    Ops.eval I τ (Ops.Stmt.allocs lens body) ρ m =
      Option.map (fun m' ↦ { store := Ops.Store.pop^[ns.length] m'.store, pos := m'.pos })
        (Ops.eval I τ body
          { idx := ρ.idx,
            buf := ρ.buf ++ List.map (fun x ↦ List.length m.store + x) (List.range ns.length) }
          { store := m.store.pushAll ns, pos := m.pos })

Full source on GitHub

Import NLAlib.Ops.RunMeasurable.