Definition mkEFF
(NB2':block)
(Hyp1: (Mem.nextblock m2 <= NB2')%positive)
(Hyp2: forall (b1 b2 : block) (delta : Z),
j12' b1 = Some (b2, delta) -> (b2 < NB2')%positive)
: Mem.mem'.
destruct (mkAccessMap_EFF_existsT NB2' Hyp1 Hyp2) as [AM [ADefault PAM]].
destruct (ContentsMap_EFF_existsT NB2') as [CM [CDefault PCM]].
eapply Mem.mkmem with (nextblock:=NB2')
(mem_access:=AM)
(mem_contents:=CM).
(*access_max*)
intros. rewrite PAM. unfold AccessMap_EFF_FUN.
destruct (plt b (Mem.nextblock m2)).
(*valid_block m2 b*)
destruct (locBlocksSrc nu23 b).
destruct (pubBlocksSrc nu23 b).
destruct (source (local_of nu12) m1 b ofs).
destruct p0.
destruct (pubBlocksSrc nu12 b0). apply m1'. apply m2.
apply m2.
apply m2.
destruct (source (as_inj nu12) m1 b ofs).
destruct p0. apply m1'.
destruct (j23 b). destruct p0. reflexivity. apply m2.
(*invalid_block m2 b*)
destruct (source j12' m1' b ofs).
destruct p. apply m1'.
reflexivity.
(*nextblock_noaccess*)
intros. rewrite PAM.
unfold AccessMap_EFF_FUN.
destruct (plt b (Mem.nextblock m2)).
exfalso. apply H; clear - Hyp1 p. xomega.
remember (source j12' m1' b ofs) as src.
destruct src; trivial.
destruct p.
exfalso. apply H. clear - Heqsrc Hyp2.
apply source_SomeE in Heqsrc.
destruct Heqsrc as [b1 [delta [ofs1
[PBO [Bounds [J1 [P1 Off2]]]]]]]; subst.
apply (Hyp2 _ _ _ J1).
(*contents_default*)
intros.
rewrite PCM; clear PCM.
unfold ContentsMap_EFF_FUN.
destruct (plt b NB2').
remember (CM_block_EFF_existsT b).
destruct s. apply a.
reflexivity.
Defined.

Lemma mkEff_nextblock: forall N Hyp1 Hyp2,
Mem.nextblock (mkEFF N Hyp1 Hyp2) = N.