Definition only_blocks {S: block -> Prop} (S_dec: forall b, {S b}+{~S b}) (w: rmap) : rmap.
refine (proj1_sig (make_rmap (fun loc => if S_dec (fst loc) then w @ loc else core (w @ loc))
_ (level w) _ (ghost_of_approx w))).
Definition upto_block (b: block) (w: rmap) : rmap :=  only_blocks (fun b' => plt b' b) w.
Definition beyond_block (b: block) (w: rmap) : rmap := only_blocks (not_dec (fun b' => plt b' b)) w.
Definition blockslice_rmap (S: block -> Prop) (phi: rmap) :=
forall loc: address, ~S (fst loc) -> identity (phi @ loc).
Definition eq_mod_blockslice (S: block -> Prop) (phi phi': rmap) :=
forall loc, (S (fst loc) -> phi @ loc = phi' @ loc) .
Definition blockslice_mpred (S: block -> Prop) (P: mpred) :=
(forall phi, P phi -> forall loc, ~S (fst loc) -> identity (phi @ loc)) /\
(forall phi phi', blockslice_rmap S phi -> blockslice_rmap S phi' ->
eq_mod_blockslice S phi phi' ->
P phi -> P phi').
Definition blockslice_mpred_rmap:
forall S (Sdec: forall b, {S b}+{~S b}) P phi,
blockslice_mpred S P -> P phi -> blockslice_rmap S phi.
Definition init_data2pred (d: init_data)  (sh: share) (a: val) (rho: environ) : mpred :=
match d with
| Init_int8 i => mapsto sh (Tint I8 Unsigned noattr) a (Vint (Int.zero_ext 8 i))
| Init_int16 i => mapsto sh (Tint I16 Unsigned noattr) a (Vint (Int.zero_ext 16 i))
| Init_int32 i => mapsto sh (Tint I32 Unsigned noattr) a (Vint i)
| Init_int64 i => mapsto sh (Tlong Unsigned noattr) a (Vlong i)
| Init_float32 r =>  mapsto sh (Tfloat F32 noattr) a (Vsingle r)
| Init_float64 r =>  mapsto sh (Tfloat F64 noattr) a (Vfloat r)
| Init_space n => mapsto_zeros n sh a
| Init_addrof symb ofs =>
match Map.get (ge_of rho) symb with
| Some b => mapsto sh (Tpointer Tvoid noattr) a (Vptr b ofs)
| _ => mapsto_ sh (Tpointer Tvoid noattr) a
end
end.
Fixpoint init_data_list2pred  (dl: list init_data)
(sh: share) (v: val)  : environ -> pred rmap :=
match dl with
| d::dl' =>
lift2 sepcon (init_data2pred d sh v)
(init_data_list2pred dl' sh (offset_val (init_data_size d) v))
| nil => lift0 emp
end.
Definition readonly2share (rdonly: bool) : share :=
if rdonly then Ers else Ews.
Definition globals_of_env (rho: environ) (i: ident) : val :=
match Map.get (ge_of rho) i with Some b => Vptr b Ptrofs.zero | None => Vundef end.
Definition globvar2pred (gv: ident->val) (idv: ident * globvar type) : assert :=
if (gvar_volatile (snd idv))
then  lift0 TT
else    init_data_list2pred (gvar_init (snd idv))
(readonly2share (gvar_readonly (snd idv))) (gv (fst idv)).
Definition globvars2pred (gv: ident->val) (vl: list (ident * globvar type)) : assert :=
(lift2 andp) (fun rho => prop (gv = globals_of_env rho))
(fold_right (lift2 sepcon) (lift0 emp) (map (globvar2pred gv) vl)).

Lemma writable_blocks_rev:
forall rho l, writable_blocks l rho = writable_blocks (rev l) rho.