Section StepType.
Context {Sem : Semantics}
{Sch: Scheduler}.
Existing Instance dryResources.
Existing Instance OrdinalPool.OrdinalThreadPool.
Existing Instance DryHybridMachineSig.
Inductive StepType : Type :=
Internal | Concurrent | Suspend.
Definition ctlType (code : @threadPool.ctl semC) (m : Mem.mem) (st : StepType) : Prop :=
match code with
| Kinit _ _ => st = Internal
| Krun c =>
match at_external semSem c m with
| None => (* ((exists i, halted semSem c i) /\ st = Halted) \/ *)
st = Internal
| Some _ => st = Suspend
end
| Kblocked c => st = Concurrent
| Kresume c _ => st = Internal
end.
Definition getStepType {i tp} (cnt : containsThread tp i) m st :=
ctlType (getThreadC cnt) m st.
Notation "cnt '$' m '@'  'I'" := (getStepType cnt m Internal) (at level 80).
Notation "cnt '$' m '@'  'E'" := (getStepType cnt m Concurrent) (at level 80).
Notation "cnt '$' m '@'  'S'" := (getStepType cnt m Suspend) (at level 80).
(* Notation "cnt '$' m '@'  'H'" := (getStepType cnt m Halted) (at level 80). *)

Lemma internal_execution_result_type:
forall tp m tp' m' i xs
(cnti': containsThread tp' i)
(Hin: List.In i xs)
(Hcomp': mem_compatible tp' m')
(Hexec: internal_execution [seq x <- xs | x == i] tp m tp' m'),
let mrestr := restrPermMap (((compat_th _ _ Hcomp') cnti').1) in
~ (cnti'$mrestr @ E).