(** Erasure Safety *)
(** Derive safety from the simulations. Erasure proven in [erasure_proof.v] and [erasure_signature.v] is stated as a simulation. Here we prove that the simulation implies safety. *)
(** *Imports*)
(* This file uses Proof Irrelevance: forall (P : Prop) (p1 p2 : P), p1 = p2. *)
(* CompCert imports*)
(* VST imports *)
(* Concurrency Imports *)
(*Erasure simulation*)
(*SSReflect*)
From mathcomp.ssreflect Require Import ssreflect ssrbool ssrnat eqtype seq.
From mathcomp.ssreflect Require Import ssreflect seq.
(*The simulations*)
(* Require Import VST.concurrency.common.machine_simulation.*)
Set Bullet Behavior "Strict Subproofs".
Module ErasureSafety.
Module ErasureProof := erasure_proof.Parching.
Module Erasure := ErasureFnctr ErasureProof.
Section ErasureSafety.
Context (initU: HybridMachineSig.schedule).
Context (init_rmap : @res JR).
Context (init_pmap : @res DR).
Context (init_rmap_perm:  match_rmap_perm init_rmap init_pmap).
(*Definition local_erasure:= erasure initU init_rmap init_pmap init_rmap_perm.*)
Definition step_diagram:= ErasureProof.core_diagram.
Existing Instance DMS.

Theorem erasure_safety: forall ge cd j js ds m n,
Erasure.match_state ge cd j js m ds m ->
jm_csafe js m n ->
HybridMachineSig.HybridCoarseMachine.csafe ds m n.