(** 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.

Lemma erasure_safety': forall n ge sch js jtr ds dtr m,
ErasureProof.match_st ge js ds ->
DryHybridMachine.invariant ds ->
jm_csafe (sch, jtr, js) m n ->
HybridMachineSig.HybridCoarseMachine.csafe (sch, dtr, ds) m n.