Definition mem_respects_readonly {F V} (ge : Genv.t F V) m :=
forall b gv, Genv.find_var_info ge b = Some gv ->
gvar_readonly gv && negb (gvar_volatile gv) = true ->
Genv.load_store_init_data ge m b 0 (gvar_init gv) /\
Mem.valid_block m b /\ (forall ofs : Z, ~ Mem.perm m b ofs Max Writable).

(* Specifications: *)
Lemma mem_respects_readonly_fwd {F V} (g : Genv.t F V) m m'
(MRR: mem_respects_readonly g m)
(FWD: mem_forward m m')
(RDO: forall b, Mem.valid_block m b -> readonly m b m'):
mem_respects_readonly g m'.
Lemma mem_respects_readonly_forward {F V} (ge : Genv.t F V) m m'
(MRR: mem_respects_readonly ge m)
(FWD: mem_forward m m')
(RDO: forall b gv, Genv.find_var_info ge b = Some gv ->
gvar_readonly gv && negb (gvar_volatile gv) = true -> readonly m b m'):
mem_respects_readonly ge m'.
Lemma mem_respects_readonly_forward' {F V} (ge : Genv.t F V) m m'
(MRR: mem_respects_readonly ge m)
(FWD: mem_forward m m')
(RDO: RDOnly_fwd m m' (ReadOnlyBlocks ge)):
mem_respects_readonly ge m'.
(*The following 2 lemmas are from Cminorgenproof.v*)
Lemma nextblock_storev:
forall chunk m addr v m',
Mem.storev chunk m addr v = Some m' -> Mem.nextblock m' = Mem.nextblock m.
Lemma nextblock_freelist:
forall fbl m m',
Mem.free_list m fbl = Some m' ->
Mem.nextblock m' = Mem.nextblock m.
Lemma perm_freelist:
forall fbl m m' b ofs k p,
Mem.free_list m fbl = Some m' ->
Mem.perm m' b ofs k p ->
Mem.perm m b ofs k p.
Lemma get_freelist:
forall fbl m m' (FL: Mem.free_list m fbl = Some m') b
(H: forall b' lo hi, In (b', lo, hi) fbl -> b' <> b) z,
ZMap.get z (Mem.mem_contents m') !! b =
ZMap.get z (Mem.mem_contents m) !! b.
Lemma free_contents:
forall m b lo hi m' b' ofs,
Mem.free m b lo hi = Some m' ->
~adr_range (b,lo) (hi-lo) (b',ofs) ->
ZMap.get ofs (PMap.get b' (Mem.mem_contents m)) =
ZMap.get ofs (PMap.get b' (Mem.mem_contents m')).