Module MemErasure.
(** The values of the erased memory may be more defined and its permissions are top.*)
(** In retrospect setting the permissions to top was a bad choice. It should have been that the permissions of the erased memory are above the permissions of the other memory. This would make it more reusable and it wouldn't need a second definition for free. *)
Local Notation "a # b" := (PMap.get b a) (at level 1).
Record mem_erasure (m m': mem) :=
{ perm_le:
forall b ofs k,
Mem.valid_block m' b ->
(Mem.mem_access m')#b ofs k = Some Freeable;
erased_contents: forall b ofs,
memval_erasure (ZMap.get ofs ((Mem.mem_contents m) # b))
(ZMap.get ofs ((Mem.mem_contents m') # b));
erased_nb: Mem.nextblock m = Mem.nextblock m'
}.

Lemma getN_erasure:
forall m1 m2 b
(Herase: forall (b : positive) (ofs : ZIndexed.t),
memval_erasure (ZMap.get ofs (Mem.mem_contents m1) # b)
(ZMap.get ofs (Mem.mem_contents m2) # b)),
forall n ofs,
memval_erasure_list
(Mem.getN n ofs (m1.(Mem.mem_contents)#b))
(Mem.getN n ofs (m2.(Mem.mem_contents)#b)).