Definition replace_externs (mu:SM_Injection) fSrc' fTgt': SM_Injection :=
match mu with
Build_SM_Injection locBSrc locBTgt pSrc pTgt local extBSrc extBTgt fSrc fTgt extern =>
Build_SM_Injection locBSrc locBTgt pSrc pTgt local extBSrc extBTgt fSrc' fTgt' extern
end.
(*typically, we have forall b, fSrc b -> fSrc' b and forall b, fTgt b -> fTgt' b, i.e. only reclassify unknown entries as foreign*)

Lemma replace_externs_wd: forall mu (WD: SM_wd mu) fSrc' fTgt'
(SRC: forall b1, fSrc' b1 = true ->
exists b2 d, extern_of mu b1 = Some(b2,d) /\ fTgt' b2=true)
(TGT: forall b, fTgt' b = true -> extBlocksTgt mu b = true),
SM_wd (replace_externs mu fSrc' fTgt').