(** A range of bytes, with full permissions and unspecified contents. *)
Program Definition range (b: block) (lo hi: Z) : massert := {|
m_pred := fun m =>
0 <= lo /\ hi <= Ptrofs.modulus
/\ (forall i k p, lo <= i < hi -> Mem.perm m b i k p);
m_footprint := fun b' ofs' => b' = b /\ lo <= ofs' < hi
|}.
Next Obligation.
split; auto. split; auto. intros. eapply Mem.perm_unchanged_on; eauto. simpl; auto.
Qed.
Next Obligation.
apply Mem.perm_valid_block with ofs Cur Freeable; auto.
Qed.

(* Specifications: *)
Lemma alloc_rule:
forall m lo hi b m' P,
Mem.alloc m lo hi = (m', b) ->
0 <= lo -> hi <= Ptrofs.modulus ->
m |= P ->
m' |= range b lo hi ** P.
Lemma range_split:
forall b lo hi P mid m,
lo <= mid <= hi ->
m |= range b lo hi ** P ->
m |= range b lo mid ** range b mid hi ** P.
Lemma range_drop_left:
forall b lo hi P mid m,
lo <= mid <= hi ->
m |= range b lo hi ** P ->
m |= range b mid hi ** P.
Lemma range_drop_right:
forall b lo hi P mid m,
lo <= mid <= hi ->
m |= range b lo hi ** P ->
m |= range b lo mid ** P.
Lemma range_split_2:
forall b lo hi P mid al m,
lo <= align mid al <= hi ->
al > 0 ->
m |= range b lo hi ** P ->
m |= range b lo mid ** range b (align mid al) hi ** P.
Lemma range_preserved:
forall m m' b lo hi,
m |= range b lo hi ->
(forall i k p, lo <= i < hi -> Mem.perm m b i k p -> Mem.perm m' b i k p) ->
m' |= range b lo hi.