NLA-lib Explorer

NLAlib.Ops.writes_allocs_preserving_post

Library · theorem

Scoped cell scratch can be removed once the postcondition depends only on surviving storage. This is the one-cell-format form of writes_allocsAs_preserving_post.

NLAlib.Ops.writes_allocs_preserving_post {K Op Tst : 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 ℕ} {F : Ops.Fp} {P : Ops.Mem K → Prop} (hn : Ops.IExp.evalList ρ.idx lens = 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.allocs lens body) ρ F P m

Full source on GitHub

Import NLAlib.Ops.Logic.Allocation.