Definition mkII
(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_II_existsT NB2' Hyp1 Hyp2) as [AM [ADefault PAM]].
destruct (ContentsMap_II_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_II_FUN.
destruct (plt b (Mem.nextblock m2)).
(*valid_block m2 b*)
destruct (j23 b).
destruct p0.
remember (source j12 m1 b ofs) as src.
destruct src.
destruct p0. apply m1'.
apply m2.
apply m2.
(*invalid_block m2 b*)
remember (source j12' m1' b ofs) as src.
destruct src.
destruct p. apply m1'.
reflexivity.
(*nextblock_noaccess*)
intros. rewrite PAM.
unfold AccessMap_II_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_II_FUN.
destruct (plt b NB2').
remember (CM_block_II_existsT b).
destruct s. apply a.
reflexivity.
Defined.
End MEMORY_CONSTRUCTION_II.
Definition minmax_at (m:mem) (j:meminj) (b2 b1: block) : option(Z * Z) :=
match j b1
with Some (b,delta) =>
if peq b b2
then match (zmap_finite_c _ (PMap.get b1 m.(Mem.mem_contents)))
with (mn,mx) => Some(mn+delta,mx+delta)
end
else None
| None => None
end.

Lemma minmax_at_sound2: forall m j b2 b1,
None = minmax_at m j b2 b1 ->
forall delta, j b1 = Some(b2,delta) ->
forall z,
ZMap.get z (Mem.mem_contents m) !! b1 = Undef.