(*Inserts the new injection entries into extern component, but not into foreign*)
Definition insert_as_extern (mu: SM_Injection) (j: meminj) (DomJ TgtJ:block->bool)
          : 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
      (fun b => orb (extBSrc b) (DomJ b))
      (fun b => orb (extBTgt b) (TgtJ b))
      fSrc
      fTgt
      (join extern (fun b => match local b with Some _ => None
                                              | None => j b end))
  end.Definition convertL (nu12: SM_Injection) (j12':meminj) FreshSrc FreshMid:=
  insert_as_extern nu12 j12' FreshSrc FreshMid.Definition convertR (nu23: SM_Injection) (j23':meminj) FreshMid FreshTgt:=
  insert_as_extern nu23 j23' FreshMid FreshTgt.

(* Specifications: *)
Lemma convertL_local: forall nu12 j12' FreshSrc FreshMid, local_of (convertL nu12 j12' FreshSrc FreshMid) = local_of nu12.
Lemma convertL_pub: forall nu12 j12' FreshSrc FreshMid, pub_of (convertL nu12 j12' FreshSrc FreshMid) = pub_of nu12.
Lemma convertL_priv: forall nu12 j12' FreshSrc FreshMid, priv_of (convertL nu12 j12' FreshSrc FreshMid) = priv_of nu12.
Lemma convertL_extern: forall nu12 j12' FreshSrc FreshMid, extern_of (convertL nu12 j12' FreshSrc FreshMid) = join (extern_of nu12) (fun b => match (local_of nu12) b with Some _ => None | None => j12' b end).
Lemma convertL_locBlocksSrc: forall nu12 j12' FreshSrc FreshMid, locBlocksSrc (convertL nu12 j12' FreshSrc FreshMid) = locBlocksSrc nu12.
Lemma convertL_locBlocksTgt: forall nu12 j12' FreshSrc FreshMid, locBlocksTgt (convertL nu12 j12' FreshSrc FreshMid) = locBlocksTgt nu12.
Lemma convertL_extBlocksSrc: forall nu12 j12' FreshSrc FreshMid, extBlocksSrc (convertL nu12 j12' FreshSrc FreshMid) = fun b => orb (extBlocksSrc nu12 b) (FreshSrc b).
Lemma convertL_extBlocksTgt: forall nu12 j12' FreshSrc FreshMid, extBlocksTgt (convertL nu12 j12' FreshSrc FreshMid) = fun b => orb (extBlocksTgt nu12 b) (FreshMid b).
Lemma convertL_DomSrc: forall nu12 j12' FreshSrc FreshMid, DomSrc (convertL nu12 j12' FreshSrc FreshMid) = (fun b => orb (DomSrc nu12 b) (FreshSrc b)).
Lemma convertL_DomTgt: forall nu12 j12' FreshSrc FreshMid, DomTgt (convertL nu12 j12' FreshSrc FreshMid) = (fun b => orb (DomTgt nu12 b) (FreshMid b)).
Lemma convertL_pubBlocksSrc: forall nu12 j12' FreshSrc FreshMid, pubBlocksSrc (convertL nu12 j12' FreshSrc FreshMid) = pubBlocksSrc nu12.
Lemma convertL_pubBlocksTgt: forall nu12 j12' FreshSrc FreshMid, pubBlocksTgt (convertL nu12 j12' FreshSrc FreshMid) = pubBlocksTgt nu12.
Lemma convertL_frgnBlocksSrc: forall nu12 j12' FreshSrc FreshMid, frgnBlocksSrc (convertL nu12 j12' FreshSrc FreshMid) = frgnBlocksSrc nu12.
Lemma convertL_frgnBlocksTgt: forall nu12 j12' FreshSrc FreshMid, frgnBlocksTgt (convertL nu12 j12' FreshSrc FreshMid) = frgnBlocksTgt nu12.
Lemma convertL_foreign: forall nu12 j12' FreshSrc FreshMid (WD12:SM_wd nu12), foreign_of (convertL nu12 j12' FreshSrc FreshMid) = foreign_of nu12.
Lemma convertR_local: forall nu23 j23' FreshMid FreshTgt, local_of (convertR nu23 j23' FreshMid FreshTgt) = local_of nu23.
Lemma convertR_pub: forall nu23 j23' FreshMid FreshTgt, pub_of (convertR nu23 j23' FreshMid FreshTgt) = pub_of nu23.
Lemma convertR_priv: forall nu23 j23' FreshMid FreshTgt, priv_of (convertR nu23 j23' FreshMid FreshTgt) = priv_of nu23.
Lemma convertR_extern: forall nu23 j23' FreshMid FreshTgt, extern_of (convertR nu23 j23' FreshMid FreshTgt) = join (extern_of nu23) (fun b => match (local_of nu23) b with Some _ => None | None => j23' b end).
Lemma convertR_foreign: forall nu23 j23' FreshMid FreshTgt (WD23:SM_wd nu23), foreign_of (convertR nu23 j23' FreshMid FreshTgt) = foreign_of nu23.
Lemma convertR_locBlocksSrc: forall nu23 j23' FreshMid FreshTgt, locBlocksSrc (convertR nu23 j23' FreshMid FreshTgt) = locBlocksSrc nu23.
Lemma convertR_locBlocksTgt: forall nu23 j23' FreshMid FreshTgt, locBlocksTgt (convertR nu23 j23' FreshMid FreshTgt) = locBlocksTgt nu23.
Lemma convertR_extBlocksSrc: forall nu23 j23' FreshMid FreshTgt, extBlocksSrc (convertR nu23 j23' FreshMid FreshTgt) = fun b => orb (extBlocksSrc nu23 b) (FreshMid b).
Lemma convertR_extBlocksTgt: forall nu23 j23' FreshMid FreshTgt, extBlocksTgt (convertR nu23 j23' FreshMid FreshTgt) = fun b => orb (extBlocksTgt nu23 b) (FreshTgt b).
Lemma convertR_DomSrc: forall nu23 j23' FreshMid FreshTgt, DomSrc (convertR nu23 j23' FreshMid FreshTgt) = (fun b => orb (DomSrc nu23 b) (FreshMid b)).
Lemma convertR_DomTgt: forall nu23 j23' FreshMid FreshTgt, DomTgt (convertR nu23 j23' FreshMid FreshTgt) = (fun b => orb (DomTgt nu23 b) (FreshTgt b)).
Lemma convertR_pubBlocksSrc: forall nu23 j23' FreshMid FreshTgt, pubBlocksSrc (convertR nu23 j23' FreshMid FreshTgt) = pubBlocksSrc nu23.
Lemma convertR_pubBlocksTgt: forall nu23 j23' FreshMid FreshTgt, pubBlocksTgt (convertR nu23 j23' FreshMid FreshTgt) = pubBlocksTgt nu23.
Lemma convertR_frgnBlocksSrc: forall nu23 j23' FreshMid FreshTgt, frgnBlocksSrc (convertR nu23 j23' FreshMid FreshTgt) = frgnBlocksSrc nu23.
Lemma convertR_frgnBlocksTgt: forall nu23 j23' FreshMid FreshTgt, frgnBlocksTgt (convertR nu23 j23' FreshMid FreshTgt) = frgnBlocksTgt nu23.