End BACKWARD_SIMULATION_SEQUENCES.
(** ** Composing two backward simulations *)
Section COMPOSE_BACKWARD_SIMULATIONS.
Variable L1: semantics.
Variable L2: semantics.
Variable L3: semantics.
Hypothesis L3_single_events: single_events L3.
Context index order match_states (S12: bsim_properties L1 L2 index order match_states).
Context index' order' match_states' (S23: bsim_properties L2 L3 index' order' match_states').
Let bb_index : Type := (index * index')%type.
Definition bb_order : bb_index -> bb_index -> Prop := lex_ord (clos_trans _ order) order'.
Inductive bb_match_states: bb_index -> state L1 -> state L3 -> Prop :=
| bb_match_later: forall i1 i2 s1 s3 s2x s2y,
match_states i1 s1 s2x -> Star L2 s2x E0 s2y -> match_states' i2 s2y s3 ->
bb_match_states (i1, i2) s1 s3.

(* Specifications: *)
Lemma bb_match_at: forall i1 i2 s1 s3 s2,
match_states i1 s1 s2 -> match_states' i2 s2 s3 ->
bb_match_states (i1, i2) s1 s3.
Lemma bb_simulation_base:
forall s3 t s3', Step L3 s3 t s3' ->
forall i1 s1 i2 s2, match_states i1 s1 s2 -> match_states' i2 s2 s3 -> safe L1 s1 ->
exists i', exists s1',
(Plus L1 s1 t s1' \/ (Star L1 s1 t s1' /\ bb_order i' (i1, i2)))
/\ bb_match_states i' s1' s3'.
Lemma bb_simulation:
forall s3 t s3', Step L3 s3 t s3' ->
forall i s1, bb_match_states i s1 s3 -> safe L1 s1 ->
exists i', exists s1',
(Plus L1 s1 t s1' \/ (Star L1 s1 t s1' /\ bb_order i' i))
/\ bb_match_states i' s1' s3'.
Lemma bb_match_at: forall i1 i2 s1 s3 s2,
match_states i1 s1 s2 -> match_states' i2 s2 s3 ->
bb_match_states (i1, i2) s1 s3.
Lemma bb_simulation_base:
forall s3 t s3', Step L3 s3 t s3' ->
forall i1 s1 i2 s2, match_states i1 s1 s2 -> match_states' i2 s2 s3 -> safe L1 s1 ->
exists i', exists s1',
(Plus L1 s1 t s1' \/ (Star L1 s1 t s1' /\ bb_order i' (i1, i2)))
/\ bb_match_states i' s1' s3'.
Lemma bb_simulation:
forall s3 t s3', Step L3 s3 t s3' ->
forall i s1, bb_match_states i s1 s3 -> safe L1 s1 ->
exists i', exists s1',
(Plus L1 s1 t s1' \/ (Star L1 s1 t s1' /\ bb_order i' i))
/\ bb_match_states i' s1' s3'.