(*CompCert imports*)
(* This file provides a series of interfaces to [forward_simulations.v] *)
Section Sim_EQ_SIMU_DIAGRAMS.
Context {M F1 V1 C1 M2 F2 V2 C2:Type}
{Sem1 : CoreSemantics (Genv.t F1 V1) C1 M}
{Sem2 : CoreSemantics (Genv.t F2 V2) C2 M}
{ge1:Genv.t F1 V1}
{ge2:Genv.t F2 V2}
{entry_points : list (val * val * signature)}.
Let core_data := C1.
Variable match_cores: core_data -> C1 -> C2 -> Prop.
Hypothesis genvs_dom_eq: genvs_domain_eq ge1 ge2.
Hypothesis match_initial_cores:
forall v1 v2 sig, In (v1,v2,sig) entry_points ->
forall vals,
exists c1 : C1, exists c2 : C2,
initial_core Sem1 ge1 v1 vals = Some c1 /\
initial_core Sem2 ge2 v2 vals = Some c2 /\ match_cores c1 c1 c2.
Hypothesis eq_halted:
forall (cd : core_data) (c1 : C1) (c2 : C2) v ,
match_cores cd c1 c2 ->
halted Sem1 c1 = Some v -> halted Sem2 c2 = Some v.
Hypothesis eq_at_external:
forall (d : C1) (st1 : core_data) (st2 : C2) (e : external_function)
(args : list val) (ef_sig : signature),
(d = st1 /\ match_cores d st1 st2) ->
at_external Sem1 st1 = Some (e, ef_sig, args) ->
at_external Sem2 st2 = Some (e, ef_sig, args).
Hypothesis eq_after_external:
forall (d : C1) (st1 : core_data) (st2 : C2) (ret : val)
(e : external_function) (args : list val) (ef_sig : signature),
(d = st1 /\ match_cores d st1 st2) ->
at_external Sem1 st1 = Some (e, ef_sig, args) ->
at_external Sem2 st2 = Some (e, ef_sig, args) ->
exists st1', exists st2', exists d',
after_external Sem1 (Some ret) st1 = Some st1' /\
after_external Sem2 (Some ret) st2 = Some st2' /\
d' = st1' /\ match_cores d' st1' st2'.
Section EQ_SIMULATION_STAR_WF.
Variable order: C1 -> C1 -> Prop.
Hypothesis order_wf: well_founded order.
Hypothesis eq_simulation:
forall c1 m c1' m',  corestep Sem1 ge1 c1 m c1' m' ->
forall c2, match_cores c1 c1 c2 ->
exists c2', match_cores c1' c1' c2' /\
(corestep_plus Sem2 ge2  c2 m c2' m' \/
(corestep_star Sem2 ge2 c2 m c2' m' /\ order c1' c1)).

Lemma  eq_simulation_star_wf:
@Forward_simulation_eq.Forward_simulation_equals _ _ _ _ _ _ _
Sem1 Sem2 ge1 ge2 entry_points.