(* Y_DEFS ends. *)
Module Alternative.
Fixpoint ytree_rep (t: YTree) (p: val): mpred :=
match t with
| YLeaf =>
!!(p = nullval) && emp
| YNode ttl v =>
EX q: val, EX r: list val,
data_at Tsh t_struct_Ynode (q, Vint (Int.repr v)) p *
list_rep (fun r n q => data_at Tsh t_struct_Ylist (r, n) q) r q *
iter_sepcon2 (fun tt_u_pair r =>
EX s: tree val,
tree_rep (fun p L R r => data_at Tsh t_struct_Ytree (p, (L, R)) r) s r *
iter_tree_sepcon2 (fun u_t_pair s => ytree_rep (snd u_t_pair) s) (fst tt_u_pair) s) ttl r
end.
End Alternative.
Fixpoint x_add1 (t: XTree): XTree :=
match t with
| XLeaf =>
XLeaf
| XNode tl v =>
XNode (map x_add1 tl) (v + 1)
end.
Section Forall_XTree.
Variable (P: Z -> Prop).
Fixpoint Forall_XTree (t: XTree): Prop :=
match t with
| XLeaf =>
True
| XNode tl v =>
fold_right and (P v) (map Forall_XTree tl)
end.
End Forall_XTree.

(* Specifications: *)
Lemma add1_pos: forall t, Forall_XTree (fun x => x >= 0) t -> Forall_XTree (fun x => x > 0) (x_add1 t).
Definition Xnode_add_spec :=
DECLARE _Xnode_add
WITH p: val, t: XTree
PRE  [ _p OF (tptr t_struct_Xnode) ]
PROP  ()
LOCAL (temp _p p)
SEP (xtree_rep t p)
POST [ Tvoid ]
PROP()
LOCAL()
SEP (xtree_rep (x_add1 t) p).