(********************************************  Max length gfs field_at load store: semax_max_path_field_load_nth_ram. semax_max_path_field_cast_load_nth_ram. semax_max_path_field_store_nth_ram.  ********************************************)
Section LOADSTORE_FIELD_AT.
Context {cs: compspecs}.

(* TODO: delete it *)
Lemma semax_partial_path_field_store_nth_ram:
forall {Espec: OracleKind},
forall n Delta sh P Q R (e1 e2 : expr) Pre Post
(t_root: type) (efs: list efield) (gfsA gfsB: list gfield) (tts: list type)
(a v : val) (v' : reptype (nested_field_type t_root (gfsB ++ gfsA))) lr,
type_is_by_value (typeof (nested_efield e1 efs tts)) = true ->
writable_share sh ->
LR_of_type (nested_field_type t_root gfsA) = lr ->
type_is_volatile (typeof (nested_efield e1 efs tts)) = false ->
JMeq v v' ->
nth_error R n = Some Pre ->
Pre |-- field_at_ sh t_root (gfsB ++ gfsA) a *
(field_at sh t_root (gfsB ++ gfsA) v' a -* Post) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq (field_address t_root gfsA a)) (eval_LR e1 lr)) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
local (`(eq v) (eval_expr (Ecast e2 (typeof (nested_efield e1 efs tts))))) ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
(tc_LR Delta e1 lr) &&
(tc_efield Delta efs) &&
local (efield_denote efs gfsB) &&
(tc_expr Delta (Ecast e2 (typeof (nested_efield e1 efs tts)))) ->
legal_nested_efield (nested_field_type t_root gfsA) e1 gfsB tts lr = true ->
semax Delta (|>PROPx P (LOCALx Q (SEPx R)))
(Sassign (nested_efield e1 efs tts) e2)
(normal_ret_assert
(PROPx P
(LOCALx Q
(SEPx
(replace_nth n R Post))))).