(** ** Memory invariants *)

(** A stack location is private if it is not the image of a valid
   location and we have full rights on it. *)

Definition loc_private (F: meminj) (m m': mem) (sp: block) (ofs: Z) : Prop :=
  Mem.perm m' sp ofs Cur Freeable /\
  (forall b delta, F b = Some(sp, delta) -> ~Mem.perm m b (ofs - delta) Max Nonempty).(** Likewise, for a range of locations. *)

Definition range_private (F: meminj) (m m': mem) (sp: block) (lo hi: Z) : Prop :=
  forall ofs, lo <= ofs < hi -> loc_private F m m' sp ofs.

Lemma range_private_invariant: forall F m m' sp lo hi F1 m1 m1', range_private F m m' sp lo hi -> (forall b delta ofs, F1 b = Some(sp, delta) -> Mem.perm m1 b ofs Max Nonempty -> lo <= ofs + delta < hi -> F b = Some(sp, delta) /\ Mem.perm m b ofs Max Nonempty) -> (forall ofs, Mem.perm m' sp ofs Cur Freeable -> Mem.perm m1' sp ofs Cur Freeable) -> range_private F1 m1 m1' sp lo hi.