Definition AccessMap_EE_Property  (m1 m1' m2:Mem.mem)
(AM:ZMap.t (Z -> perm_kind -> option permission)):Prop :=
forall b,
(Mem.valid_block m2 b -> forall k ofs,
(Mem.perm m1 b ofs Max Nonempty ->
PMap.get b AM ofs k = PMap.get b m1'.(Mem.mem_access) ofs k) /\
(~Mem.perm m1 b ofs Max Nonempty ->
PMap.get b AM ofs k = PMap.get b m2.(Mem.mem_access) ofs k))
/\ (~ Mem.valid_block m2 b -> forall k ofs,
PMap.get b AM ofs k = PMap.get b m1'.(Mem.mem_access) ofs k).
Definition Content_EE_Property
(m1 m1' m2:Mem.mem) (CM:ZMap.t (ZMap.t memval)):=
forall b,
(Mem.valid_block m2 b -> forall ofs,
(Mem.perm m1 b ofs Max Nonempty ->
ZMap.get ofs (PMap.get b CM) =
ZMap.get ofs (PMap.get b m1'.(Mem.mem_contents))) /\
(~Mem.perm m1 b ofs Max Nonempty ->
ZMap.get ofs (PMap.get b CM) =
ZMap.get ofs (PMap.get b m2.(Mem.mem_contents))))
/\ (~ Mem.valid_block m2 b -> forall (HM1': Mem.valid_block m1' b) ofs,
ZMap.get ofs (PMap.get b CM) =
ZMap.get ofs (PMap.get b m1'.(Mem.mem_contents)))
/\ fst CM !! b = Undef.
Definition AccessMap_EE_FUN'  (m1 m1' m2:Mem.mem) (b:block):
Z -> perm_kind -> option permission :=
if plt b (Mem.nextblock m1')
then
if plt b (Mem.nextblock m2)
then (fun ofs k =>
if Mem.perm_dec m1 b ofs Max Nonempty
then PMap.get b m1'.(Mem.mem_access) ofs k
else PMap.get b m2.(Mem.mem_access) ofs k)
else PMap.get b m1'.(Mem.mem_access)
else (fun ofs k => None).
Definition AccessMap_EE_FUN  (m1 m1' m2:Mem.mem) (b:block):
Z -> perm_kind -> option permission :=
if plt b (Mem.nextblock m2)
then (fun ofs k =>
if Mem.perm_dec m1 b ofs Max Nonempty
then PMap.get b m1'.(Mem.mem_access) ofs k
else PMap.get b m2.(Mem.mem_access) ofs k)
else PMap.get b m1'.(Mem.mem_access).
Definition ContentMap_EE_ValidBlock_FUN m1 m1' m2 b ofs: memval :=
if Mem.perm_dec m1 b ofs Max Nonempty
then ZMap.get ofs (PMap.get b m1'.(Mem.mem_contents))
else ZMap.get ofs (PMap.get b m2.(Mem.mem_contents)).
Definition ContentMap_EE_InvalidBlock_FUN m1' b ofs: memval:=
ZMap.get ofs (PMap.get b m1'.(Mem.mem_contents)).
Definition ContentMap_EE_Block_FUN m1 m1' m2 b ofs : memval:=
if plt b (Mem.nextblock m2)
then ContentMap_EE_ValidBlock_FUN m1 m1' m2 b ofs
else ContentMap_EE_InvalidBlock_FUN m1' b ofs.
Definition ContentsMap_EE_FUN  (m1 m1' m2:Mem.mem) (b:block):
ZMap.t memval.
destruct (plt b (Mem.nextblock m1')).
apply(CM_block_EE_existsT m1 m1' m2 b).
apply (ZMap.init Undef).
Defined.

Lemma ContentsMap_EE_existsT: forall (m1 m1' m2:Mem.mem),
{ M : PMap.t (ZMap.t memval) |
fst M = ZMap.init Undef /\
forall b, PMap.get b M = ContentsMap_EE_FUN m1 m1' m2 b}.