(***************************************  Load/store lemmas about mapsto: semax_load_nth_ram. semax_cast_load_nth_ram. semax_store_nth_ram.  ***************************************)

(* Specifications: *)
Lemma semax_load_nth_ram :
forall {Espec: OracleKind}{cs: compspecs} n (Delta: tycontext) sh id P Q R e1 Pre t1 t2 v p,
typeof e1 = t1 ->
typeof_temp Delta id = Some t2 ->
is_neutral_cast (typeof e1) t2 = true ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq p) (eval_lvalue e1)) ->
nth_error R n = Some Pre ->
readable_share sh ->
Pre |-- mapsto sh t1 p v * TT ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_lvalue Delta e1) && local (`(tc_val t1 v)) ->
@semax cs Espec Delta (|> PROPx P (LOCALx Q (SEPx R)))
(Sset id e1)
(normal_ret_assert
(PROPx P
(LOCALx (temp id v :: remove_localdef_temp id Q)
(SEPx R)))).
Lemma semax_cast_load_nth_ram :
forall {Espec: OracleKind}{cs: compspecs} n (Delta: tycontext) sh id P Q R e1 Pre t1 t2 v p,
typeof e1 = t1 ->
typeof_temp Delta id = Some t2 ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq p) (eval_lvalue e1)) ->
nth_error R n = Some Pre ->
cast_pointer_to_bool t1 t2 = false ->
readable_share sh ->
Pre |-- mapsto sh t1 p v * TT ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_lvalue Delta e1) && local (`(tc_val t2 (eval_cast t1 t2 v))) ->
@semax cs Espec Delta (|> PROPx P (LOCALx Q (SEPx R)))
(Sset id (Ecast e1 t2))
(normal_ret_assert
(PROPx P
(LOCALx (temp id (eval_cast t1 t2 v) :: remove_localdef_temp id Q)
(SEPx R)))).
Lemma semax_store_nth_ram:
forall {Espec: OracleKind} {cs: compspecs} n Delta P Q R e1 e2 Pre Post p v sh t1,
typeof e1 = t1 ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq p) (eval_lvalue e1)) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq v) (eval_expr (Ecast e2 t1))) ->
nth_error R n = Some Pre ->
writable_share sh ->
Pre |-- mapsto_ sh t1 p * (mapsto sh t1 p v -* Post) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_lvalue Delta e1) && (tc_expr Delta (Ecast e2 t1)) ->
semax Delta
(|> PROPx P (LOCALx Q (SEPx R)))
(Sassign e1 e2)
(normal_ret_assert
(PROPx P (LOCALx Q (SEPx (replace_nth n R Post))))).