NLA-lib Explorer

NLAlib.Ops.writes_allocs

Library · theorem

An allocation chain: k scratch buffers at the handles L, L + 1, …, L + k - 1 (L = m.store.length) with their lengths, as one named state; after the body they are all freed. The rule for the blocks that allocate seven or eight buffers.

NLAlib.Ops.writes_allocs {Op Tst K : 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 ℕ} (hn : Ops.IExp.evalList ρ.idx lens = some ns) {F : Ops.Fp} {P : Ops.Mem K → Prop}
  (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))
              (fun m' ↦
                ∀ (s₂ : Ops.Store K),
                  List.length s₂ = List.length m.store →
                    Ops.Store.Below (List.length m.store) m'.store s₂ →
                      P { store := s₂, pos := m'.pos })
              { store := s₁, pos := m.pos }) :
  Ops.Writes md I τ (Ops.Stmt.allocs lens body) ρ F P m

Full source on GitHub

Import NLAlib.Ops.Logic.Writes.