Instance CompSpecs : compspecs. make_compspecs prog. Defined.
Definition Vprog : varspecs. mk_varspecs prog. Defined.
Definition t_struct_tree := Tstruct _tree noattr.
Fixpoint tree_rep (t: tree val) (p: val) : mpred :=
match t with
| E => !!(p=nullval) && emp
| T a x v b => !! (Int.min_signed <= Z.of_nat x <= Int.max_signed /\ tc_val (tptr Tvoid) v) &&
EX pa:val, EX pb:val,
data_at Tsh t_struct_tree (Vint (Int.repr (Z.of_nat x)),(v,(pa,pb))) p *
tree_rep a pa * tree_rep b pb
end.
Definition treebox_rep (t: tree val) (b: val) :=
EX p: val, data_at Tsh (tptr t_struct_tree) p b * tree_rep t p.
Arguments tree_rep: simpl never.
Arguments treebox_rep: simpl never.
Opaque treebox_rep tree_rep.
Hint Resolve tree_rep_saturate_local: saturate_local.
Hint Resolve tree_rep_valid_pointer: valid_pointer.
Hint Resolve treebox_rep_saturate_local: saturate_local.
Hint Resolve tree_rep_nullval: saturate_local.

Lemma tree_rep_internal: forall l x v r (p p1 p2: val),
Int.min_signed <= Z.of_nat x <= Int.max_signed ->
tc_val (tptr Tvoid) v ->
data_at Tsh t_struct_tree (Vint (Int.repr (Z.of_nat x)), (v, (p1, p2))) p *
tree_rep l p1 *
tree_rep r p2 |--
tree_rep (T l x v r) p.