End Extensions.
(** *Extension Phases*)
Section Injection.
Record fsim_properties_inj: Type :=
{  Injindex: Type;
Injorder: Injindex -> Injindex -> Prop;
Injmatch_states: Injindex -> meminj -> state L1 -> state L2 -> Prop;
Injfsim_order_wf: well_founded Injorder;
Injfsim_match_meminj: forall i f s1 s2, Injmatch_states i f s1 s2 ->  Mem.inject f (get_mem1 s1) (get_mem2 s2);
Injfsim_match_full: forall i f s1 s2,
Injmatch_states i f s1 s2 ->
injection_full f (get_mem1 s1);
Injfsim_match_start_stacks:
forall s1 f arg m0, start_stack L1 m0 s1 f arg  ->
exists i j s2, start_stack L2 m0 s2 f arg /\ Injmatch_states i j s1 s2;
Injfsim_match_initial_states:
forall s1, initial_state L1 s1 ->
exists i f s2, initial_state L2 s2 /\ Injmatch_states i f s1 s2;
Injfsim_match_final_states:
forall i s1 s2 r f,
Injmatch_states i f s1 s2 -> final_state L1 s1 r -> (final_state L2 s2 r);
Injfsim_simulation:
forall s1 t s1' f, Step L1 s1 t s1' ->
forall i s2, Injmatch_states i f s1 s2 ->
exists i', exists s2' f' t',
(Plus L2 s2 t' s2' \/ (Star L2 s2 t' s2' /\ Injorder i' i))
/\ Injmatch_states i' f' s1' s2' /\
Values.inject_incr f f' /\
inject_trace f' t t';
Injfsim_public_preserved:
forall id, Senv.public_symbol (symbolenv L2) id = Senv.public_symbol (symbolenv L1) id
}.
(** An alternate form of the simulation diagram *)

(* Specifications: *)
Lemma Injfsim_simulation':
forall (SIM:fsim_properties_inj),
forall i s1 t s1' f,
Step L1 s1 t s1' ->
forall s2, Injmatch_states SIM i f s1 s2 ->
(exists i', exists s2' f' t',
Plus L2 s2 t' s2' /\
Injmatch_states SIM i' f' s1' s2'
/\ inject_incr f f' /\ inject_trace f' t t')
\/ (exists i' f', Injorder SIM i' i /\ t = E0 /\ Injmatch_states SIM i' f' s1' s2
/\ inject_incr f f').
(** *Star version of simulation*)
Lemma Injsimulation_star:
forall (SIM:fsim_properties_inj),
forall s1 t s1', Star L1 s1 t s1' ->
forall i f s2,
Injmatch_states SIM i f s1 s2 ->
exists i' f', exists s2' t', Star L2 s2 t' s2' /\ Injmatch_states SIM i' f' s1' s2'
/\ inject_incr f f' /\ inject_trace f' t t'.
(** *Plus version of simulation*)
Lemma Injsimulation_plus:
forall (SIM:fsim_properties_inj),
forall s1 t s1', Plus L1 s1 t s1' ->
forall i f s2, Injmatch_states SIM i f s1 s2 ->
(exists i', exists f', exists s2' t', Plus L2 s2 t' s2' /\ Injmatch_states SIM i' f' s1' s2'
/\ inject_incr f f' /\ inject_trace f' t t')
\/ (exists i', exists f', clos_trans _ (Injorder SIM) i' i /\ t = E0 /\ Injmatch_states SIM i' f' s1' s2
/\ inject_incr f f').