(*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.Notation jres := (@res JR).Notation jstate := (@ThreadPool.t _ _ (JTP ge)).Notation jmachine_state := (@MachState _ _ (JTP ge)).Notation dres := (@res DR).Notation dstate := (@ThreadPool.t _ _ (DTP ge)).Notation dmachine_state := (@MachState _ _ (DTP ge)).Instance DMS : MachineSig(ThreadPool := DTP ge) := DMS ge.Instance Sem : Semantics := Sem ge.Notation match_st := (match_st ge).(*Parameter halt_inv: SM_Injection ->
                      G -> Values.val -> M ->
                      G -> Values.val -> M -> Prop.
  Parameter init_inv: Values.Val.meminj ->
                      G ->  list Values.val -> M ->
                      G ->  list Values.val -> M ->  Prop.*)
    (*Erasure is about drying memory. So the invariants are trivial. *)
    Inductive init_inv:  Values.Val.meminj ->
                         semG -> list Values.val -> mem ->
                         semG -> list Values.val -> mem -> Prop:=
    |InitEq: forall j g1 args1 m1 g2 args2 m2,
        g1 = g2 ->
        args1 = args2 ->
        m1 = m2 ->
        init_inj_ok j m1 ->
        init_inv j g1 args1 m1 g2 args2 m2.(*Parameter halt_inv: SM_Injection ->
                      G -> Values.val -> M ->
                      G -> Values.val -> M -> Prop.
  Parameter init_inv: Values.Val.meminj ->
                      G ->  list Values.val -> M ->
                      G ->  list Values.val -> M ->  Prop.*)
    (*Erasure is about drying memory. So the invariants are trivial. *)
    Inductive init_inv:  Values.Val.meminj ->
                         semG -> list Values.val -> mem ->
                         semG -> list Values.val -> mem -> Prop:=
    |InitEq: forall j g1 args1 m1 g2 args2 m2,
        g1 = g2 ->
        args1 = args2 ->
        m1 = m2 ->
        init_inj_ok j m1 ->
        init_inv j g1 args1 m1 g2 args2 m2.Inductive halt_inv:  Values.Val.meminj ->
                         semG -> Values.val -> mem ->
                         semG -> Values.val -> mem -> Prop:=
    |HaltEq: forall j g1 args1 m1 g2 args2 m2,
        g1 = g2 ->
        args1 = args2 ->
        m1 = m2 ->
        halt_inv j g1 args1 m1 g2 args2 m2.Inductive halt_inv:  Values.Val.meminj ->
                         semG -> Values.val -> mem ->
                         semG -> Values.val -> mem -> Prop:=
    |HaltEq: forall j g1 args1 m1 g2 args2 m2,
        g1 = g2 ->
        args1 = args2 ->
        m1 = m2 ->
        halt_inv j g1 args1 m1 g2 args2 m2.Definition ge_inv: semG -> semG -> Prop:= @eq semG.Definition core_data:= unit.Definition core_ord: unit-> unit -> Prop := fun _ _ => False.(*States match if the dry part satisfies the invariant and the substates match.*)
    Inductive match_state :
      core_data ->  Values.Val.meminj -> jmachine_state ->  mem -> dmachine_state -> mem -> Prop:=
      MATCH: forall d j js ds U m,
        invariant ds -> (*This could better go inside the state... but it's fine here. *)
        match_st js ds ->
        match_state d j  (U, nil, js) m (U, nil, ds) m.(*States match if the dry part satisfies the invariant and the substates match.*)
    Inductive match_state :
      core_data ->  Values.Val.meminj -> jmachine_state ->  mem -> dmachine_state -> mem -> Prop:=
      MATCH: forall d j js ds U m,
        invariant ds -> (*This could better go inside the state... but it's fine here. *)
        match_st js ds ->
        match_state d j  (U, nil, js) m (U, nil, ds) m.

Lemma core_ord_wf: well_founded core_ord.