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').
Hint Immediate memval_erasure_refl val_erasure_refl : val_erasure.
Hint Constructors memval_erasure_list val_erasure_list : val_erasure.
Proof with eauto with val_erasure.
induction vs; simpl...
Qed.
(* TODO: is that still used? *)
(*Lemma val_erasure_list_decode: forall vals vals' typs, val_erasure_list vals vals' -> val_erasure_list (val_casted.decode_longs typs vals) (val_casted.decode_longs typs vals').  Lemma memval_erasure_list_refl: forall vs, memval_erasure_list vs vs. Proof with eauto with val_erasure. induction vs; simpl... Qed.  Hint Immediate memval_erasure_list_refl : val_erasure.  (** ** Lemmas about erased values*)
Definition isDefined v :=
match v with
| Vundef => false
| _ => true
end.

Lemma val_erasure_sub:
forall v1 v2 v1' v2',
val_erasure v1 v1' ->
val_erasure v2 v2' ->
val_erasure (Val.sub v1 v2) (Val.sub v1' v2').