End InternalCall.
Section CORESTEPS.
Variable cenv : compilenv.
Variable sz : Z.
Variable f : Csharpminor.function.
Variable tfn : function.
Variable mu : SM_Injection.
Variable m tm : mem.
Variable e : Csharpminor.env.
Variable lenv : temp_env.
Variable te : env.
Variable sp lo hi: Values.block.
Variable cs : callstack.
Variable s : Csharpminor.stmt.
Variable k : Csharpminor.cont.
Variable tk : cont.
Variable xenv : exit_env.
Variable PRE: REACH_closed m (vis mu) /\
meminj_preserves_globals ge (as_inj mu) /\
(forall b, isGlobalBlock ge b = true -> frgnBlocksSrc mu b = true) /\
sm_valid mu m tm /\ SM_wd mu /\
Mem.inject (as_inj mu) m tm.
Variable TRF : transl_funbody cenv sz f = OK tfn.

(* Specifications: *)
Lemma MS_step_case_SkipSeq: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
(MK : match_cont (Csharpminor.Kseq s k) tk cenv xenv cs),
exists st2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge
(CMin_State tfn Sskip tk (Vptr sp Int.zero) te) tm st2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m m2' /\
Match_cores (CSharpMin_State f s k e lenv) mu'
(CSharpMin_State f s k e lenv) m st2' m2' /\
SM_wd mu' /\ sm_valid mu' m m2'.
Lemma MS_step_case_SkipBlock: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
(MK : match_cont (Csharpminor.Kblock k) tk cenv xenv cs),
exists st2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge (CMin_State tfn Sskip tk (Vptr sp Int.zero) te) tm st2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m m2' /\
Match_cores (CSharpMin_State f Csharpminor.Sskip k e lenv) mu' (CSharpMin_State f Csharpminor.Sskip k e lenv) m st2' m2' /\
SM_wd mu' /\
sm_valid mu' m m2'.
Lemma MS_match_is_call_cont: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
v (MK: match_cont k tk cenv xenv cs)
(CC: Csharpminor.is_call_cont k),
exists tk',
corestep_star CMin_core_sem tge (CMin_State tfn Sskip tk v te) tm
(CMin_State tfn Sskip tk' v te) tm
/\ is_call_cont tk'
/\ match_cont k tk' cenv nil cs.
Lemma MS_step_case_SkipCall:forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm)) m'
(CC: Csharpminor.is_call_cont k)
(FL: Mem.free_list m (blocks_of_env e) = Some m')
(MK : match_cont k tk cenv xenv cs),
exists st2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge (CMin_State  tfn Sskip tk (Vptr sp Int.zero) te) tm st2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m' m2' /\
Match_cores (CSharpMin_Returnstate Vundef k) mu' (CSharpMin_Returnstate Vundef k) m' st2' m2' /\
SM_wd mu' /\
sm_valid mu' m' m2'.
Lemma MS_step_case_Assign: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
a v id x x0
(EE: Csharpminor.eval_expr ge e lenv m a v)
(MK : match_cont k tk cenv xenv cs)
(EQ : transl_expr cenv a = OK (x, x0)),
exists st2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge (CMin_State tfn (Sassign id x) tk (Vptr sp Int.zero) te) tm st2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m m2' /\
Match_cores (CSharpMin_State f Csharpminor.Sskip k e (PTree.set id v lenv))
mu' (CSharpMin_State f Csharpminor.Sskip k e (PTree.set id v lenv)) m st2' m2' /\
SM_wd mu' /\
sm_valid mu' m m2'.
Lemma MS_step_case_Store: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
x x0 x1 x2 chunk m' a addr vaddr v
(CH: Mem.storev chunk m vaddr v = Some m')
(MK : match_cont k tk cenv xenv cs)
(EvAddr : Csharpminor.eval_expr ge e lenv m addr vaddr)
(EvA : Csharpminor.eval_expr ge e lenv m a v)
(EQ : transl_expr cenv addr = OK (x, x0))
(EQ1 : transl_expr cenv a = OK (x1, x2)),
exists st2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge (CMin_State tfn (make_store chunk x x1) tk (Vptr sp Int.zero) te) tm st2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m' m2' /\
Match_cores (CSharpMin_State f Csharpminor.Sskip k e lenv)
mu' (CSharpMin_State f Csharpminor.Sskip k e lenv) m' st2' m2' /\
SM_wd mu' /\
sm_valid mu' m' m2'.
Lemma MS_step_case_Call: forall
(MCS : structured_match_callstack mu m tm
(Frame cenv tfn e lenv te sp lo hi :: cs)
(Mem.nextblock m)
(Mem.nextblock tm))
x x0 x1 a vf fd optid vargs bl
(MK : match_cont k tk cenv xenv cs)
(EvalA: Csharpminor.eval_expr ge e lenv m a vf)
(EvalBL: Csharpminor.eval_exprlist ge e lenv m bl vargs)
(FF: Genv.find_funct ge vf = Some fd)
(EQ : transl_expr cenv a = OK (x, x0))
(EQ1 : transl_exprlist cenv bl = OK x1),
exists c2' : CMin_core,
exists m2' mu',
corestep_plus CMin_core_sem tge
(CMin_State  tfn (Scall optid (Csharpminor.funsig fd) x x1) tk (Vptr sp Int.zero) te) tm c2' m2'
/\ intern_incr mu mu' /\
sm_inject_separated mu mu' m tm /\
sm_locally_allocated mu mu' m tm m m2' /\
Match_cores (CSharpMin_Callstate fd vargs (Csharpminor.Kcall optid f e lenv k)) mu'
(CSharpMin_Callstate fd vargs (Csharpminor.Kcall optid f e lenv k)) m c2' m2' /\
SM_wd mu' /\
sm_valid mu' m m2'.
Lemma Builtin_mem_inject:
forall vargs m1 t vres m2 f m1' vargs',
meminj_preserves_globals ge (restrict (as_inj mu) (vis mu)) ->
csharpmin_eff_sem vargs m1 t vres m2 ->
Mem.inject (restrict (as_inj mu) (vis mu)) m1 m1' ->
val_list_inject (restrict (as_inj mu) (vis mu)) vargs vargs' ->
exists mu', exists vres', exists m2',
cmin_eff_sem tge vargs' m1' t vres' m2'
/\ val_inject (restrict (as_inj mu') (vis mu')) vres vres'
/\ Mem.inject (restrict (as_inj mu') (vis mu')) m2 m2'
/\ Mem.unchanged_on (loc_unmapped (as_inj mu)) m1 m2
/\ Mem.unchanged_on (local_out_of_reach (as_inj mu) m1) m1' m2'
/\ intern_incr mu mu'
/\ sm_inject_separated mu mu' m1 m1'
/\ sm_locally_allocated mu mu' m1 m1' m2 m2' .