Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
(** Symmetrically, [encode_val], applied to values related by [val_inject],
returns lists of memory values that are pairwise
related by [memval_inject]. *)
Lemma inj_bytes_inject:
forall f bl, list_forall2 (memval_inject f) (inj_bytes bl) (inj_bytes bl).
Proof.
induction bl; constructor; auto. constructor.
Qed.
Lemma repeat_Undef_inject_any:
forall f vl,
list_forall2 (memval_inject f) (list_repeat (length vl) Undef) vl.
Proof.
induction vl; simpl; constructor; auto. constructor.
Qed.
Lemma repeat_Undef_inject_self:
forall f n,
list_forall2 (memval_inject f) (list_repeat n Undef) (list_repeat n Undef).
Proof.
induction n; simpl; constructor; auto. constructor.
Qed.
Theorem encode_val_inject:
forall f v1 v2 chunk,
val_inject f v1 v2 ->
list_forall2 (memval_inject f) (encode_val chunk v1) (encode_val chunk v2).
Proof.
intros. inv H; simpl.
apply inj_bytes_inject.
apply inj_bytes_inject.
destruct chunk; try apply repeat_Undef_inject_self.
unfold inj_pointer; simpl; repeat econstructor; auto.
replace (size_chunk_nat chunk) with (length (encode_val chunk v2)).
apply repeat_Undef_inject_any. apply encode_val_length.
Qed.
(** The identity injection has interesting properties. *)
Definition inject_id : meminj := fun b => Some(b, 0).
Lemma val_inject_id:
forall v1 v2,
val_inject inject_id v1 v2 <-> Val.lessdef v1 v2.
Proof.
intros; split; intros.
inv H. constructor. constructor.
unfold inject_id in H0. inv H0. rewrite Int.add_zero. constructor.
constructor.
inv H. destruct v2; econstructor. unfold inject_id; reflexivity. rewrite Int.add_zero; auto.
constructor.
Qed.
Lemma memval_inject_id:
forall mv, memval_inject inject_id mv mv.
Proof.
destruct mv; econstructor. unfold inject_id; reflexivity. rewrite Int.add_zero; auto.
Qed.