(********************************************  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_max_path_field_load_nth_ram'':
forall {Espec: OracleKind},
forall n Delta sh id P Q R (e1: expr) Pre
(t 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,
typeof_temp Delta id = Some t ->
is_neutral_cast (typeof (nested_efield e1 efs tts)) t = true ->
readable_share sh ->
LR_of_type (nested_field_type t_root gfsA) = lr ->
type_is_volatile (typeof (nested_efield e1 efs tts)) = false ->
legal_nested_efield (nested_field_type t_root gfsA) e1 gfsB tts lr = true ->
JMeq v' v ->
nth_error R n = Some Pre ->
Pre |-- field_at sh t_root (gfsB ++ gfsA) v' a * TT ->
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)) |--
(tc_LR Delta e1 lr) &&
(tc_efield Delta efs) &&
local (efield_denote efs gfsB) &&
local `(tc_val (typeof (nested_efield e1 efs tts)) v) ->
semax Delta (|>PROPx P (LOCALx Q (SEPx R)))
(Sset id (nested_efield e1 efs tts))
(normal_ret_assert
(PROPx P
(LOCALx (temp id v :: remove_localdef_temp id Q)
(SEPx R)))).