Ltac instantiate_Vptr :=
match goal with
| H:isptr (eval_id ?i ?rho), A:name ?i
|- _ =>
let b := fresh "b_" A in
let z := fresh "z_" A in
let J := fresh "H_" A in
destruct (eval_id i rho) as [| | | | | b z] eqn:J; try contradiction H;
clear H; symmetry in J; rename J into H
| H:isptr (eval_id ?i ?rho)
|- _ =>
let b := fresh "b_"  in
let z := fresh "z_"  in
let J := fresh "H_"  in
destruct (eval_id i rho) as [| | | | | b z] eqn:J; try contradiction H;
clear H; symmetry in J; rename J into H
end.
Ltac solve_nth_error :=
match goal with |- @nth_error ?T (?A::_) ?n = Some ?B =>
first [unify n O; unfold nth_error, value; repeat f_equal; reflexivity
| let b := fresh "n" in evar (b:nat);  unify n (S b);
unfold nth_error; fold (@nth_error  T); solve_nth_error
]
end.
Ltac rewrite_eval_id :=
repeat match goal with H: ?v = (eval_id ?i ?rho) |- context [ (eval_id ?i ?rho) ] =>
rewrite <- H
end.

Lemma rel_expr_nested_load {cs: compspecs}:
forall sh p t_root v e lr efs tts gfs P rho,
legal_nested_efield t_root e gfs tts lr = true ->
type_is_by_value (nested_field_type2 t_root gfs) = true ->
P |-- rel_LR e lr p rho && efield_denote efs gfs rho && (data_at sh t_root v p * TT) ->
P |-- rel_expr (nested_efield e efs tts) (repinject _ (proj_reptype t_root gfs v)) rho.