End InternalSteps.
Arguments internal_step {Sem} {tid} {tp} {m}.
Arguments internal_execution {Sem} ge.
End InternalSteps.
(** ** Type of steps the concurrent machine supports *)
(*Note: Internal and External steps were introduced in the HybridMachine after this development. However, this is not exactly the same, as it treats resume and start steps as internal as well. Basically anything that may not pop the schedule *)
Module StepType.
event_semantics HybridMachine DryHybridMachine HybridMachineSig InternalSteps.
(** Distinguishing the various step types of the concurrent machine *)
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). *)

(* Specifications: *)
Lemma internal_step_type :
forall  i tp tp' m m' (cnt : containsThread tp i)
(Hcomp: mem_compatible tp m)
(Hstep_internal: internal_step cnt Hcomp tp' m'),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) cnt).1) in
cnt$mrestr @ I.
Lemma internal_step_result_type:
forall tp m tp' m' i (cnti: containsThread tp i)
(cnti': containsThread tp' i)
(Hcomp: mem_compatible tp m)
(Hcomp': mem_compatible tp' m')
(Hinternal: internal_step cnti Hcomp tp' m'),
let mrestr := restrPermMap (((compat_th _ _ Hcomp') cnti').1) in
~ (cnti'$mrestr @ E).
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).