(** * Erasure from FineConc to a non-angelic SC machine*)
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".
(** The erasure removes permissions and angels from the machine (i.e. making it a bare machine) and also allows some values to become more defined. See [val_erasure] and [memval_erasure] for a precise account of that. *)
(** ** Erasure of Values*)
Module ValErasure.
Definition isPointer (v : val) :=
match v with
| Vptr _ _ => true
| _ => false
end.
Definition val_erasure v1 v2 : Prop :=
match v1, v2 with
| Vundef, _ => True
| v1, v2 => v1 = v2
end.
Definition optionval_erasure (v1 v2 : option val) : Prop :=
match v1, v2 with
| Some v1, Some v2 => val_erasure v1 v2
| None, None => True
| _, _ => False
end.
Definition memval_erasure mv1 mv2 : Prop :=
match mv1, mv2 with
| Undef, _ => True
| Fragment v1 q1 n1, Fragment v2 q2 n2 =>
val_erasure v1 v2 /\ q1 = q2 /\ n1 = n2
| mv1, mv2 => mv1 = mv2
end.
Inductive val_erasure_list : seq.seq val -> seq.seq val -> Prop :=
val_erasure_nil : val_erasure_list [::] [::]
| val_erasure_cons : forall (v v' : val) (vl vl' : seq.seq val),
val_erasure v v' ->
val_erasure_list vl vl' ->
val_erasure_list (v :: vl) (v' :: vl').
Inductive memval_erasure_list : seq.seq memval -> seq.seq memval -> Prop :=
memval_erasure_nil : memval_erasure_list [::] [::]
| memval_erasure_cons : forall (mv mv' : memval) (mvl mvl' : seq.seq memval),
memval_erasure mv mv' ->
memval_erasure_list mvl mvl' ->
memval_erasure_list (mv :: mvl) (mv' :: mvl').

(* Specifications: *)
Lemma val_erasure_refl:
forall v, val_erasure v v.
Lemma memval_erasure_refl:
forall mval,
memval_erasure mval mval.