Definition AccessMap_II_Property  (j12 j23 j12' :meminj) (m1 m1' m2 : mem)
(AM:ZMap.t (Z -> perm_kind -> option permission)):Prop :=
forall b2,
(Mem.valid_block m2 b2 -> forall k ofs2,
match j23 b2 with
None => PMap.get b2 AM ofs2 k  = PMap.get b2 m2.(Mem.mem_access) ofs2 k
| Some (b3,d3) =>
match source j12 m1 b2 ofs2 with
Some(b1,ofs1) =>  PMap.get b2 AM ofs2 k =
PMap.get b1 m1'.(Mem.mem_access) ofs1 k
| None =>  PMap.get b2 AM ofs2 k =
PMap.get b2 m2.(Mem.mem_access) ofs2 k
end
end)
/\ (~ Mem.valid_block m2 b2 -> forall k ofs2,
match source j12' m1' b2 ofs2 with
Some(b1,ofs1) => PMap.get b2 AM ofs2 k =
PMap.get b1 m1'.(Mem.mem_access) ofs1 k
| None =>  PMap.get b2 AM ofs2 k = None
end).
Definition Content_II_Property (j12 j12' j23':meminj) (m1 m1' m2:Mem.mem)
(CM:ZMap.t (ZMap.t memval)):=
forall b2,
(Mem.valid_block m2 b2 -> forall ofs2,
match source j12 m1 b2 ofs2 with
Some(b1,ofs1) =>
match j23' b2 with
None => ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m2.(Mem.mem_contents))
| Some(b3,ofs3) =>
ZMap.get ofs2 (PMap.get b2 CM) =
inject_memval j12'
(ZMap.get ofs1 (PMap.get b1 m1'.(Mem.mem_contents)))
end
| None => ZMap.get ofs2 (PMap.get b2 CM) =
ZMap.get ofs2 (PMap.get b2 m2.(Mem.mem_contents))
end)
/\ (~ Mem.valid_block m2 b2 -> forall ofs2,
match source j12' m1' b2 ofs2 with
None => ZMap.get ofs2 (PMap.get b2 CM) =Undef
| Some(b1,ofs1) =>
ZMap.get ofs2 (PMap.get b2 CM) =
inject_memval j12'
(ZMap.get ofs1 (PMap.get b1 m1'.(Mem.mem_contents)))
end)
/\ fst CM !! b2 = Undef.

(* Specifications: *)
Lemma add_no_neutral2: forall (p q:positive), (p <> p + q)%positive.
Lemma cont_split: forall m b (A B Q: Prop)
(SPLIT: (Mem.valid_block m b  -> A) /\ (~Mem.valid_block m b -> B) /\ Q)
(P:Prop)
(HA: Mem.valid_block m b -> A -> Q -> P)
(HB: ~Mem.valid_block m b -> B -> Q -> P), P.
Lemma II_ok: forall m1 m2 j12 (MInj12 : Mem.inject j12 m1 m2) m1'
(Fwd1: mem_forward m1 m1') j23 m3
(MInj23 : Mem.inject j23 m2 m3) m3'
(Fwd3: mem_forward m3 m3')
j' (MInj13': Mem.inject j' m1' m3')
(InjIncr: inject_incr (compose_meminj j12 j23) j')
(InjSep: inject_separated (compose_meminj j12 j23) j' m1 m3)
(Unch11': Mem.unchanged_on
(loc_unmapped (compose_meminj j12 j23)) m1 m1')
(Unch33': Mem.unchanged_on
(loc_out_of_reach (compose_meminj j12 j23) m1) m3 m3')
prej12' j23' n1' n2'
(HeqMKI: mkInjections m1 m1' m2 j12 j23 j' =
(prej12', j23', n1', n2'))
j12' (Hj12': j12'= removeUndefs j12 j' prej12')
m2'
(NB: m2'.(Mem.nextblock)=n2')
(CONT:  Content_II_Property j12 j12' j23' m1 m1' m2
(m2'.(Mem.mem_contents)))
(ACCESS: AccessMap_II_Property j12 j23 j12' m1 m1' m2
(m2'.(Mem.mem_access))),
j'=compose_meminj j12' j23' /\
inject_incr j12 j12' /\ inject_incr j23 j23' /\
Mem.inject j12' m1' m2' /\ mem_forward m2 m2' /\
Mem.inject j23' m2' m3' /\
Mem.unchanged_on (loc_out_of_reach j12 m1) m2 m2' /\
inject_separated j12 j12' m1 m2 /\
inject_separated j23 j23' m2 m3 /\
Mem.unchanged_on (loc_unmapped j23) m2 m2' /\
Mem.unchanged_on (loc_out_of_reach j23 m2) m3 m3'.
Lemma add_no_neutral2: forall (p q:positive), (p <> p + q)%positive.
Lemma cont_split: forall m b (A B Q: Prop)
(SPLIT: (Mem.valid_block m b  -> A) /\ (~Mem.valid_block m b -> B) /\ Q)
(P:Prop)
(HA: Mem.valid_block m b -> A -> Q -> P)
(HB: ~Mem.valid_block m b -> B -> Q -> P), P.
Lemma II_ok: forall m1 m2 j12 (MInj12 : Mem.inject j12 m1 m2) m1'
(Fwd1: mem_forward m1 m1') j23 m3
(MInj23 : Mem.inject j23 m2 m3) m3'
(Fwd3: mem_forward m3 m3')
j' (MInj13': Mem.inject j' m1' m3')
(InjIncr: inject_incr (compose_meminj j12 j23) j')
(InjSep: inject_separated (compose_meminj j12 j23) j' m1 m3)
(Unch11': Mem.unchanged_on
(loc_unmapped (compose_meminj j12 j23)) m1 m1')
(Unch33': Mem.unchanged_on
(loc_out_of_reach (compose_meminj j12 j23) m1) m3 m3')
prej12' j23' n1' n2'
(HeqMKI: mkInjections m1 m1' m2 j12 j23 j' =
(prej12', j23', n1', n2'))
j12' (Hj12': j12'= removeUndefs j12 j' prej12')
m2'
(NB: m2'.(Mem.nextblock)=n2')
(CONT:  Content_II_Property j12 j12' j23' m1 m1' m2
(m2'.(Mem.mem_contents)))
(ACCESS: AccessMap_II_Property j12 j23 j12' m1 m1' m2
(m2'.(Mem.mem_access))),
j'=compose_meminj j12' j23' /\
inject_incr j12 j12' /\ inject_incr j23 j23' /\
Mem.inject j12' m1' m2' /\ mem_forward m2 m2' /\
Mem.inject j23' m2' m3' /\
Mem.unchanged_on (loc_out_of_reach j12 m1) m2 m2' /\
inject_separated j12 j12' m1 m2 /\
inject_separated j23 j23' m2 m3 /\
Mem.unchanged_on (loc_unmapped j23) m2 m2' /\
Mem.unchanged_on (loc_out_of_reach j23 m2) m3 m3'.