(** * Definitions and properties of machine executions *)
From mathcomp.ssreflect Require Import ssreflect ssrbool ssrnat ssrfun eqtype seq fintype finfun.
Set Implicit Arguments.
(*NOTE: because of redefinition of [val], these imports must appear after Ssreflect eqtype.*)
(* Require Import VST.concurrency.common.ClightSemanticsForMachines. *)
Set Bullet Behavior "None".
Set Bullet Behavior "Strict Subproofs".
Module Executions.
Section Executions.
Context
{Sem : Semantics}
{initU : seq.seq nat}
{SemAx : CoreLanguage.SemAxioms}
{SemD : CoreLanguage.SemDet}
{DilMem : DiluteMem}
{Res: Resources}.
(* Existing Instance FineDilMem. *)
Existing Instance HybridFineMachine.scheduler.
Existing Instance OrdinalPool.OrdinalThreadPool.
Context {Hbs : MachineSig}.
(** Reflexive-transitive closure of machine step relation*)
Inductive multi_step :
MachState -> mem -> MachState -> mem -> Prop :=
| Step_refl : forall ms (m : mem),
multi_step ms m ms m
| Step_trans : forall i U U'
(tp tp' tp'' : t)
tr tr' tr''
(m m' m'' : mem),
MachStep (i :: U, tr, tp) m (U, tr ++ tr', tp') m' ->
multi_step (U, tr ++ tr', tp') m' (U', tr ++ tr' ++ tr'', tp'') m'' ->
multi_step (i :: U,tr,tp) m (U',tr ++ tr' ++ tr'',tp'') m''.
(** Complete executions (until the schedule is empty) of the FineConc machine*)
Inductive fine_execution :
MachState -> mem -> MachState -> mem -> Prop :=
| fine_completed : forall ms (m : mem),
halted_machine ms ->
fine_execution ms m ms m
| fine_exec : forall i U U'
tp tp' tp''
tr tr' tr''
(m m' m'' : mem),
MachStep (i :: U, tr, tp) m (U, tr ++ tr', tp') m' ->
fine_execution (U, tr ++ tr', tp') m' (U', tr ++ tr' ++ tr'', tp'') m'' ->
fine_execution (i :: U,tr,tp) m (U',tr ++ tr' ++ tr'',tp'') m''.
(** ** Generic Properties of executions and steps *)

Lemma step_event_tid:
forall U tr tp m U' tr' tp' m'
(Hstep: MachStep (U, tr, tp) m
(U', tr ++ tr', tp') m'),
forall ev ev', List.In ev tr' ->
List.In ev' tr' ->
thread_id ev = thread_id ev'.