(* This in principle is not provable. We should get it somehow from the simulation. Possibly, by showing that the (internal) Clight step has no traces and allo external function calls have traces, so the "matching" Asm execution must be all internal steps (because otherwise the traces wouldn't match). *)
Admitted.

(* Specifications: *)
Lemma Forall2_impl: forall {A B} (P Q : A -> B -> Prop) l1 l2,
(forall a b, P a b -> Q a b) -> List.Forall2 P l1 l2 -> List.Forall2 Q l1 l2.
Lemma inject_incr_trace:
forall (tr1 tr2 : list Events.machine_event) (mu f' : meminj),
inject_incr mu f' ->
List.Forall2 (inject_mevent mu) tr1 tr2 ->
List.Forall2 (inject_mevent f') tr1 tr2.
(* When a thread takes an internal step (i.e. not changing the schedule) *)
Lemma internal_step_diagram:
forall (m : option mem) (sge tge : HybridMachineSig.G) (U : list nat)
tr1 (st1 : ThreadPool (Some hb)) (m1 : mem) (st1' : ThreadPool (Some hb))
(m1' : mem),
machine_semantics.thread_step (HybConcSem (Some hb) m) sge U st1 m1 st1' m1' ->
forall (cd : option compiler_index) tr2 (st2 : ThreadPool (Some (S hb)))
(mu : meminj) (m2 : mem),
concur_match cd mu st1 m1 st2 m2 ->
forall (Hmatch_event : List.Forall2 (inject_mevent mu) tr1 tr2),
exists
(st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index)
(mu' : meminj),
concur_match cd' mu' st1' m1' st2' m2' /\
List.Forall2 (inject_mevent mu') tr1 tr2 /\
(machine_semantics_lemmas.thread_step_plus
(HybConcSem (Some (S hb)) m) tge U st2 m2
st2' m2' \/
machine_semantics_lemmas.thread_step_star
(HybConcSem (Some (S hb)) m) tge U st2 m2
st2' m2' /\ ord_opt (Injorder compiler_sim) cd' cd).