(** * Safety of the FineConc Machine (abstract semantics)*)
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.*)
Set Bullet Behavior "None".
Set Bullet Behavior "Strict Subproofs".
Module FineConcInitial.
AsmContext CoreInjections event_semantics.
Section FineConcInitial.
Context {Sem : Semantics}
{CI: CoreInj}.
Class FineInit :=
{ init_mem : Memory.Mem.mem; (** some initial memory *)
init_mem_wd: (** The initial memory is well-defined*)
valid_mem init_mem;
the_ge_wd:   (** The initial global env is well-defined*)
ge_wd (id_ren init_mem) the_ge
}.
(* init_core_wd:   (** The initial core is well-defined*) *)
(*   forall c v args m m' (ARGS:valid_val_list (id_ren m) args), *)
(*     init_mem = Some m -> *)
(*     initial_core semSem 0 m c m' v args -> *)
(*     core_wd (id_ren m) c /\ valid_mem m'; *)
End FineConcInitial.
End FineConcInitial.
(** ** Safety for FineConc (interleaving) semantics *)
Module FineConcSafe.
Section FineConcSafe.
Context {Sem : Semantics}
{semAx: CoreLanguage.SemAxioms}
{semDet: CoreLanguage.SemDet}
{CI : CoreInj}
{FI : FineInit}.
(** Excluded middle is required, but can be easily lifted*)
Variable em : ClassicalFacts.excluded_middle.
(* Is this the right instance? *)
Existing Instance DryHybridMachine.dryResources.
Existing Instance DryHybridMachine.DryHybridMachineSig.
Existing Instance OrdinalPool.OrdinalThreadPool.
Existing Instance dryFineMach.
Existing Instance FineDilMem.
Existing Instance dryCoarseMach.
Existing Instance HybridFineMachine.scheduler.
Existing Instance HybridCoarseMachine.scheduler.
Existing Instance HybridCoarseMachine.DilMem.

(* Specifications: *)
Lemma init_tp_wd:
forall pmap v args m' tp (ARGS:valid_val_list (id_ren init_mem) args),
@init_mach DryHybridMachine.dryResources _ _ _ pmap init_mem tp m' v args ->
tp_wd (id_ren m') tp /\ valid_mem m'.