Inductive match_freelists (j:meminj): list (block * Z * Z) -> list (block * Z * Z) -> Prop :=
  match_freelists_nil: match_freelists j nil nil
| match_freelists_cons: forall b1 lo1 hi1 t1 b2 lo2 hi2 t2 delta,
        j b1 = Some (b2,delta) ->
        lo2 = lo1+delta -> hi2 = hi1+delta ->
        match_freelists j t1 t2 ->
        match_freelists j ((b1,lo1,hi1)::t1) ((b2,lo2,hi2)::t2).Inductive match_freelists (j:meminj): list (block * Z * Z) -> list (block * Z * Z) -> Prop :=
  match_freelists_nil: match_freelists j nil nil
| match_freelists_cons: forall b1 lo1 hi1 t1 b2 lo2 hi2 t2 delta,
        j b1 = Some (b2,delta) ->
        lo2 = lo1+delta -> hi2 = hi1+delta ->
        match_freelists j t1 t2 ->
        match_freelists j ((b1,lo1,hi1)::t1) ((b2,lo2,hi2)::t2).Inductive match_freelists (j:meminj): list (block * Z * Z) -> list (block * Z * Z) -> Prop :=
  match_freelists_nil: match_freelists j nil nil
| match_freelists_cons: forall b1 lo1 hi1 t1 b2 lo2 hi2 t2 delta,
        j b1 = Some (b2,delta) ->
        lo2 = lo1+delta -> hi2 = hi1+delta ->
        match_freelists j t1 t2 ->
        match_freelists j ((b1,lo1,hi1)::t1) ((b2,lo2,hi2)::t2).

Lemma replace_externs_meminj_preserves_globals_as_inj: forall {F V} (ge: Genv.t F V) nu (WDnu: SM_wd nu) (PG: meminj_preserves_globals ge (as_inj nu) /\ (forall b, isGlobalBlock ge b = true -> frgnBlocksSrc nu b = true)) mu fSrc fTgt (Hyp: mu = replace_externs nu fSrc fTgt) (WDmu: SM_wd mu) (FRG: forall b, frgnBlocksSrc nu b = true -> fSrc b = true), meminj_preserves_globals ge (as_inj mu) /\ (forall b, isGlobalBlock ge b = true -> frgnBlocksSrc mu b = true).