Definition local_out_of_reach mu (m : mem) (b : block) (ofs : Z): Prop :=
locBlocksTgt mu b = true /\
forall b0 delta, local_of mu b0 = Some (b, delta) ->
(~ Mem.perm m b0 (ofs - delta) Max Nonempty \/
pubBlocksSrc mu b0 = false).

(*Proof the match_genv is preserved by callsteps*)
Lemma after_external_meminj_preserves_globals:
forall {F V} (ge: Genv.t F V) mu (WDmu : SM_wd mu)
(PG: meminj_preserves_globals ge (extern_of mu) /\
(forall b, isGlobalBlock ge b = true -> frgnBlocksSrc mu b = true))
nu pubSrc' pubTgt' vals1 m1
(pubSrcHyp: pubSrc' = fun b => andb (locBlocksSrc mu b)
(REACH m1 (exportedSrc mu vals1) b))
(Hnu: nu = replace_locals mu pubSrc' pubTgt')
nu' (WDnu' : SM_wd nu') (INC: extern_incr nu nu')
m2 (SMV: sm_valid mu m1 m2) (SEP: sm_inject_separated nu nu' m1 m2)
frgnSrc' ret1 m1'
(frgnSrcHyp: frgnSrc' = fun b => andb (DomSrc nu' b)
(andb (negb (locBlocksSrc nu' b))
(REACH m1' (exportedSrc nu' (ret1::nil)) b)))
frgnTgt' ret2 m2'
(frgnTgtHyp: frgnTgt' = fun b => andb (DomTgt nu' b)
(andb (negb (locBlocksTgt nu' b))
(REACH m2' (exportedTgt nu' (ret2::nil)) b)))
mu' (Mu'Hyp: mu' = replace_externs nu' frgnSrc' frgnTgt'),
meminj_preserves_globals ge (extern_of mu') /\
(forall b, isGlobalBlock ge b = true -> frgnBlocksSrc mu' b = true).