Module MemoryLemmas.
Global Notation "a # b" := (Maps.PMap.get b a) (at level 1).
Transparent Mem.store.
Transparent Mem.alloc.
Definition max_inv mf := forall b ofs, Mem.valid_block mf b ->
permission_at mf b ofs Max = Some Freeable.

Lemma setN_inside: forall (vl : list memval) (c : ZMap.t memval) (ofs0 ofs: Z),
Intv.In ofs0 (ofs, (ofs + Z.of_nat (length vl))%Z) ->
ZMap.get ofs0 (Mem.setN vl ofs c) = List.nth (Z.to_nat (ofs0 - ofs)%Z) vl Undef.