(***** All the additional conditions in the above auxiliary lemmas were needed for proving the condition Events.inject_separated j j' m tm in his lemma; otherwise, the claim is as before, just updated by replacing star step by corestep_star, as ususal*)

(* Specifications: *)
Theorem MS_match_callstack_function_entry:
forall fn cenv tf m e m' tm tm' sp f cs args targs le,
build_compilenv fn = (cenv, tf.(fn_stackspace)) ->
tf.(fn_stackspace) <= Int.max_unsigned ->
list_norepet (map fst (Csharpminor.fn_vars fn)) ->
list_norepet (Csharpminor.fn_params fn) ->
list_disjoint (Csharpminor.fn_params fn) (Csharpminor.fn_temps fn) ->
alloc_variables Csharpminor.empty_env m (Csharpminor.fn_vars fn) e m' ->
bind_parameters (Csharpminor.fn_params fn) args (create_undef_temps fn.(fn_temps)) = Some le ->
val_list_inject f args targs ->
Mem.alloc tm 0 tf.(fn_stackspace) = (tm', sp) ->
match_callstack prog f m tm cs (Mem.nextblock m) (Mem.nextblock tm) ->
Mem.inject f m tm ->
let te := set_locals (Csharpminor.fn_temps fn) (set_params targs (Csharpminor.fn_params fn)) in
exists f',
match_callstack prog f' m' tm'
(Frame cenv tf e le te sp (Mem.nextblock m) (Mem.nextblock m') :: cs)
(Mem.nextblock m') (Mem.nextblock tm')
/\ Mem.inject f' m' tm'
/\ (*LENB: this clause is new in Restructured Proof*) inject_incr f f'
/\ (*LENB this clause in new in coop-sim proof*) inject_separated f f' m tm.
Lemma MS_step_case_InternalCall:
forall cenv  f j m tm e cs k tk vargs targs x m1 lenv
(Param1: list_norepet (map fst (Csharpminor.fn_vars f)))
(Param2 : list_norepet (Csharpminor.fn_params f))
(Param3 : list_disjoint (Csharpminor.fn_params f) (fn_temps f))
(AlocVars : alloc_variables empty_env m (Csharpminor.fn_vars f) e m1)
(BindParams: bind_parameters (Csharpminor.fn_params f) vargs
(create_undef_temps (fn_temps f)) = Some lenv)
(MINJ : Mem.inject j m tm)
(MCS : match_callstack prog j m tm cs (Mem.nextblock m) (Mem.nextblock tm))
(MK : match_cont k tk cenv nil cs)
(ISCC : Csharpminor.is_call_cont k)
(ARGSINJ : val_list_inject j vargs targs)
(EQ : transl_function f = OK x)
(*NEW:*) (PG: meminj_preserves_globals ge j), exists (c2' : CMin_core) (m2' : mem), corestep_plus CMin_core_sem tge (CMin_Callstate (AST.Internal x) targs tk) tm c2' m2' /\ exists (j' : meminj), inject_incr j j' /\ inject_separated j j' m tm /\ match_cores (CSharpMin_State f (Csharpminor.fn_body f) k e lenv) j' (CSharpMin_State f (Csharpminor.fn_body f) k e lenv) m1 c2' m2'.  (******************End of updated section for internal call rule*****************************)
(************************************************************************************)
Lemma MS_step_case_Return:
forall j m tm cs f e lenv k tk cenv v tv optid
(MINJ : Mem.inject j m tm)
(MCS : match_callstack prog j m tm cs (Mem.nextblock m) (Mem.nextblock tm))
(MK : match_cont (Csharpminor.Kcall optid f e lenv k) tk cenv nil cs)
(RESINJ : val_inject j v tv)
(*NEW:*) (PG: meminj_preserves_globals ge j), exists c2' : CMin_core, exists m2' : mem, corestep_plus CMin_core_sem tge (CMin_Returnstate tv tk) tm c2' m2'  /\ match_cores  (CSharpMin_State f Csharpminor.Sskip k e (set_optvar optid v lenv)) j (CSharpMin_State f Csharpminor.Sskip k e (set_optvar optid v lenv)) m c2' m2' .  Lemma MS_step: forall (c1 : core_data) (m1 : mem) (c1' : core_data) (m1' : mem), corestep CSharpMin_core_sem ge c1 m1 c1' m1' -> forall (c2 : CMin_core) (m2 : mem) (j : meminj), match_cores c1 j c1 m1 c2 m2 -> (exists c2' : CMin_core, exists m2' : mem, exists j' : meminj, inject_incr j j' /\ Events.inject_separated j j' m1 m2 /\ corestep_plus CMin_core_sem tge c2 m2 c2' m2' /\ match_cores c1' j' c1' m1' c2' m2') \/ (MC_measure c1' < MC_measure c1)%nat /\ match_cores c1' j c1' m1' c2 m2.  Require Import sepcomp.forward_simulations.  Require Import sepcomp.forward_simulations_lemmas.  (*program structure not yet updated to module*)
Theorem transl_program_correct:
forall (R: list_norepet (map fst (prog_defs prog)))
entrypoints
(entry_points_ok :
forall v1 v2 sig,
In (v1, v2, sig) entrypoints ->
exists b f1 f2,
v1 = Vptr b Int.zero
/\ v2 = Vptr b Int.zero
/\ Genv.find_funct_ptr ge b = Some f1
/\ Genv.find_funct_ptr tge b = Some f2)
(init_mem: exists m0, Genv.init_mem prog = Some m0),
Forward_simulation_inj.Forward_simulation_inject
CSharpMin_core_sem
CMin_core_sem ge tge entrypoints.
Lemma MS_step_coopsem: forall (c1 : core_data) (m1 : mem) (c1' : core_data) (m1' : mem),
corestep csharpmin_coop_sem ge c1 m1 c1' m1' ->
forall (c2 : CMin_core) (m2 : mem) (j : meminj),
match_cores c1 j c1 m1 c2 m2 ->
(exists c2' : CMin_core,
exists m2' : mem,
exists j' : meminj,
inject_incr j j' /\
Events.inject_separated j j' m1 m2 /\
corestep_plus cmin_coop_sem tge c2 m2 c2' m2' /\
match_cores c1' j' c1' m1' c2' m2') \/
(MC_measure c1' < MC_measure c1)%nat /\ match_cores c1' j c1' m1' c2 m2.
Theorem transl_program_correct_coopsem:
forall (R: list_norepet (map fst (prog_defs prog)))
entrypoints
(entry_points_ok :
forall v1 v2 sig,
In (v1, v2, sig) entrypoints ->
exists b f1 f2,
v1 = Vptr b Int.zero
/\ v2 = Vptr b Int.zero
/\ Genv.find_funct_ptr ge b = Some f1
/\ Genv.find_funct_ptr tge b = Some f2)
(init_mem: exists m0, Genv.init_mem prog = Some m0),
Forward_simulation_inj.Forward_simulation_inject csharpmin_coop_sem
cmin_coop_sem ge tge entrypoints.