(** Erasure Signature  *)
(** Describes the specification of the erasure in two parts: 1. Signature: Describes the axioms required to prove an erasure. 2. Functor: Using the axioms, sets up the erasure theorem/results  NOTE: Seems like the Functor is not used. TODO, remove the functor or rewrite it as a simulation (come back after erasure_proof / erasure_safety). *)
(* The concurrent machinery*)
(*The simulations*)
Definition init_inj_ok (j: Values.Val.meminj) m:=
forall b b' ofs, j b = Some (b', ofs) ->
b = b' /\
Mem.valid_block m b.
Module Type ErasureSig.
(*  Module SCH: Scheduler with Module TID:=NatTID:= THESCH. Import SCH.*)
Declare Instance Sem (ge : Clight.genv) : Semantics.
Declare Instance JR : Resources.
Declare Instance JTP (ge : Clight.genv) : ThreadPool.ThreadPool(Sem := Sem ge).
Declare Instance JMS (ge : Clight.genv) : MachineSig(ThreadPool := JTP ge).
Declare Instance DilMem : DiluteMem.
Declare Instance scheduler : Scheduler.
Declare Instance JuicyMachine (ge : Clight.genv) : HybridMachine(machineSig:=JMS ge).
Notation JMachineSem ge := (MachineSemantics(HybridMachine := JuicyMachine ge)).
Notation jres := (@res JR).
Notation jstate ge := (@ThreadPool.t _ _ (JTP ge)).
Notation jmachine_state ge := (@MachState _ _ (JTP ge)).
Declare Instance DR : Resources.
Declare Instance DTP (ge : Clight.genv) : ThreadPool.ThreadPool(Sem := Sem ge).
Declare Instance DMS (ge : Clight.genv) : MachineSig(ThreadPool := DTP ge).
Declare Instance DryMachine (ge : Clight.genv) : HybridMachine(machineSig := DMS ge).
Notation DMachineSem ge := (MachineSemantics(HybridMachine := DryMachine ge)).
Notation dres := (@res DR).
Notation dstate ge := (@ThreadPool.t _ _ (DTP ge)).
Notation dmachine_state ge := (@MachState _ _ (DTP ge)).
(*Parameter parch_state : jstate ->  dstate.*)
Parameter match_st : forall (ge : Clight.genv), jstate ge -> dstate ge -> Prop.

(* Specifications: *)
(*match axioms*)
Axiom MTCH_cnt: forall {ge js tid ds},
match_st ge js ds ->
ThreadPool.containsThread js tid -> ThreadPool.containsThread ds tid.
Axiom MTCH_cnt': forall {ge js tid ds},
match_st ge js ds ->
ThreadPool.containsThread ds tid -> ThreadPool.containsThread js tid.
Axiom  MTCH_getThreadC: forall ge js ds tid c,
forall (cnt: ThreadPool.containsThread js tid)
(cnt': ThreadPool.containsThread ds tid)
(M: match_st ge js ds),
ThreadPool.getThreadC cnt =  c ->
ThreadPool.getThreadC cnt'  =  c.
Axiom MTCH_compat: forall ge js ds m,
match_st ge js ds ->
mem_compatible js m ->
mem_compatible ds m.
Axiom MTCH_updt:
forall ge js ds tid c
(H0:match_st ge js ds)
(cnt: ThreadPool.containsThread js tid)
(cnt': ThreadPool.containsThread ds tid),
match_st ge (ThreadPool.updThreadC cnt c)
(ThreadPool.updThreadC cnt' c).