Definition marshal j m args tm targs :=
  Build_SM_Injection
  (fun _ => false) (fun _ => false)
  (fun _ => false) (fun _ => false)
  (fun _ => None)
  (DomSrc j)
  (DomTgt j)
  (REACH m (getBlocks args))
  (REACH tm (getBlocks targs))
  (as_inj j).

(* Specifications: *)
Lemma as_inj_marshal j m args tm targs : as_inj (marshal j m args tm targs) = as_inj j.
Lemma foreign_of_marshal j m args tm targs : foreign_of (marshal j m args tm targs) = restrict (as_inj j) (REACH m (getBlocks args)).
Lemma DomSrc_marshal j m args tm targs : DomSrc (marshal j m args tm targs) = DomSrc j.
Lemma DomTgt_marshal j m args tm targs : DomTgt (marshal j m args tm targs) = DomTgt j.
Lemma locBlocksTgt_marshal j m args tm targs : locBlocksTgt (marshal j m args tm targs) = (fun _ => false).
Lemma vis_marshal j m args tm targs : vis (marshal j m args tm targs) = REACH m (getBlocks args).
Lemma injsep_marshal j j' m args tm targs m1 m2 : sm_inject_separated j (marshal j' m args tm targs) m1 m2 -> sm_inject_separated j j' m1 m2.
Lemma injsep_marshal' j j' m args tm targs m1 m2 : sm_inject_separated (marshal j m args tm targs) j' m1 m2 -> sm_inject_separated j j' m1 m2.
Lemma restrict_as_inj_eq j j' m1 m2 : SM_wd j -> SM_wd j' -> inject_incr (as_inj j) (as_inj j') -> sm_inject_separated j j' m1 m2 -> sm_valid j m1 m2 -> restrict (as_inj j') (DomSrc j) = as_inj j.
Lemma reach_in_exported_src b m args j : REACH m (getBlocks args) b=true -> REACH m (exportedSrc j args) b=true.
Lemma reach_in_exported_tgt {b m args} j : REACH m (getBlocks args) b=true -> REACH m (exportedTgt j args) b=true.
Lemma extern_semantics_preservation c c' d m m' tm cd j ef sig args : trace_match_state cd j c m d tm -> corestep tr_source geS c m c' m' -> at_external source (snd c) = Some (ef, sig, args) -> exists cd' j' d' tm', corestep tr_target geT d tm d' tm' /\ trace_match_state cd' j' c' m' d' tm'.
Lemma safe_match_target_step cd j c m d tm z tr : (forall n, safeN tr_source geS n (z,tr,c) m) -> match_state cd j c m d tm -> ~TraceSemantics.yielded target d -> exists c' m' d' tm' n tn, corestepN source geS n c m c' m' /\ corestepN target geT (S tn) d tm d' tm' /\ exists cd' j', match_state cd' j' c' m' d' tm'.
Lemma safe_match_target_atext cd j c m d tm z tr ef sig args : (forall n, safeN tr_source geS n (z,tr,c) m) -> match_state cd j c m d tm -> at_external target d = Some (ef, sig, args) -> exists c' m' n, corestepN source geS n c m c' m' /\ TraceSemantics.yielded source c' /\ exists cd' j', match_state cd' j' c' m' d tm.
Lemma trace_refinement z z' c d d' m tm tm' tr0 ttr0 ttr cd j tn : match_state cd j c m d tm -> match_trace tr0 ttr0 -> (forall n, safeN tr_source geS n (z,tr0,c) m) -> corestepN tr_target geT tn (z,ttr0,d) tm (z',ttr,d') tm' -> exists z'' c' m' tr n, corestepN tr_source geS n (z,tr0,c) m (z'',tr,c') m' /\ match_trace tr ttr.