End StepLemmas.
End StepLemmas.
(** ** Definition of internal steps *)
Module InternalSteps.
Section InternalSteps.
Context {Sem : Semantics}
{SemAx : SemAxioms}
{SemD : SemDet}.
Notation schedule := (seq nat).
Existing Instance OrdinalPool.OrdinalThreadPool.
Existing Instance dryResources.
Existing Instance DryHybridMachineSig.
(** Internal steps are just thread coresteps or resume steps or start steps, they mimic fine-grained internal steps *)
Definition internal_step {tid} {tp} m (cnt: containsThread tp tid)
(Hcomp: mem_compatible tp m) tp' m' :=
(exists ev, threadStep cnt Hcomp tp' m' ev) \/
(resume_thread m cnt tp' /\ m = m') \/
(start_thread m cnt tp' m').
(* For now we don't emit events from internal_execution*)
(*NOTE: we will probably never need to do so*)
Inductive internal_execution : schedule -> t -> mem ->
t -> mem -> Prop :=
| refl_exec : forall tp m,
internal_execution [::] tp m tp m
| step_trans : forall tid U U' tp m tp' m' tp'' m''
(cnt: containsThread tp tid)
(HschedN: schedPeek U = Some tid)
(HschedS: schedSkip U = U')
(Hcomp: mem_compatible tp m)
(Hstep: internal_step cnt Hcomp tp' m')
(Htrans: internal_execution U' tp' m' tp'' m''),
internal_execution U tp m tp'' m''.
(** ** Lemmas about internal steps and internal executions *)

(** Reverse composition of [internal_execution] and [internal_step]*)
Lemma internal_execution_trans :
forall i U tp tp' tp'' m m' m'' (pf': containsThread tp' i)
(Hcomp: mem_compatible tp' m')
(Hstep: internal_step pf' Hcomp tp'' m'')
(Hexec: internal_execution U tp m tp' m'),
internal_execution (U ++ (i :: nil))%list tp m tp'' m''.