(* Lemma headptr_field_compatible' {cs: compspecs}: forall t p, headptr p -> legal_alignas_type t = true -> legal_cosu_type t = true -> sizeof t < Ptrofs.modulus -> complete_type cenv_cs t = true -> field_compatible t nil p. *)

(* Specifications: *)
Lemma mapsto_data_at'' {cs: compspecs}: forall sh t v v' p,
((type_is_by_value t) && (complete_legal_cosu_type t) && (negb (type_is_volatile t)) && is_aligned cenv_cs ha_env_cs la_env_cs t 0 = true)%bool ->
headptr p ->
JMeq v v' ->
mapsto sh t p v = data_at sh t v' p.
Lemma data_at_type_changable {cs}: forall (sh: Share.t) (t1 t2: type) v1 v2,
t1 = t2 ->
JMeq v1 v2 ->
@data_at cs sh t1 v1 = data_at sh t2 v2.
Lemma field_at__change_composite {cs_from cs_to} {CCE: change_composite_env cs_from cs_to}: forall (sh: Share.t) (t: type) gfs,
cs_preserve_type cs_from cs_to (coeq _ _) t = true ->
@field_at_ cs_from sh t gfs = @field_at_ cs_to sh t gfs.
Lemma data_at_change_composite {cs_from cs_to} {CCE: change_composite_env cs_from cs_to}: forall (sh: Share.t) (t: type) v1 v2,
JMeq v1 v2 ->
cs_preserve_type cs_from cs_to (coeq _ _) t = true ->
@data_at cs_from sh t v1 = @data_at cs_to sh t v2.
Lemma data_at__change_composite {cs_from cs_to} {CCE: change_composite_env cs_from cs_to}: forall (sh: Share.t) (t: type),
cs_preserve_type cs_from cs_to (coeq _ _) t = true ->
@data_at_ cs_from sh t = @data_at_ cs_to sh t.
(* TODO: rename and clean up all array_at_data_at lemmas. *)
Lemma array_at_data_at1 {cs} : forall sh t gfs lo hi v p,
lo <= hi ->
field_compatible0 t (gfs SUB lo) p ->
field_compatible0 t (gfs SUB hi) p ->
@array_at cs sh t gfs lo hi v p =
at_offset (@data_at cs sh (nested_field_array_type t gfs lo hi) v)
(nested_field_offset t (ArraySubsc lo :: gfs)) p.
Lemma data_at_ext_derives {cs} sh t v v' p q: v=v' -> p=q -> @data_at cs sh t v p |-- @data_at cs sh t v' q.
Lemma data_at_ext_eq {cs} sh t v v' p q: v=v' -> p=q -> @data_at cs sh t v p = @data_at cs sh t v' q.
Lemma field_at__field_at {cs: compspecs} :
forall sh t gfs v p, v = default_val (nested_field_type t gfs) -> field_at_ sh t gfs p |-- field_at sh t gfs v p.
Lemma data_at__field_at {cs: compspecs}:
forall sh t v p, v = default_val t -> data_at_ sh t p |-- field_at sh t nil v p.
Lemma field_at__data_at {cs: compspecs} :
forall sh t v p, v = default_val (nested_field_type t nil) -> field_at_ sh t nil p |-- data_at sh t v p.