(* FIXME Build an rmap that's identical to phi except where m has allocated. *)
refine (proj1_sig (remake_rmap (fun loc =>
fmap_option (res_option (phi @ loc))
(* phi = NO *)
(fmap_option (access_at m loc Cur)
(NO Share.bot bot_unreadable)
(fun p =>
match p with
| Freeable => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP
| _ => NO Share.Lsh Lsh_nonreadable
end))
(* phi = YES *)
(fun _ => phi @ loc)) (ghost_of phi) (level phi) _ (ghost_of_approx phi))).
(* Build an [rmap] that's identical to [phi] except where [m] has stored. *)
Definition inflate_store: rmap. refine (
proj1_sig (make_rmap (fun loc =>
match phi @ loc with
| YES sh rsh (VAL _) _ => YES sh rsh (VAL (contents_at m loc)) NoneP
| YES _ _ _ _ => resource_fmap (approx (level phi)) (approx (level phi)) (phi @ loc)
| _ => phi @ loc
end) (ghost_of phi) (level phi) _ (ghost_of_approx phi))).

(* Specifications: *)
Lemma adr_inv: forall (b b': block) (ofs ofs': Z) ch,
~ adr_range (b, ofs) (size_chunk ch) (b', ofs') ->
b <> b' \/ ~ ofs <= ofs' < ofs + size_chunk ch.
Lemma range_inv: forall ofs ofs' ch,
~ ofs <= ofs' < ofs + size_chunk ch ->
ofs' < ofs \/ ofs' >= ofs + size_chunk ch.
Lemma nextblock_access_empty: forall m b ofs k, (b >= nextblock m)%positive
-> access_at m (b, ofs) k = None.